Skip to content

research: an opt-in ledger keeps every native pass a thread makes, with the line that asked for it, and probe_pass_ledger lists a default export's - #1837

Merged
DrunkOnJava merged 3 commits into
mainfrom
research/pass-ledger
Nov 12, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
research/pass-ledger

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

This adds an opt-in ledger of native passes, and a standing probe that prints it after a default export.

native_document::record_passes() starts keeping one PassEntry for each of:

  • every extract and extract_graphs walk this thread makes;
  • every use of the handle's parameter-definitions pass: made, held, replaced by another key's, or dropped.

Each entry carries:

  • the caller's file and line, from #[track_caller], so no call site changes;
  • the value source, the channels, the size and a fingerprint of the selection, and whether the walk was uncached;
  • the partitions walked, the bytes inflated, the records emitted and the time.

take_passes() returns the entries and stops keeping them. probe_pass_ledger prints each pass, then the totals, every selection read more than once (with its callers), and any definitions pass made again after the export dropped it.

Motivation

This came from an advisor review of where time spent now keeps paying off. Three of 11-12's pull requests each wrote a counter of their own to prove a fold (walk_inflated_bytes for #1694, read_counts for #1816, wall_read_passes for #1824). #1816's first Measure failed because a memo was dropped before its reader. The ledger shows that directly as remade ... after dropped at ..., and it shows the next fold's target as a repeated selection, without a counter written for it.

Changes

  • src/research/native_document.rs:
    • PassEntry, record_passes and take_passes, and a thread-local that holds nothing until a probe turns it on;
    • extract, extract_graphs and definition_captions are #[track_caller];
    • the definitions pass notes held, replaced and made.
  • src/reader.rs: forget_native_definitions notes a dropped pass, and holds_native_definitions says whether one is held.
  • probes/examples/probe_pass_ledger.rs and changelog.d/research/pass-ledger.md.

Testing

Unit tests are banned here. Measure 43307975040 runs 75613fd0 against its merge-base with main, 1a9aacc7. It covers the samples of every year, the BIM4LCA models, the R2025 set, rac_advanced and the held-out models, with the probe on each. Rows, registered before the run:

  1. Exports unchanged. Every ifc.sha256 and diagnostics.json equals the base's. With the ledger off, as in every export, a pass checks one thread-local and does nothing else.
  2. The ledger sees the export.

Read. Both rows hold.

  1. 125 of 125 ifc.sha256 and 101 of 101 diagnostics.json equal the base's, and no scorer output moved.
  2. All 202 probe outputs exit with the summary and list at least one walk.

Merge of main (dbff466f). #1821 split the pass's key into definition_key and added held_definition_units. definition_pass keeps the caller argument beside the new key function. A units read that the held pass answers is noted as definitions held, so once #1821 is in, the ledger shows that read in place of the walk above. With the ledger off, the merge's only change to the code above is #1821's, which main measured. No new Measure.

rustfmt --check passes. CI runs clippy, the MSRV check and the docs.

Breaking changes

None. The new items are under rvt::research, which is unstable-research.

…th the line that asked for it, and probe_pass_ledger lists a default export's
…'s time once (#1694)

The extract's clock started before the definitions pass, so when the
pass made them, its walk's time was in both "definitions made" and
"extract", and the probe's total counted it twice. The clock now starts
after the definitions.
#1821 split the definitions pass's key into definition_key and added held_definition_units. definition_pass keeps the ledger's caller argument beside the new key function, and a units read that the held pass answers is noted as 'definitions held', so the ledger still names every reader of the definitions.
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 12, 2026 22:32
@DrunkOnJava
DrunkOnJava merged commit 622deb3 into main Nov 12, 2026
64 checks passed
@DrunkOnJava
DrunkOnJava deleted the research/pass-ledger branch November 12, 2026 23:30
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