Repository navigation
perf(semantics): read a library symbol's implied generals from its record - #1357
Merged
Merged
Conversation
…cord A library symbol's implied generals were derived again by every model that queried them, since the memo is per model and the runtime builds one per execution; its record now carries them (base definition and base usage) and ImplicitGenerals answers from it, as DirectSupertypes does. 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)".
|
Recorded over the tree where usages subset the base usage of their kind: one rejection case gains a connector-ends error, every bucket keeps its verdict; the api-json figures are unchanged. Co-Authored-By: jason.han <hanhuijun@gmail.com>
Co-Authored-By: jason.han <hanhuijun@gmail.com>
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
Develop's CircleCI race and coverage jobs exceed their 30-minute package budget in
internal/exec/runtimeandcmd/sysmlsince d8b60ed (usages subset the base usage of their kind):go test ./cmd/sysml -run TestExploreTablesTheSpacecraftRaceWithinItsBudgetwent from 155 s to 211 s on one machine. #1350 memoizedModel.ImplicitGeneralsper symbol, which brought that test back to 158 s on develop; what remained is that the memo is per model, and the runtime builds a model per execution, so a library symbol's implied generals were derived again —candidateBaseFeatures,declaredGeneralizationReachesover the library — by every model that asked (statedTypes/effectiveTypesthroughDeclaredSupertypes). On theinternal/exec/runtimesuite that derivation was 11.7 s of 415 s of CPU (ImplicitGenerals12.2 s cumulative), withunitConversion,isBoundandlongNamederived thousands of times each.A library symbol's facts already record its direct supertypes; they now record its implied generals too, and
ImplicitGeneralsanswers from the record wheneverDirectSupertypesdoes, memoizing the answer like the derived one:LibraryFacts.ImpliedSuperslists every general the kind implies — the base definition (Parts::Part) as well as the base usage (Parts::parts) — in derivation order; it listed the base usages only, so answering from it lost the implied typing (the reasonImplicitGeneralsread facts forRecorded()symbols alone).factRecord.Implied,impliedOf) carries the same entries, since the loader installs those facts before the interface records are written; a record whose implied general no reference reaches leaves the whole edge set to be derived on load, as a supertype does.internal/workspace/libs/stdlib.snapshotregenerated (go generate ./internal/workspace/libswith a freshXDG_CACHE_HOME; a stale cache record would have been read back as the fact).No behaviour change: the same generals in the same order, read instead of derived.
Baseline movement (re-recorded over develop with usages subsetting their base usage)
docs/project/pilot-rejection-baseline.json(go run -C tools ./cmd/pilot-reject -update): 334 cases, 323 both reject, 11 only we reject, 0 only the pilot rejects, 0 both accept — every bucket keeps its verdict. One row moves:semantic/k49-binding-connector-with-three-ends.kermlours-errors 2 → 3, the new oneconnector-ends("b has 3 ends but specializes a binary link (Links::BinaryLink)"): the connector now conforms toLinks::binaryLinks, so the end-count rule of KerML 1.1 §8.3.4.5.3 fires besidebinding-binary; the pilot rejects it as before.docs/project/api-json-differential-baseline.json(go run -C tools ./cmd/pilot-apijson-diff -update, all nine roots provisioned): headline unchanged — 920 files, 86974 matched, 29497 ours-only, 40387 pilot-only, 596664 present-equal, 47633 present-different, 1021444 ours-missing, 65920 pilot-missing, 2020649 absent-both, 20867 indeterminate — sodocs/project/api-json-differential.mddoes not move; withinspec-examplesone element changes bucket to a type mismatch (typeMismatch390 → 391, total 1742 → 1743) andextensionProperties140676 → 140679.make docs-countsreports every figure current.How it was verified
Failing-before test
TestLibraryImpliedGeneralsAreRecordedWithTheDefinition(internal/workspace/model): a library usage's record carries an implied definition,ImplicitGeneralsmatches the record, a repeated query allocates 0 times and a fresh model answers the same — fails on d8b60ed (no definition recorded), passes here.TestEveryPersistedFactFamilyIsComparednow compares the new family.Timings on this machine (
go test -count=1, same VM, runs sequential; "before" b60a18c, "after" d8b60ed, "develop" 5b0c985 = develop with fix(semantics): derive a declaration's implied generals once per symbol #1350, "fix" this branch):cmd/sysml -run TestExploreTablesTheSpacecraftRaceWithinItsBudgetinternal/exec/runtime(whole package, no race)CPU profile of
TestExecutionConformance:ImplicitGenerals0.63 s /computeImplicitGenerals0.54 s of 52 s sampled (develop: 12.2 s / 11.7 s of 415 s on the whole package); what remains understatedTypesisdeclaredTypesresolution, which perf(runtime): compute a feature's effective types once per model #1351 memoizes.gofmt -l .empty,go build ./...,go vet,go testofinternal/semantic/...,internal/workspace/...,internal/check/...,internal/exec/runtime,cmd/sysml;python3 scripts/changelog.py check. Full gate on the branch:go build ./...,go vet ./...,gofmt -l .empty,go test -timeout 60m ./...(every corpus provisioned) exit 0,go test -C tools ./...exit 0,make lintpassed.Checklist
make testandmake lintpass locallychanges/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (compliance rows need nothing: the census is counted at docs build)F4,K5) in the body, docs, or changelogLink to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/7cd14420fabe46389e22657ea286e92d
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/7cd14420fabe46389e22657ea286e92d?variant=devin
Requested by: @HuiJun