Skip to content

[Code Health] Rename span families to pod/host/chip/core — coordinated across simpler, pypto-lib, pypto-serving #1793

Description

@ChaoWao

Category

Naming / Consistency

Component

Other (please specify in description)

Affects the [STRACE] span vocabulary, which spans src/common/,
simpler_setup/tools/, the docs, and two external repositories.

Description

Span names currently come in two unrelated families with no shared scheme, and one
of them is a de-facto contract with repositories outside this one.

Today:

Family Emitted by Occurrences
simpler_run*, simpler_prewarm.* the chip runtime in the forked child ~185 in 37 files
l3.* the L3 parent (added by #1730, unreleased) ~59 in 17 files

The scheme. One word per level of the hierarchy — the same levels, named
instead of numbered:

Prefix Level What it describes Replaces
pod. L4 a Worker whose children are L3 Workers nothing emits it yet
host. L3 one host driving chips: graph build, submit, dispatch, worker threads l3.*
chip. L2 the chip runtime in the forked child simpler_run*, simpler_prewarm.*
core. L0 the in-core AIC/AIV pipeline the core-swimlane tool's own output

Numeric levels stay out of the names, consistent with codestyle rule 13's mapping
of L2 → Chip and L0 → Core. Rule 13 lumps L3+ together as unprefixed because
it governs type and identifier names, where one Worker serves every level above
the chip; a trace does need L3 distinguished from L4, hence two words where the rule
has none.

The prefix is per process, not per call site. Orchestrator::submit_impl and
WorkerThread::submit_dispatch are level-agnostic — the same code runs at L3 and
L4. It does not need to be per site: a Worker forks its next-level children into
separate processes, so one process hosts exactly one Worker level, and the prefix
resolves once at Worker init.

Reserve a namespace for external producers. pod./host./chip./core. are our
levels and a caller is not one of them; without a reserved prefix a caller's span
named host.foo parses as ours. Settle it here rather than when a public tracing
API lands, because this is the one moment every name and every parser is already
being touched.

Location

Inside this repo:

  • simpler_setup/tools/strace_timing.py — legacy_spans(), _ROUNDS_TABLE_NAMES,
    _host_thread_name, the swimlane process-role test, the flow-key pairing
  • Hardcoded assertions that will fail loudly (good):
    tests/st/a2a3/host_build_graph/native_run_lifecycle/test_native_run_lifecycle.py
    (an expected-depth table), tests/st/a5/tensormap_and_ringbuffer/bench_prewarm_timing.py
    (a compiled regex on name=simpler_run.bind.prebuilt),
    examples/workers/l2/vector_add/test_run_timing.py, tests/ut/py/test_strace_timing.py
  • Docs: docs/dfx/host-trace.md, docs/dfx/l2-timing.md, docs/dfx/device-phases.md,
    simpler_setup/tools/README.md, and the dfx-analyze / benchmark skills

Outside this repo — the reason this needs coordination rather than a rename commit:

docs/dfx/host-trace.md frames this as a feature: "A consumer (e.g. pypto-serving)
reads the per-stage breakdown from the log, with no code change on its side and no
API contract."
"No API contract" is precisely the problem — the names are the
contract. #1210 already renamed a span root once, the downstream repo had to adapt,
and the scar is still in its code.

Proposed Fix

Coordinated rename across simpler, pypto-lib and pypto-serving together — no
dual-spelling window and no alias table, so the retired spellings actually go away
rather than lingering the way #1210's did.

  1. Settle the merge order. simpler emits the new names, so it lands last or behind
    something the other two can pin against; otherwise their parsers see unknown
    names for the window between merges.
  2. Rename in simpler, and replace legacy_spans()'s allow-list with an explicit
    family split so per-task host.* spans stay out of the invocation-grouping path.
  3. Downstream edits in the two files located above.
  4. A grep gate per repo: zero occurrences of the retired spellings, in prose as
    well as code
    , since the pypto-serving consumer is a runbook.

Blocked on #1792's "one span entry point" item — renaming one emit site is far
easier than renaming three — and on the by_name() fix requested in #1730, because
removing the allow-list is what makes that latent bug live.

Priority

Medium

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    code healthTechnical debt, robustness, code quality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions