Skip to content

perf(semantics): bring big-model load back toward 0.12.1 - #2399

Merged
HuiJun merged 6 commits into
developfrom
perf/big-model-load-regressions
Nov 19, 2026
Merged

HuiJun merged 6 commits into
developfrom
perf/big-model-load-regressions

Conversation

@HuiJun

@HuiJun HuiJun commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

Loading a large model regressed against v0.12.1 in time and allocations (BenchmarkLoad, BenchmarkLoadFiles, BenchmarkAnalyze/synthetic). Profiles of LoadFiles/satellites=128 put the cost in four places on the semantic load path, each fixed here without changing a diagnostic:

  • Inheritance loss was derived again per redefinition. Resolving a redefinition target asks for the owning type's inheritanceLoss while that type's own redefinitions are unsettled, and the whole walk was discarded, supertypes included. walkInheritanceLoss now gives each type a lookup frame of its own, and a supertype whose derivation no guard cut short stays memoized. A type met again within a walk cuts its reader short, as a memoized guard entry already did.
  • Qualified metaclass names were concatenated on every classification (sysmlMetaclass, kermlMetaclass). They are kept per model.
  • conforms derived the target's element key once per supertype through SameElement. It is derived once per query.
  • EffectiveIsComposite was derived on every read of a feature's isVariable, which the redefinition and restriction checks read for every feature. The settled answer is memoized per feature, owned by its declaring document, and not kept when a resolution guard cut the derivation short.

How it was verified

  • go build ./..., go vet ./..., gofmt -l ., make lint, go test -count=1 ./tests/hygiene and go test -timeout 60m ./... pass locally on this head (the full suite after regenerating the git-ignored stdlib.snapshot).
  • New tests: TestSupertypeLossStaysMemoizedWhenTheSubtypeWalkIsCutShort (fails without the fix) and TestEffectiveIsCompositeMemoFollowsTheDeclaringDocument.

Benchmarks: v0.12.1 against develop with #2378, #2379 and #2380 merged, and against the same tree with this branch merged; Go 1.27.4, 8 cores, six interleaved rounds (-benchtime 3x for load, 5x for analyze), three rounds of ConvertAPIJSON at 1x.

                    │ v0.12.1.txt │         develop+queued.txt         │          this-branch.txt           │
                    │   sec/op    │   sec/op     vs base               │   sec/op     vs base               │
Analyze/synthetic-8   1.452 ± 12%   1.800 ± 15%  +23.97% (p=0.004 n=6)   1.623 ± 12%  +11.82% (p=0.026 n=6)
                    │ v0.12.1.txt  │         develop+queued.txt          │          this-branch.txt           │
                    │     B/op     │     B/op      vs base               │     B/op      vs base              │
Analyze/synthetic-8   486.2Mi ± 0%   548.9Mi ± 0%  +12.89% (p=0.002 n=6)   529.3Mi ± 0%  +8.88% (p=0.002 n=6)
                    │ v0.12.1.txt │         develop+queued.txt         │          this-branch.txt          │
                    │  allocs/op  │  allocs/op   vs base               │  allocs/op   vs base              │
Analyze/synthetic-8   5.410M ± 0%   6.238M ± 0%  +15.30% (p=0.002 n=6)   5.750M ± 0%  +6.29% (p=0.002 n=6)
                                               │  v0.12.1.txt   │           develop+queued.txt            │             this-branch.txt             │
                                               │     sec/op     │     sec/op      vs base                 │     sec/op      vs base                 │
Load/satellites=128/elements=24167-8              2.393 ± 18%      3.016 ±  5%    +26.06% (p=0.002 n=6)      2.465 ±  6%          ~ (p=0.818 n=6)
Load/satellites=512/elements=95927-8              10.09 ± 23%      12.51 ±  6%    +23.93% (p=0.015 n=6)      10.44 ±  8%          ~ (p=0.394 n=6)
LoadFiles/satellites=128/files=6-8                2.643 ±  8%      3.443 ± 17%    +30.29% (p=0.002 n=6)      2.874 ±  8%     +8.75% (p=0.015 n=6)
LoadFiles/satellites=512/files=6-8                10.80 ±  5%      14.94 ±  5%    +38.28% (p=0.002 n=6)      11.94 ±  5%    +10.49% (p=0.004 n=6)
ConvertAPIJSON/satellites=128/elements=24167-8    58.04 ±   ∞ ¹    79.42 ±   ∞ ¹        ~ (p=0.100 n=3) ²    74.90 ±   ∞ ¹        ~ (p=0.100 n=3) ²
geomean                                           3.937            5.148          +30.75%                    4.325           +9.85%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05
                                               │  v0.12.1.txt   │           develop+queued.txt            │            this-branch.txt             │
                                               │      B/op      │      B/op       vs base                 │      B/op       vs base                │
Load/satellites=128/elements=24167-8             673.4Mi ± 0%     808.9Mi ± 0%    +20.12% (p=0.002 n=6)     687.0Mi ± 0%    +2.02% (p=0.002 n=6)
Load/satellites=512/elements=95927-8             2.582Gi ± 0%     3.108Gi ± 0%    +20.37% (p=0.002 n=6)     2.635Gi ± 0%    +2.02% (p=0.002 n=6)
LoadFiles/satellites=128/files=6-8               662.7Mi ± 0%     849.2Mi ± 0%    +28.15% (p=0.002 n=6)     715.3Mi ± 0%    +7.95% (p=0.002 n=6)
LoadFiles/satellites=512/files=6-8               2.534Gi ± 0%     3.264Gi ± 0%    +28.79% (p=0.002 n=6)     2.741Gi ± 0%    +8.16% (p=0.002 n=6)
ConvertAPIJSON/satellites=128/elements=24167-8   32.77Gi ±  ∞ ¹   35.39Gi ±  ∞ ¹        ~ (p=0.100 n=3) ²   35.21Gi ±  ∞ ¹       ~ (p=0.100 n=3) ²
geomean                                          1.172Gi          1.419Gi         +21.09%                   1.233Gi         +5.21%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05
                                               │  v0.12.1.txt   │           develop+queued.txt            │            this-branch.txt            │
                                               │   allocs/op    │   allocs/op     vs base                 │   allocs/op    vs base                │
Load/satellites=128/elements=24167-8             10.344M ± 0%     12.337M ± 0%    +19.26% (p=0.002 n=6)     9.677M ± 0%    -6.45% (p=0.002 n=6)
Load/satellites=512/elements=95927-8              41.02M ± 0%      48.97M ± 0%    +19.37% (p=0.002 n=6)     38.36M ± 0%    -6.49% (p=0.002 n=6)
LoadFiles/satellites=128/files=6-8                9.728M ± 0%     12.573M ± 0%    +29.25% (p=0.002 n=6)     9.719M ± 0%    -0.09% (p=0.002 n=6)
LoadFiles/satellites=512/files=6-8                37.92M ± 0%      49.27M ± 0%    +29.93% (p=0.002 n=6)     37.88M ± 0%    -0.11% (p=0.002 n=6)
ConvertAPIJSON/satellites=128/elements=24167-8    162.1M ±  ∞ ¹    203.1M ±  ∞ ¹        ~ (p=0.100 n=3) ²   197.8M ±  ∞ ¹       ~ (p=0.100 n=3) ²
geomean                                           15.13M           18.77M         +24.03%                   15.13M         -0.03%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05

Against develop with the queued fixes, load time falls 17–20% (p=0.002) and load allocations 22–23%.

Known caveats

  • LoadFiles is still 9–10% slower than v0.12.1 and allocates 8% more bytes; Load is within noise of v0.12.1.
  • Analyze/synthetic is still +12% time and +6% allocations; the time difference from develop is not significant at six rounds on this machine (±12–15%).
  • ConvertAPIJSON/satellites=128 is not improved by this change. Its remaining time is in the api-json writer's derived properties (structureDirectedFeatures, structureEffectiveFeatures), and the conversion writes about 46% more output than in v0.12.1, so it is not a load-path regression.

Checklist

  • make test and make lint pass locally (go test ./... without the race detector, and make lint)
  • Tests added or updated for the change
  • Documentation extended where it already covers the surface (none covers these internals)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md
  • baselines regenerated and make docs-counts run if a gate count moved (none moved)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

Release Management opened this PR for Jason
Implemented in session Fix big-model load regressions since v0.12.1
Review with Devin · Open in Devin Desktop


devin-ai-integration Bot and others added 6 commits November 19, 2026 06:59
… walk reading it is cut short

Resolving a redefinition target asks for the owning type's loss while that
type's own redefinitions are still unsettled. The whole walk was discarded,
so every supertype's loss was derived again for each redefinition the type
declares. Each type now derives its loss in a lookup frame of its own and is
memoized when no guard cut that derivation short.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Classifying an element concatenated the library prefix and the metaclass name
on every query; the qualified names are now kept per model.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
conforms compared the target against every supertype through SameElement,
which derived the target's element key again for each one.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Redefinition and restriction checks read a feature's isVariable, which derives
isComposite again on every read. The settled answer is now kept per feature.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Adds the changelog fragment for the load-path fixes.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@HuiJun
HuiJun added this pull request to the merge queue Nov 19, 2026
Merged via the queue into develop with commit 699347b Nov 19, 2026
32 checks passed
@HuiJun
HuiJun deleted the perf/big-model-load-regressions branch November 19, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant