Repository navigation
perf(runtime): read a declaration's member from its scope's index - #1369
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)".
|
6 tasks done
6 tasks done
4 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
runtime.memberSymbol(scope, node)returned the symbol a scope registered for a declaration by collecting every member of the scope (Scope.AllMembers, which allocates the slice) and scanning it.Scope.MemberDeclaringalready answers the same question — the first registration of the declaration, as the scan found — from the scope's lazily built declaration index without allocating, somemberSymbolnow calls it. Twelve runtime call sites share the helper.The cost became visible when a nested requirement's subject was bound to its enclosing part (#1312):
roleRedefiningDefaultasksmemberSymbolfor every member of every instantiated type, and the 0.11.0 performance measurement ofdevelopagainstv0.10.1hastests/perfInstantiateat 2.51 M → 6.34 M allocations, of which 4.94 M → 6.34 M is that merge; the profile puts 1.81 M of it inmemberSymbol → Scope.AllMembers.Six interleaved rounds on a quiet machine,
develop(5db0f74) | #1368 | this branch | both (benchstat, allocations exact, p = 0.002 on every moved row):tests/perfInstantiatetests/perfBatchSatisfytests/perfFeaturesOftests/stressmodelSatisfy/32tests/stressmodelFleetSatisfy/32tests/stressmodelFleetInstantiate/32v0.10.1:Instantiate2.509 M,BatchSatisfy4.301 M,FeaturesOf4.130 M,Satisfy/3233.4 k — with both fixes thetests/perfrows are at or below the previous release; the stress rows' remainder (+20 %) is #1276/#1319's wider type set, carried in the record as the earlier candidate measured it.How it was verified
TestMemberSymbolReadsTheScopeWithoutCollectingIt(new): the lookup answers the member declared for each of a scope's declarations and allocates nothing; ondevelopit allocates 3 per lookup.go build ./...,go vet ./...,gofmt -l .clean;go testofinternal/exec/...,internal/frontend/repl,internal/frontend/grpc,tests/modelgreen (the twointernal/exec/solvecorpus tests that need the downloaded training corpus fail identically on baredevelopin this checkout).Checklist
make testandmake lintpass locally (the packages above; full suite in CI)changes/unreleased/member-symbol-by-decl.fixed.mdmake docs-countsrun if a gate count moved (none moved)Link 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