IC: time the export branch's two halves, so the next lever is sized

`processTopLevel`'s `export` branch is 484ms of an 8.64s build, and the split
matters for what to do about it: `resolveSym` is 118ms, `addReexportedEnumFields`
is 290ms over 34815 exported symbols — 8.3us each.

That cost is one line: `addReexportedEnumFields` calls `loadSym` to force the
symbol out of `Partial` state and THEN asks whether it is a non-pure enum type.
Almost none of them are, so nearly all of that is a full symbol decode done to
answer a question the def's header already contains — a sym is written as
`(sd <name> <marker> <kind> ...)`, so the kind is two tokens in.

Not fixed here, deliberately. A peek would have to hand-walk that layout, and
mis-stepping it misclassifies silently rather than failing; it is worth doing
with an oracle beside it, the way `indexFromBif` was. Sized and recorded so the
next person starts from a number instead of a hunch.

Timers only — no behaviour change; verified 67/67 `.c` byte-identical.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FMyRHByv7hhaQJ4Pa1bHbE
This commit is contained in:
araq
2026-08-30 23:55:58 +02:00
parent 1a70426a5b
commit 4c6d7d2d20
2 changed files with 5 additions and 1 deletions

View File

@@ -4140,10 +4140,14 @@ proc processTopLevel(c: var DecodeContext; cur: var Cursor; flags: set[LoadFlag]
# being compiled fresh (they would collide with the fresh originals).
if c.mainModuleSuffix.len == 0 or
parseSymName(symAsStr).module != c.mainModuleSuffix:
icProfStart(tResolveSym)
let sym = resolveSym(c, symAsStr, false)
icProfStop(tResolveSym)
if sym != nil:
strTableAdd(interf, sym)
icProfStart(tEnumFields)
addReexportedEnumFields(c, sym, interf)
icProfStop(tEnumFields)
skip cur
else:
raiseAssert "expected Symbol or ParRi but got " & $cur.kind &

View File

@@ -36,7 +36,7 @@ when defined(icBNodeProf):
TimeSlot* = enum
tLoadClosure, tModuleId, tBifLoad, tPosIndex, tTopLevel, tInterfTables,
tTransform, tHandOff, tGenBody, tAnalyses,
tSym, tTyp, tInfo, tOrigin, tExportBranch
tSym, tTyp, tInfo, tOrigin, tExportBranch, tResolveSym, tEnumFields
var profCounts: array[ProfSlot, int]
var profNanos: array[TimeSlot, int64]