Repository navigation
perf(runtime): compute a feature's effective types once per model - #1351
Merged
Merged
Conversation
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
4 of 6 tasks
This was referenced Oct 21, 2026
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
Since #1276 (an object is typed by every type its feature inherits through subsetting),
Context.effectiveTypesis asked for the same feature symbol on every object made as that feature:extractType,directTypes,conjoinedTypesandwithConjoinedTypeseach call it, and each call re-resolved the feature's typing relationships (declaredTypes→RelationshipsOf→resolveQualified), re-ranFeatureTypeSetover the subsetted features and rebuilt the conjunction. In the 0.11.0 release-gate measurement this was the largest avoidable part of thetests/stressmodelSatisfy/FleetSatisfyandtests/perfInstantiate/FeaturesOf/BatchSatisfyallocation growth: a 300-iteration allocation profile ofSatisfy/satellites=32at #1276's merge commit puts 2.1M of the 2.4M new allocations underdeclaredTypes/statedTypesand theslices.CloneineffectiveTypes.effectiveTypesis now memoized per feature symbol on the runtimeModel, beside its other per-symbol tables (features,chainHosts,denotedFeatures); the computation moved unchanged tocomputeEffectiveTypes. The memoized slice is shared, soconjoinedTypesclones beforeslices.DeleteFunc(the other callers only read). No behaviour changes: the same types in the same order for every call.How it was verified
Failing-before differential test
TestEffectiveTypesAreComputedOncePerFeature(internal/exec/runtime/effective_types_memo_test.go): a repeatedeffectiveTypesquery fortest::Rig::frontallocates 755 times on develop d8b60ed and 0 with this change.Six interleaved rounds, benchstat, same machine (Intel Xeon, 8 vCPU, Go 1.25.11); pre-fix(runtime): type an object by every type its feature inherits through subsetting #1276 bb293df | develop d8b60ed + fix(semantics): derive a declaration's implied generals once per symbol #1350 | this change + fix(semantics): derive a declaration's implied generals once per symbol #1350. Allocations and bytes are exact (±0%, p=0.002 throughout); sec/op was taken on a loaded machine (the release-gate run was sharing it) and is not reported here.
tests/perfInstantiateallocs/optests/perfFeaturesOfallocs/optests/perfBatchSatisfyallocs/optests/perfInstantiateB/optests/stressmodelSatisfy/satellites=32/assertions=96allocs/optests/stressmodelFleetSatisfy/satellites=32/assertions=24allocs/optests/stressmodelFleetInstantiate/satellites=32/elements=1179allocs/optests/stressmodelSatisfy/satellites=32/assertions=96B/opThe residual over pre-fix(runtime): type an object by every type its feature inherits through subsetting #1276 is the inherent cost of fix(runtime): type an object by every type its feature inherits through subsetting #1276 and feat(semantics): usages subset the base library usage of their kind #1319 (
FeatureTypeSetover the subsetted features, the w9c inherited-name check over the wider type set), measured and attributed in the 0.11.0 performance record (docs(perf): measure the 0.11.0 candidate against 0.10.1 #1337).go build ./...,go vet ./...,gofmt -l .empty,go test ./internal/exec/runtime(219 s, all pass),python3 scripts/changelog.py check.Checklist
make testandmake lintpass locally (runtime package run locally; the full suite runs in CI)changes/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (no gate count moved)F4,K5) in the body, docs, or changelogLink to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/cf22d7a746814d20b2f0eaf11682fef9
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/cf22d7a746814d20b2f0eaf11682fef9?variant=devin
Requested by: @HuiJun