Repository navigation
perf(runtime): memoize related features only for features that declare the relationship - #1743
Merged
Merged
Conversation
…e the relationship Co-Authored-By: jason.han <hanhuijun@gmail.com>
…k requires 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)".
|
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
Part of the 0.12.0 performance gate (record: #1740). #1626 memoized, per
(feature, owner type, relationship kind), the features a feature's relationships name, so that a repeated read allocates nothing. The memo's key, map growth and the clipped empty slice were paid for every feature the walk asked about — and most features declare no subsetting, redefinition or reference of the kind asked for. Those entries were the majority of the map and grew with every type an instantiation touched:FeaturesOfwent from 267 MiB to 296 MiB per run and a coldInstantiatefrom 221 MB to 252 MB (column 2 → column 3 of the record, same toolchain).relatedFeaturesnow returnsnilbefore touching the memo whenrelationshipsOfKind(sym, kind)is empty (that lookup is itself memoized by #1626 and is what the collect loop iterates). The result is the same value the memo would have stored (slices.Clipof a nil slice), so the walks that do relate stay memoized and repeated reads still allocate nothing.Residual, stated in the fragment:
FeaturesOfallocates 285 MB per run instead of 310 MB (0.11.0 on the same toolchain: 273 MB),BatchSatisfy476 MiB instead of 491 MiB (0.11.0: 461 MiB), a coldInstantiate230 MB instead of 252 MB (0.11.0: 221 MB). The rest is the memo that pays for itself (allocation counts on these rows are 4–8 % below 0.11.0 because of it) — no parity claim. Allocation counts are unchanged by this PR;GRPCVerifyConstraintis unchanged (it is the subject of #1742).How it was verified
Six interleaved rounds of
go test ./tests/perf -run '^$' -bench . -benchmemon the merge before #1626, #1626 itself, the 0.12.0 candidate (1c6bb1972) and this branch;benchstat, 8 CPUs,Intel(R) Xeon(R) Processor,GOMAXPROCS=8. Bytes/allocs are exact; this host is loaded, so no sec/op claim is made except where the fix's own spread is tight.FeaturesOfBatchSatisfyInstantiate(cold, pinned-benchtime 2x, 3 runs each)Instantiate(suite, b.N-dependent)ExecuteActionFreshContextGRPCVerifyConstraintallocs/op:
FeaturesOf2.186M → 2.185M,BatchSatisfy4.078M → 4.078M,Instantiate2.011M → 2.010M,GRPCVerifyConstraint16.30k → 16.30k (all unchanged).FeaturesOfsec/op 641.8m ± 310 % → 598.6m ± 2 % (−6.7 %, p=0.002); every othertests/perfrow~.tests/stressmodel(Load|Satisfy|FleetInstantiate|FleetSatisfy, six rounds, candidate vs this PR): every row~on sec/op, B/op and allocs/op (FleetInstantiate/512B/op 176.1Mi ± 8 % vs 181.3Mi ± 5 %, p=0.13; allocs identical).Memory acceptance (
/usr/bin/time -v, thetests/perftest binary runningFeaturesOf+Instantiate, candidate vs this PR, 3 cold runs each): peak RSS 336 340 / 336 784 / 334 840 KiB → 317 904 / 317 624 / 319 820 KiB (−17 MiB), wall 1.85 / 1.84 / 1.84 s → 1.75 / 1.79 / 1.75 s. Under a hard capulimit -v 4000000: candidate 335 140 KiB, this PR 316 956 KiB, both rc=0 (a Go test binary's address-space reservation is what sets the lowest cap it tolerates, so the cap is on virtual size, not RSS).tests/stressmodelFleetInstantiate/512binary, 3 cold runs: 192 720 / 187 180 / 187 744 KiB → 196 488 / 198 632 / 197 888 KiB (+2–5 %, within that row's B/op spread above; its allocation count is identical) — recorded, not claimed either way.Gate (this branch, corpora present —
OPENSYSML_REQUIRE_PSSM_SUITE/PILOT_LIBRARY_XMIassets fetched with their scripts;-timeout 45mbecause the full suite ran beside the benchmark queue):Checklist
make testandmake lintpass locally (go build ./...,go vet ./...,gofmt -l .empty,go test ./...above)internal/exec/runtimesubsetting/redefinition tests andTestExecutionConformancechanges/unreleased/related-features-memo.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