Repository navigation
perf(runtime): allocate in the binding walks only where a binding can be found - #1742
Merged
Merged
Conversation
… be found Co-Authored-By: jason.han <hanhuijun@gmail.com>
…agment 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)".
|
…k requires Co-Authored-By: jason.han <hanhuijun@gmail.com>
Merged
5 of 6 tasks
2 of 6 tasks
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
#1508 (
resolveBindingsclimbing a feature read to its owners) and #1512 (bindingWitnesses,siblingSubsetterValues) made the runtime's binding walks correct for owner-declared and sibling bindings, and paid for it on every read whether or not a binding exists: the owner walk spelled outownerFeature + "." + pathat each level, the witness draw built its pool index (witnessDraw+inPoolmap) before looking at a candidate, the sibling set allocated itstakenmap before the first value, andunwrappedDeclMemberslisted a body's members into a fresh slice each time a body was scanned for a declared feature. In the 0.12.0 candidate that isGRPCVerifyConstraintat 16 301 allocations per constraint against 0.11.0's 14 091 (source rebuilt with the same go1.27.3), and it reachesInstantiate,BatchSatisfyandFeaturesOf.This branch allocates in those walks only where a binding can be found: the owner walk builds the path only while an owner's types declare a binding (
ownersDeclareBindings), the witness draw lives on the stack and indexes its pool on the first candidate (admitsPooled),takenis made on the first sibling value, and bodies are scanned with an iterator (eachUnwrappedDeclMember) instead of a member list. Nothing the walks find changes; the conformance, robustness and gRPC suites are the proof.Fragment:
changes/unreleased/binding-walk-allocs.fixed.md.How it was verified
A/B, six rounds,
benchstat.Revisions:
pre1508= develop before #1508,m1508= the #1508 merge,m1512= the #1512 merge,dev= the 0.12.0 candidate (1c6bb1972),fix1= this branch on it. Interleaved rounds on one host ("Intel(R) Xeon(R) Processor", 8 CPUs),GOMAXPROCS=8; bytes and allocations are exact, sec/op below is from a machine that was also running the release suite and is reported only where it is flat.Candidate → this branch:
GRPCVerifyConstraint16 301 → 14 887 allocations (−8.7 %) and 834 KiB → 785 KiB per constraint;BatchSatisfy−6.5 % allocations, −2.0 % bytes;Instantiate−12.1 % allocations, −4.0 % bytes;FeaturesOf−3.7 % allocations, −2.0 % bytes. The other rows oftests/perf,internal/exec/runtimeand thetests/stressmodelconstellation (Satisfy,FleetInstantiate,FleetSatisfyat 32/128/512 satellites) are unchanged within noise (FleetInstantiateallocations −0.03…−0.13 %, p=0.002).AssignmentLoopStepis not moved by this branch (its bytes are #1514/#1461, their own PR). The warm gRPC rowInstantiateWarmModel(tests/grpc) is below.Residuals, stated plainly:
GRPCVerifyConstraintstays 796 allocations per constraint above 0.11.0 (14 887 vs 14 091) — those are the owner and sibling reads #1508/#1512 make correctly and this PR keeps; theBatchSatisfybytes still +4.5 % over pre-#1508 andFeaturesOf+10.5 % are #1626's subsetting memo, addressed inperf/related-features-memo. No sec/op claim is made here: on this loaded hostGRPCVerifyConstraintsec/op is flat between the candidate and this branch (1.66 vs 1.68 ms); the −35 % frompre1508todevlanded elsewhere in develop. TheInstantiateB/op spread (±30–45 % on the older revisions) is the harness's cold first iteration, the same on every revision; the allocation count is the comparable figure.internal/frontend/grpc, six rounds dev vs fix1 (same host, quiet apart from one A/B):InstantiateWarmModel2 155 → 1 996 allocations per instantiation (−7.4 %) and 125.5 → 117.9 KiB; 0.11.0 rebuilt with go1.27.3 is 1 962, so 34 remain — the attribution of that row to the binding walks is confirmed.Definition of done on this branch:
(The long
cmd/sysml/smttimes are the host running a benchmark A/B alongside; the default 10 m per-package timeout is why-timeout 45m.)Checklist
make testandmake lintpass locally (go build,go vet,gofmt -l,go test -timeout 45m ./...above)changes/unreleased/binding-walk-allocs.fixed.mdmake docs-countsrun if a gate count moved — no gate count movedLink to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/15408827f8104c7fbbdbd1b2c852ed2c
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/15408827f8104c7fbbdbd1b2c852ed2c?variant=devin
Requested by: @HuiJun