Skip to content

Reduce allocation in graph snapshots and schema generation - #4

Merged
Frotty merged 1 commit into
masterfrom
codex/repository-performance
Dec 1, 2026
Merged

Frotty merged 1 commit into
masterfrom
codex/repository-performance

Conversation

@Frotty

@Frotty Frotty commented Dec 1, 2026

Copy link
Copy Markdown
Member

Changes

  • Read owned children and metadata through generated slot walks during graph inspection. Ownership discovery, snapshot metadata scanning, sorted metadata validation, and mutation scopes no longer build and discard detached codec records.
  • Validate the materialized ownership tree once. Compute metadata dependency order once per immutable snapshot using primitive arrays, and reuse it for materialization and hashing. This retains four bytes per encoded value in each snapshot.
  • Start the per-owner tracked metadata scratch maps small. They still grow for large imports.
  • Remove the generator's unused containment closure and its reverse index. The reachability walk that determines revision propagation remains in use.

Measurements

The base was c7defa5. Three alternating pairs of fresh Temurin 25.0.4.1 JVMs ran on Windows on a Ryzen 5 7600, with -Xms1g -Xmx1g -XX:+UseParallelGC -XX:ActiveProcessorCount=6. The table shows the range of per-process wall-clock medians and main-thread allocations per operation. Timings came from runs without JFR enabled.

Workload Median time range, baseline → candidate Allocated MiB/op, baseline → candidate
Seeded AST snapshot round trip, 207,850 nodes 163–397 → 101–236 ms 219.9 → 80.1–81.9
Seeded AST snapshot round trip, 3,053 nodes 3.08–4.61 → 2.33–2.54 ms 3.32 → 1.28–1.29
Tracked metadata snapshot round trip, 12,002 nodes with references and an alias 20–28 → 17–42 ms 56.7 → 35.8–36.2
Warm generator CLI on the 1,089-line WurstScript schema 1,549–2,130 → 1,806–1,909 ms 72.1–72.6 → 56.7–56.8

The large AST JFR run collected 2,325 main-thread execution and native samples on the baseline and 992 on the candidate for the same operation count. Samples in codec encoding fell from 1,288 to 209. Ownership validation alone fell from 33.6 to 10.7 MiB per pass. The isolated 12,000-container single-owner import continued to allocate 3.39 MiB and had overlapping wall-clock ranges.

End-to-end wall time varied with the host. The metadata-heavy round trip showed a repeatable reduction in allocation. Its wall time varied enough that these runs do not establish a latency gain. Most CLI samples remained in file I/O, and CLI elapsed time showed no repeatable improvement. Whole-compiler speed was outside the measured workload.

To reproduce, compile the test classes and run test.bench.ArtifactPipelineBench with the test runtime classpath. Use ast pipeline 2500 24, ast pipeline 30 35, metadata pipeline 12000 30, or schema wurstscript.parseq output-directory 10. The WurstScript input used here has SHA-256 e0475d56dcd5892fde5299d499f1109db1e05a19f70a0e880cf2e2561c18706c. Graph runs check the round trip, including metadata aliases, before timing.

Behavior checks

  • 174 tests passed on Java 25 and 27, including the owned-child/reference-list regression, graph identity and aliasing, metadata cycles, sorted-key validation, deep traversal, revision reset, detached codecs, and ownership scopes. The WurstScript generator emitted the same 328 Java filenames on both revisions.
  • This PR targets master independently. A trial merge with Fix repository-wide generator and generated AST defects #3 reported overlapping edits; whichever PR lands second will need reconciliation.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T18:52:17.149023Z a3f0995 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Frotty
Frotty merged commit 18c78b9 into master Dec 1, 2026
2 checks passed
@Frotty
Frotty deleted the codex/repository-performance branch December 1, 2026 20:19
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