Repository navigation
perf(semantics): bring big-model load back toward 0.12.1 - #2399
Merged
Merged
Conversation
… 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>
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Loading a large model regressed against v0.12.1 in time and allocations (
BenchmarkLoad,BenchmarkLoadFiles,BenchmarkAnalyze/synthetic). Profiles ofLoadFiles/satellites=128put the cost in four places on the semantic load path, each fixed here without changing a diagnostic:inheritanceLosswhile that type's own redefinitions are unsettled, and the whole walk was discarded, supertypes included.walkInheritanceLossnow 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.sysmlMetaclass,kermlMetaclass). They are kept per model.conformsderived the target's element key once per supertype throughSameElement. It is derived once per query.EffectiveIsCompositewas derived on every read of a feature'sisVariable, 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/hygieneandgo test -timeout 60m ./...pass locally on this head (the full suite after regenerating the git-ignoredstdlib.snapshot).TestSupertypeLossStaysMemoizedWhenTheSubtypeWalkIsCutShort(fails without the fix) andTestEffectiveIsCompositeMemoFollowsTheDeclaringDocument.Benchmarks: v0.12.1 against
developwith #2378, #2379 and #2380 merged, and against the same tree with this branch merged; Go 1.27.4, 8 cores, six interleaved rounds (-benchtime 3xfor load,5xfor analyze), three rounds ofConvertAPIJSONat1x.Against
developwith the queued fixes, load time falls 17–20% (p=0.002) and load allocations 22–23%.Known caveats
LoadFilesis still 9–10% slower than v0.12.1 and allocates 8% more bytes;Loadis within noise of v0.12.1.Analyze/syntheticis still +12% time and +6% allocations; the time difference fromdevelopis not significant at six rounds on this machine (±12–15%).ConvertAPIJSON/satellites=128is 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 testandmake lintpass locally (go test ./...without the race detector, andmake lint)changes/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (none moved)F4,K5) in the body, docs, or changelogImplemented in session Fix big-model load regressions since v0.12.1
Review with Devin · Open in Devin Desktop