Repository navigation
perf(check): keep one declaration per library package name until a second is met - #1746
Merged
Merged
Conversation
…cond is met 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
Loading an empty model into a REPL allocates 2 155 times on the 0.12.0 candidate against 2 022 on 0.11.0's source built with the same toolchain (six rounds; exact). The +6.6 % is #1462's duplicate-library check:
DuplicateLibrarieswalked every library document's root packages and appended each package symbol to a per-name slice, so the ~130 library packages, none of them duplicated, cost a slice allocation (and its growth) each on every load.This PR keeps the check and its findings and changes only what it keeps for the common case: the first declaration of a name is held in a plain map until a second declaration of the same name is met, and only then does the name get a slice (seeded with both) and a place in the report order. The grouping of duplicates by the pair of trees, the used-declaration choice and the warning text are unchanged, as is the walk itself — a document count of root packages still has to be read, so the load does not return to 0.11.0's time.
A/B, six rounds (
go test ./internal/frontend/repl -bench . -benchmem -count 1× 6,benchstat; pre-#1462 / #1462 / candidate1c6bb1972/ this branch; same host, "Intel(R) Xeon(R) Processor", 8 CPUs; bytes and allocations exact)LoadModel/elements=0allocs/opLoadModel/elements=0B/opLoadModel/elements=250,/1000,/4000allocs/op and B/opLoadModel/*live-B/opResidual, stated in the fragment: 2 038 vs 2 022 allocations and 238 vs 228 Ki — the
firstmap and the walk over the library roots are the check's cost. No sec/op claim: a fullgo test ./...gate ran on the host alongside rounds 1–3 and the timing columns carry ±100–300 % spread.Memory acceptance
repl.test -test.bench '^BenchmarkLoadModel/elements=0$' -test.benchtime 200x, candidate and fix built the same way, three cold runs each, interleaved (/usr/bin/time, 8 CPUs):Hard cap: under
ulimit -v 4000000both pass (119 / 118 MiB peak RSS), and underulimit -v 2000000both pass too (117 / 113 MiB) — one earlier attempt of the fix under the 2 GB cap died in the Go runtime's arena reservation before loading anything, at 38 MB RSS, which the same binary did not repeat; that cap sits at the test binary's address-space reservation on either revision. Whole binary,sysml -validateover the 12 086-element generated model, three cold runs: 198 / 198 / 198 MiB candidate, 199 / 189 / 199 MiB fix, 0.24 s both;tests/stressmodelLoad/5121.27–1.36 GiB on both. Resident memory is not what this change recovers: it is 117 allocations and 9 KB per empty load, and the PR does not claim an RSS change.How it was verified
internal/check/workspace(TestDuplicateLibrariesIsQuietWhenNothingIsDeclaredTwice,…ReportsAUserLibraryDeclaredTwice,…ReportsTwoCopiesOfAStandardLibraryFile,…GroupsATreeDeclaredTwice,…SurvivesAnInterfaceRecordReload) pass unchanged — the finding set is the same, only the bookkeeping for single declarations changed.go test ./...below.Gate
(corpora present: training examples, pilot corpora, spec examples, pilot library XMI, PSSM suite, with their
OPENSYSML_REQUIRE_*variables set.)Checklist
go build ./...,go vet ./...,gofmt -l .(empty),go test ./...pass locally (above);make lintnot run (the gate above is the repository's definition of done)changes/unreleased/duplicate-libraries-walk.fixed.mdmake docs-countsrun if a gate count moved — no 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