Skip to content

perf(metamodel): memoize owned features and supertypes in the direction walk - #2377

Merged
1 commit merged into
developfrom
perf/memoize-owned-features-direction-walk
Nov 19, 2026
Merged

1 commit merged into
developfrom
perf/memoize-owned-features-direction-walk

Conversation

@HuiJun

@HuiJun HuiJun commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

#2251 made the effective direction of a port feature walk the owner's inheritance path (structureDirectionThrough → structureGeneralWithFeature / structureHasFeature). Each step recomputed Type::ownedFeature (structureOwnedFeatures) and the owned supertypes (structureOwnedSupertypes) of the type it visited, once per feature, which roughly doubled the api-json export: TestSymbolStructureMatchesGraphStructure went from 879 s to 2123 s in the merge queue and the translate race shard from 16.2 to 42.6 min, close to its 55 min go test timeout.

This change keeps the walk as it is and removes the repeated work:

  • structureOwnedFeatures is derived once per element through the evaluator memo (new memoOwnedFeatures kind).
  • structureOwnedSupertypes is derived once per element through memoizedValueList.
  • structureDirectionThrough asks whether the owner owns the feature only for a PortUsage, the one case that reads the answer.

No result changes: the computations are the same functions, now behind the memo the neighbouring derivations already use.

How it was verified

  • CPU profile of TestSymbolStructureMatchesGraphStructure on the fix(symbol): report a member's direction relative to the type it is read through #2251 head: structureDirectionThrough is 14.0 s cumulative of a 22 s run over examples/sysml-v2-training, almost all in the two recomputed derivations.

  • Same test, same corpus subset, no race detector, local 8-core machine:

    build time
    parent of fix(symbol): report a member's direction relative to the type it is read through #2251 9.9 s
    develop 23.1 s
    this branch 11.7 s
  • OPENSYSML_STRUCTURE_DIFFERENTIAL_DUMP from the three builds is identical once sorted (the dump order follows the parallel walk).

  • gofmt -l ., go vet ./..., go build ./..., make lint, go test -count=1 ./tests/hygiene and go test -count=1 ./... pass locally.

  • CI timings of the translate shard on this pull request and in the merge queue to follow in a comment.

Checklist

  • make test and make lint pass locally (go test ./... without -race locally; the race tier runs in the queue)
  • Tests added or updated for the change (none: behaviour is unchanged and covered by the structure differential)
  • Documentation extended where it already covers the surface (see CONTRIBUTING.md)
  • Changelog entry added as changes/unreleased/<slug>.<section>.md, not as an edit to CHANGELOG.md
  • baselines regenerated and make docs-counts run if a gate count moved (none moved)
  • No internal work-item labels (waves, slices, F4, K5) in the body, docs, or changelog

Continous Integration Deployment opened this PR for Jason
Implemented in session Speed up inheritance walk from conjugated port change
Review with Devin · Open in Devin Desktop


…on walk

The effective-direction walk for port features recomputed Type::ownedFeature
and the owned supertypes of every type on the inheritance path, per feature.
Both are now derived once per element through the evaluator memo, and the
owned-feature test runs only for port usages, which alone read it.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

CI timings, quick tier (Go tests (cli translate), no race detector), from the job logs:

run TestSymbolStructureMatchesGraphStructure internal/translate/export
before #2251 (runs 44306129138, 44294584002) 83.6 s, 75.5 s 104.7 s, 95.6 s
with #2251 (runs 44389135423, 44373118990, 44369388026) 287.8 s, 233.9 s, 339.1 s 318.0 s, 260.5 s, 377.2 s
this pull request (run of 1236e9f) 109.2 s 130.6 s

The race-tier figures (translate shard, 16.2 min before and 42.6 min with #2251) can only be re-measured once this is in the merge queue. What remains above the pre-#2251 time is the inheritance walk itself, which #2251 added for correctness.

devin-ai-integration Bot added a commit that referenced this pull request Nov 18, 2026
…pertype memos of #2377

Merges perf/memoize-owned-features-direction-walk and drops this branch's own
memos of structureOwnedFeatures and structureOwnedSupertypes in favour of the
ones that branch carries; the general-type and feature-direction memos stay.

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@HuiJun
HuiJun added this pull request to the merge queue Nov 19, 2026
@HuiJun
HuiJun removed this pull request from the merge queue due to a manual request Nov 19, 2026
@github-merge-queue github-merge-queue Bot closed this pull request by merging all changes into develop in 17df973 Nov 19, 2026
@devin-ai-integration
devin-ai-integration Bot deleted the perf/memoize-owned-features-direction-walk branch November 20, 2026 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant