Repository navigation
perf(check): sweep a document's expressions for typed by only while one is unreported - #1744
Merged
Merged
Conversation
…ne is unreported 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)".
|
tryParseCrossFeature reads an end's typing before the end's own declaration does, so a count the checkpoint did not hold was one too high, and the notation pass swept the document's expressions for a typing it had already reported. Co-Authored-By: jason.han <hanhuijun@gmail.com>
A snapshot written before RootNamespace.TypedBy was encoded passed the version and digest checks and would have decoded the field from the next one's bytes; format 27 refuses it. Co-Authored-By: jason.han <hanhuijun@gmail.com>
3 of 6 tasks
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
Cause: #1478 (
typed byon body-expression parameters). ItsNonstandardNotationPasssweep,typedByInExpressions, walks every expression of every document on every load to find atyped byspelled on a body-expression parameter, allocating a walker frame per expression whether or not the document spells one — and SysML documents almost never do. That is the +4.7 % B/op on every load-heavy row of the 0.12.0 candidate (LoadModel/250…4000,AnalyseResolved), bisected to #1478.This PR has the parser count the
typed byspellings of a document (RootNamespace.TypedBy, incremented inParser.typedBySpan, the one place the keyword is accepted), and the pass runs the expression sweep only while the member walk has reported fewer than that. The count is syntax, so it lives on the AST root likeUndefinedOperatorsand is carried throughastcodec;snapshotFormatVersionmoves to 27 so a snapshot written without the field is refused rather than decoded shifted, andstdlib.snapshotis regenerated. A speculative parse (tryParseCrossFeaturereading an end's typing before the end does) holds and restores the count with its checkpoint, so an end without a cross feature is counted once. The finding itself is unchanged: a document that spellstyped byin a body expression is still swept and still reported (internal/check/passestests pass unchanged;TestRootNamespaceCountsTypedBypins the count on declarations, prefix metadata and body-expression parameters).How it was verified
A/B, six rounds, same host (Intel(R) Xeon(R) Processor, 8 CPUs),
benchstatColumns: #1478's parent / #1478 / the 0.12.0 candidate (
1c6bb1972) / this branch. Bytes and allocations are exact; the host is shared with the benchmark queue, so no sec/op claim is made.internal/frontend/replLoadModel/250B/opLoadModel/1000B/opLoadModel/4000B/opLoadModel/1000B/elementLoadModel/0B/opLoadModel/*allocs/opLoadModel/*live-B/opinternal/workspace/modelAnalyseResolvedB/opAnalyseUnresolvedB/opResidual, stated in the fragment:
LoadModel/1000allocates 58.5 MB per load instead of 61.2 MB, against 58.2 MB on 0.11.0's source with the same toolchain; the 0.3 MB left (+0.5 %) is other merges' work, not #1478's. The other load-heavy rows the release record lists under #1478 (tests/stressmodelLoad/LoadFiles/OpenSplit/ValidateSplit/EditImported,ImportValues,WorkspaceEdit,REPLSubmitSnippet) run the same pass per document and are expected to move alike; they were not re-measured for this PR and are not claimed here.Memory acceptance (
repl.test -bench 'LoadModel/elements=1000$' -benchtime 20x, three cold runs each, candidate / fix)ulimit -v 4000000Peak RSS does not move: the sweep's garbage was short-lived, so this fix recovers allocation volume (GC work), not resident memory — the record says the same.
Gate
On cd077d9 (the head, with the checkpoint restore and snapshot format 27); the A/B above is from 755faab, whose only difference is those two review fixes, neither on a benchmarked path.
python3 scripts/changelog.py checkpasses withchanges/unreleased/typed-by-sweep.fixed.md.Checklist
go build ./...,go vet ./...,gofmt -l .(empty) andgo test ./...pass locally (above);make lintisgofmt+go vetTestRootNamespaceCountsTypedBy)changes/unreleased/typed-by-sweep.fixed.mdstdlib.snapshotregenerated for the newRootNamespace.TypedByfieldLink 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