Skip to content

perf(reader): the definitions pass, the wall records read and the catalog's document build only the fields they read; the preamble does less (#1335) - #1483

Merged
DrunkOnJava merged 12 commits into
mainfrom
perf/1335-definitions-projected
Nov 6, 2026
Merged

DrunkOnJava merged 12 commits into
mainfrom
perf/1335-definitions-projected

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

One mechanism, three cuts, for #1335: a native pass that reads a few fields of a graph now reads and checks the whole graph exactly as before and builds only the fields it reads (native_parameters::decode_graph_projected, Options::graph_fields). It is used by the parameter definitions pass (its Family and FamilySymbol records), the read of the wall records (SWall and ArcWall) and the extensible storage catalog's document; the preamble's element index and checksum hex also do less work. Folded from #1483, #1485 and #1488; the phase read (#1487) is not changed and is recorded below as a measured floor.

Measured at 4140b96 (main merged at df96767). The pushed head, 1811752, merges main at 8060ecc cleanly: no conflict in the files this changes, and #1470's additions to native_walls.rs are in native_walls_and_top_joins_into, which reads in full, not in WallReads::read.

  • Peak memory falls on 58 of 68 files, is equal on 6 and rises on 4 (by 1, 1, 1 and 8 MiB). The catalog's document, built whole, was the peak of many files: 2024 Snowdon Towers HVAC 398 to 214 MiB (0.54), Einhoven 37 to 30, 2015 to 2019 rst_basic 91 to 94 down to 79 to 80, Core Interior 324 to 310, RE1 Plumbing 73 to 67, Snowdon Towers plumbing 513 to 462. The four rises: 2026 racbasicsampleproject 225 to 233 MiB (1.03), and RE1 Electrical, 2015 rac_advanced and the BIM4LCA office at building permit by 1 MiB each. Why the 8 MiB is not measured.
  • Time against main (the same unfiltered run, paired on one runner per shard, median of three): 0.867 on the 2015 samples, 0.878 on 2016 to 2018, 0.862 on 2019 to 2022, 0.903 on 2023, 0.968 on 2024 to 2027, 0.972 on the reference models and offices; 0.947 over the 58 samples (mean of the per-file ratios 0.914, median 0.901) and 0.953 over all 68 files. The table is below.
  • Against 0.11.0 and 0.15.0 (same-runner timing runs, 2015 to 2023 samples and the six reference models): 1.175 of 0.11.0's time over the 33 samples (mean of per-file ratios 1.199, median 1.254; 2015 to 2022 about 1.2, 2023 0.894, reference models 0.772) and 0.884 of 0.15.0's (mean 0.890, median 0.894). Tables below.
  • No export moves: ifc.sha256 equal on all 111 exports of the unfiltered run, diagnostics.json equal on the 93 that upload one, and the 18 held-out models' counts.txt and ifc.sha256 equal; of the 2,251 result files common to the two sides, 2,233 are byte-identical and the 18 that differ are the runs' own commit.txt, runner-*.txt, vmstat-*.log and score-cache-*.log. The semantic check says "no semantic difference in 34 models".

Motivation

#1335: the definitions pass is FamilySymbol 207 ms decode + 110 ms freeing, Family 28 + 8, of its 403 ms on 2015 rac_advanced (profile run 42111526405, scratch head cc7f9c1, one loaded runner; shares only). Over the 33 samples of 2015 to 2023 that profile has the passes at: definitions 9,843 of 63,116 ms (15.6%), wall records 2,227 (3.5%), phase read 1,946 (3.1%), native preamble 2,499 (4.0%), record index 1,220 (1.9%). On a quiet runner the cuts are smaller than the shares: 8.1%, 2.4% and 1.2%.

"The shared preamble before the native passes, about 590 ms" is not the native preamble. It is everything an export does before its first native pass (the partition strings, the arc wall scan, the 2023 record scan, the levels), which 0.11.0 does as well: profiled on both (run 42111526405 on an EPYC 9V74 and run 42112096504, scratch head 03aa8f6, on an EPYC 7763: different runners, so shares only) those steps are 65.7% of the export of 2015 rac_advanced at 0.11.0 and 35.5% on main, and among the steps both versions run each takes about the same share on both (the partition strings 35% at 0.11.0 and 29% on main, the 2023 record scan 17% and 18%, writing the file 15% and 18%). They are a floor shared with 0.11.0. What the native passes added is read_preamble: 68 ms on 2015 rac_advanced: schema parse 11 ms, element index parse 18 ms, storage increments 4 ms, extensible storage catalog 28 ms.

The issue's concern about the definitions pass: a root-only read could ingest a record the full decode refuses today. This does not read less: every byte is read and every check made, in the same order and with the same errors, and only the values of the fields not kept are not built. A record the full decode refuses is refused with the same message.

Changes

  • src/research/native_parameters.rs: the cursor's pointer, entity_pointer, class and field take const BUILD: bool. With it unset they read, check and note pointers exactly as with it set (one body, so the checks cannot differ) and return Null in place of the value. decode_graph_projected(.., keep) decodes a graph whose objects keep only the fields named in keep. A repeated field key is found in the built object where there is one, and by position (ClassPlan::duplicate, found only when projecting) where the field is not built. The full decode's path is the same statements as before.
  • src/research/native_document.rs: Options::graph_fields, a function from a record's root class to the fields to keep; a projected record has no saved_metadata. The definitions pass sets its own, whatever the caller's.
  • Each field list is a pub const beside the one function that reads the projected graph, so that a field the reader comes to read is added where it is read: native_parameter_definitions::{FAMILY_BINDING_FIELDS, SYMBOL_BINDING_FIELDS} and Registry::ingest_binding_context; native_walls::WALL_READ_FIELDS (m_id, m_WallAttributesId, m_baseOrTop) and wall_facts, which WallReads::read calls; native_es_catalog::CATALOG_FIELDS and from_graph, which decode calls. Doc lines at those readers and at wall_type_id and is_top_joined say so, and docs/maintaining.md has a section on it.
  • src/research/native_index.rs: parse searched the element table's layout for the leaf of each of the 7 fields it takes, at each of the file's rows (17,101 on rac_advanced), with a vector of candidates each time. The leaf a prefix names is now found at the first row that asks for it and kept in a named field of IndexLeaves, so a lookup that fails fails at the same point with the same message and an eighth lookup is a new field, not an index.
  • src/research/schema_registry.rs, src/research/native_es_catalog.rs, src/research/native_document.rs: the checksums of the schema (one per class) and of the catalog's stream are formatted with lower_hex, the same lowercase digits without a string for each byte.
  • probes/examples/probe_1335_projected_graphs.rs: imports the constants, decodes every record both ways under each list and under two that stress the mechanism (the identity alone, no field), and runs the real readers on both graphs: ingest_binding_context (the registry and the refusals), wall_facts (every SWall and ArcWall) and from_graph (the catalog and its provenance JSON) on the Global/Latest document in full and projected.
  • changelog.d/changed/1335-*.md: three fragments.

What is not cut (floors)

Shares of the exports' own time over the 33 samples of 2015 to 2023 at the final head (profile run 42124471783, scratch head c85c73c, an EPYC 9V74, shares only), against main before in run 42111526405: definitions 6.8% (15.6%), the named-parameter read 3.4% (2.9%), the phase read 3.5% (3.1%), the record index 2.3% (1.9%), the wall records 1.8% (3.5%) and wall types 0.4%, the preamble 1.7% (4.0%), area regions 0.9% (0.8%); all native passes 22.8% (33.0%). If every one cost nothing, the export would take about 0.92 of 0.11.0's time (an estimate: those shares applied to the timing run's totals), so the 1.2 against 0.11.0 is what these passes still cost.

  • The phase read: 97 ms of 2015 rac_advanced's 2,207 (4.4%, run 42111526405). Projecting its RoomElem graphs (38 ms of it) measured 0.993 of this PR's first head's time (run 42117002359, closed as perf(reader): the phase read builds only the fields it keeps of each RoomElem graph (#1335) #1487): inside the run's noise, for a list kept by hand. The rest is the per-record selection and routing of extract_records (about 26 ms) and the Element base read of 16,981 other records (18 ms), which builds an ElementBase and a Record for each so that the same closure sees what it saw.
  • The record index: one walk of every partition that includes the first inflate of each, which 0.11.0 does as well.
  • The steps before the first native pass (the paragraph above), shared with 0.11.0.
  • Area regions (native_area_regions.rs, new since 0.11.0): on 2015 rac_advanced the LevelRoomPlan graphs are 9.5 ms decoding and 5.0 ms freeing and the CurveElem graphs 5.9 and 1.6, about 22 ms of 1,646 (1.3%) at the final head (run 42124471783), and only a file with Areas pays it; over the 33 samples the pass is 0.9% of the exports' time in all. Its reader, plan(), builds m_segments, m_circuits, m_components and m_rooms of the PlanTopology, which is the bulk of those graphs, so a projection would leave most of the 1.3%: not worth a pull request. A floor.
  • Taken in follow-up pull requests, stacked on this one: building the class plans of a decode afresh for each record (3.1% of all export time: 1,024,681 plans built over the 33 samples, 2,114 ms of 68,189, in the plan-timing profile run 42127560399 on an EPYC 7763; 47 of the definitions pass's 166 ms and 20 of the wall records' 61 ms on rac_advanced), and the byte scan of the named-parameter read.

Testing

Unit tests are banned here: none added. All runs are of 4140b96, against main at df96767 or the clean tags; Autodesk's sample projects, the reference models, the BIM4LCA offices, the Revit 2025 models and the held-out models are fetched for the runs and never stored (held-out as counts).

  • The unfiltered Measure, run 42125670870 (-f base=main -f nordic=true -f r2025=true -f holdout=true -f samples=true -f timing=true, default scorers, no ifc_flags): byte identity of every model and the timing against main, above. Its same-project gates job wrote the check run 127599178067: success, "pass: 9 samples held to their earlier saves, and the Areas on 4 saves and on the 2021 save". The probe run below, dispatched on the same commit and finished 30 seconds later, wrote a neutral "NOT MEASURED: the scorers asked for exclude bodies_across_saves" (127599399222) that GitHub lists as the latest check of that name; the success is listed with filter=all.
  • The projected decode against the full decode, run 42125686355 (-f probe=probe_1335_projected_graphs -f samples=true -f r2025=true -f scorers=none; every sample of 2015 to 2027, the reference models and the Revit 2025 models, 88 files): 1,128,043 records, 6,768,258 projected decodes under six lists, 0 mismatches; the 4,743 records the full decode refuses are refused alike (FamilyInstance 3,403, VarSketch 1,125, ImageHolder 105, AppearanceAssetElem 38, RebarShape 30, others fewer). No Family or FamilySymbol is among them: the registry the definitions pass builds is the same from both graphs on every file. wall_facts is the same on all 7,900 SWall and ArcWall records. The catalog's document gives the same catalog and provenance on 79 files and is refused alike on 9. Not measured: the BIM4LCA offices and the held-out models under the probe.
  • Time against 0.11.0 and 0.15.0, runs 42125703262 and 42125717387 (timing jobs, the 33 samples of 2015 to 2023 and the six reference models, one runner per shard, an EPYC 9V74 for the samples in both and a 9V74 and a 9V45 for the models; median of three exports each; sum of medians, mean and median of the per-file ratios; Revit 2024 to 2027 samples were not timed against the tags):
class files 0.11.0 (s) PR (s) sum mean median per file
samples 2015 6 6.2 7.7 1.236 1.237 1.260 1.07 to 1.31
samples 2016 to 2018 9 6.6 8.0 1.213 1.230 1.282 1.07 to 1.33
samples 2019 to 2022 15 13.7 16.6 1.216 1.222 1.254 1.06 to 1.33
samples 2023 3 4.3 3.8 0.894 0.914 0.950 0.79 to 1.00
33 samples 33 30.7 36.1 1.175 1.199 1.254 0.79 to 1.33
reference models 6 9.4 7.3 0.772 0.811 0.830 0.73 to 0.89
class files 0.15.0 (s) PR (s) sum mean median per file
samples 2015 6 9.0 7.8 0.870 0.870 0.868 0.85 to 0.89
samples 2016 to 2018 9 9.0 8.0 0.890 0.895 0.900 0.86 to 0.92
samples 2019 to 2022 15 19.0 16.7 0.882 0.889 0.894 0.86 to 0.92
samples 2023 3 4.3 3.9 0.913 0.915 0.914 0.90 to 0.93
33 samples 33 41.3 36.5 0.884 0.890 0.894 0.85 to 0.93
reference models 6 5.8 5.6 0.961 0.940 0.936 0.91 to 0.98

Peak memory against 0.11.0 is 0.61 to 0.96 on the samples (the models 0.73 to 1.03), against 0.15.0 0.86 to 1.00 on the samples (the models 0.82 to 1.00).

  • Time against main, the timing job of the unfiltered run (one runner per shard; shard 1 an EPYC 7763 for the 2024 samples, shard 2 a 9V74 for the samples to 2023 and the reference models, shard 3 a 7763 for the offices and the 2027 samples, shard 4 a 9V45 for the 2025 and 2026 samples):
class files main (s) PR (s) sum mean median per file peak memory, PR / main
samples 2015 6 9.1 7.9 0.867 0.868 0.863 0.84 to 0.90 0.85 to 1.00
samples 2016 to 2018 9 9.3 8.2 0.878 0.883 0.886 0.85 to 0.91 0.86 to 1.00
samples 2019 to 2022 15 19.7 17.0 0.862 0.871 0.875 0.83 to 0.90 0.86 to 0.99
samples 2023 3 4.3 3.9 0.903 0.906 0.905 0.89 to 0.92 0.89 to 1.00
samples 2024 to 2027 25 160.9 155.7 0.968 0.963 0.964 0.89 to 1.00 0.54 to 1.03
reference models and offices 10 61.1 59.4 0.972 0.946 0.950 0.88 to 0.98 0.82 to 1.01
58 samples 58 203.3 192.6 0.947 0.914 0.901 0.83 to 1.00 0.54 to 1.03
all files 68 264.4 252.0 0.953 0.919 0.914 0.83 to 1.00 0.54 to 1.03

Earlier heads of the three parts (the decoder is the same; each slice measured against the one before it): the definitions part 0.919 of main over the 33 samples (run 42115512932, head fa10c6d), the wall records part 0.976 (run 42116989088, head 16527ce) and the preamble part 0.988 (run 42117016111, head 76e98d7). The wall records part raised the peak of 2019 and 2020 rac_advanced from 168 to 173 MiB (1.03) in its run; the definitions part had taken them from 173 to 168, so they are at what main peaks at.

  • tools/check-local.sh: nothing is built on this Mac (no local compute); CI's fast jobs pass on this head.

Audit-honesty checklist

  • No capability changes; no export is meant to change, and none does in the 111 exports of the unfiltered run. Nothing here is a claim about Revit's own export.
  • A user-visible change has its entry as a fragment under changelog.d/changed/.
  • No limitation resolved or added. Revit 2015–2023 exports: the remaining time against 0.11.0 after #1237 #1335 stays open.
  • Opt-in costs nothing when off: the plan of a class has an empty kept and no duplicate unless the decode is projected.
  • No emojis, no private paths.

Breaking changes

None to the stable API, the CLIs or any export. rvt::research (unstable): native_document::Options gains graph_fields (and GraphFields); native_parameters gains decode_graph_projected; native_walls gains WALL_READ_FIELDS, WallFacts and wall_facts; native_es_catalog gains CATALOG_FIELDS, document, document_limits and from_graph; native_parameter_definitions gains FAMILY_BINDING_FIELDS, SYMBOL_BINDING_FIELDS and binding_context_fields.

Related issues

Refs #1335, which stays open.

@DrunkOnJava DrunkOnJava changed the title perf(reader): the definitions pass builds only the fields it keeps of each Family and FamilySymbol record (#1335) perf(reader): the definitions pass, the wall records read and the catalog's document build only the fields they read; the preamble does less (#1335) Nov 5, 2026
@DrunkOnJava DrunkOnJava added the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 5, 2026 23:44
@DrunkOnJava DrunkOnJava removed the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) November 6, 2026 00:39
@DrunkOnJava
DrunkOnJava merged commit e3cc717 into main Nov 6, 2026
35 checks passed
@DrunkOnJava
DrunkOnJava deleted the perf/1335-definitions-projected branch November 6, 2026 01:28
DrunkOnJava added a commit that referenced this pull request Nov 6, 2026
…not turn a job red (#1457) (#1506)

## Summary

`rustup toolchain install` failed once on `full / build + real files /
macos-26 / stable` on #1483 at 1811752 with "could not download file
from
'https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256'",
with nothing wrong in the code. rustup's own retries are over in
seconds. #1491 put the install in one composite action, so one change
now covers every job.

The install is tried three times, 20 s and 40 s apart, each failure
leaving a warning. A toolchain that really can't be installed still
fails the job, with an error, about a minute later.

The one other rustup download in CI, `rustup component add rustfmt` in
`ifcopenshell-validate`, moves into that job's setup step as `component:
rustfmt`, so it goes through the same retry.

Cache keys don't move: no toolchain and no environment variable changes,
and Swatinem/rust-cache v2.9.3 hashes neither the action file nor the
installed components. Every rust-cache key on this PR's CI run
42134631531 equals the same job's on main's run 42131995046, the
IfcOpenShell job's included
(`v0-rust-ci-release-Linux-x64-cdee7d24-2ff012fc`).

Refs #1457.

## Verification

- The action's run block, run under `bash --noprofile --norc -eo
pipefail` (as GitHub runs `shell: bash`) against a fake `rustup`,
`rustc` and `sleep`:
  - 0 failures: exit 0, 1 install, no sleep.
- 2 failures: exit 0, 3 installs, sleeps of 20 and 40, default set, 2
lines in `GITHUB_ENV`.
- 3 and 9 failures: exit 1, 3 installs, the error annotation, no default
set, nothing in `GITHUB_ENV`.
- `actionlint` exits 0.
- Not measured: a real download failure on a runner.
`tools/ci/check-workflows.py` wasn't run locally (no PyYAML here); CI
runs it.

No output, `src/` or gate file changes, so no Measure.
DrunkOnJava added a commit that referenced this pull request Nov 6, 2026
…itory (#1511)

## Summary

Cargo's `cargo::redundant_homepage` lint warns on all four crates in
every nightly job's log (`package.homepage` is redundant with
`package.repository`; seen on #1483's docs.rs job, nightly-2026-10-01).
Both fields hold the same URL, so this removes `homepage`. The
repository link stays on crates.io, and `documentation` still points at
docs.rs.

## Verification

Nothing in `tests/`, `tools/`, `.github/` or `docs/` reads the field
(`git grep`). No code or output changes, so no Measure. CI's package and
docs jobs build the manifests.
DrunkOnJava added a commit that referenced this pull request Nov 9, 2026
…read by VWallDriver.m_pCrv, so 14 doors of rac_advanced 2027 take the axes rule (#1475) (RE-360) (#1500)

## Summary

Closes #1475.

On Revit 2027's save of `rac_advanced`, 18 of 180 `SWall` records hold a
second `GLine` besides the location curve, owned by
`WallRunTimeData.m_prevLocLine`. `native_walls` left out any wall with a
second curve, so the 8 host walls of 14 doors returned no native line
and the doors kept the default axes (RE-360). A record of exactly two
curves is now read where one is the level `GLine` `VWallDriver.m_pCrv`
names and the other is a `GLine` that only `m_prevLocLine` names. A
record with the one `GLine` reads as before, and any other set of curves
stays unread (a `CurveLoop.m_curves` profile wall, an arc, a null or
ambiguous `m_pCrv`).

## Motivation

#1456's second read found 14 doors of `rac_advanced`'s 2027 save left on
the default axes. #1454's check compares each cut opening with the 2025
save, so the 14 differ on axes alone. Both done-when items of #1475 are
met: the missing row is explained from the bytes (RE-360 section 1), and
the 14 doors are placed by the rule on 2027. The 15th door of the 2024
save's 8 hosts is hosted by another wall on 2027: #1454's cause, not
this one.

## Changes

- `src/research/native_walls.rs`: `record_line`, `location_curve_index`,
`is_previous_location_line`; `location_curve` (RE-348) now shares the
pointer read.
- `tools/re/bodies_across_saves.py`: the 2027 floor of `rac_advanced`
doors 47 to 61 and the ceiling of doors left on the default axes 42 to
28, as RE-347 requires of a count that moves. Whichever of this and
#1454 lands second sets 2027's numbers from a samples run on the merged
head and takes neither side's: #1454's branch holds 68, 24 and 15 for
the same counts, and this change's 61, 18 and 28 would loosen them.
- `probes/examples/probe_re360_wall_location_curve.rs`,
`tools/ci/scrub-holdout-results.sh` (keeps the probe's counts-only
`previous lines:` line for a model without a licence),
`reports/element-framing/RE-360-wall-previous-location-line.md`,
`changelog.d/fixed/1475-wall-previous-location-line.md`,
`docs/maintaining.md`, RE-347's section 7 (figures it no longer holds).

## Testing

Unit tests are banned in this repository: none added. Measured on
Autodesk's sample projects of 2024 to 2027 (25 files, no Revit export of
any):

- Measure
[42129732742](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42129732742),
head `d741927`: the probe, the cause.
- Measure
[42134051521](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42134051521),
head `0a0ba7ce` against base `ce3a3c47` (the same code without the
rule), default scorers, every job green. The figures below are from it.
It was dispatched from `main`, so it took `main`'s gate.
- Measure
[42137808608](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42137808608)
on head `b470a9ab`: the `same-project gates` check passes on 9 samples,
but reads "Scored by workflow commit `c5bae9ed`", `main`'s gate, whose
2027 ceiling is 42. **It did not exercise this PR's edit of
`bodies_across_saves.py`**, so 61, 18 and 28 are not yet scored by
anything.
- Measure
[42141380072](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42141380072),
the unfiltered run on head `5754c7f3` against `main` at `0dd3ad93`,
dispatched from this branch (`-f base=main -f samples=true -f
nordic=true -f r2025=true -f holdout=true -f keep_ifc=true`, the probe
on every model), every default scorer, no filter, every job green. Its
`same-project gates` check reads "pass: 9 samples held to their earlier
saves, and the Areas on 4 saves and on the 2021 save", "Scored by
workflow commit `5754c7f3`": this branch's gate, with its 61, 18 and 28.
The same gate on the base fails `rac_advanced` 2027 on both numbers (47
doors below 61, 42 left out above 28), so the floor and ceiling bind.
The figures under "Every model" are from it.

- Head `a0c90b97` holds #1477 and #1483 (main moved after the run)
through a clean merge; #1483's projected wall read is the 2015 to 2023
`WallReads::read`, not this read. Their effect on the figures was not
measured.

- [x] Verified end to end on real Revit files: the command, the files
and the measured result are in the report, with the probe that
reproduces it
- [x] Touches the IFC exporter only through what the wall read feeds: of
111 models and samples six exports change and 105 are byte for byte
main's (list below)
- [x] Not a performance change

## Every model (run 42141380072, repeated on the landing head)

The landing run is
[42530216655](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42530216655),
head `aa3324e8` against `main` at `1e2d3de4`, which includes #1517: that
change makes `native_walls` reach Revit 2015 to 2023, so this rule does
too. 112 of 118 exports are `main`'s, the same 6 move, none of them 2015
to 2023, and `same-project gates` passes. Before it, run
[42518227323](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42518227323),
head 431c2f2d against `main` at ab5f8e1, 118 models and samples:
`ifc.sha256` moves on the same 6 as below, the office's door axes
(placed by the rule 193 to 194, differing from Revit 0) and
`Qto_WallBaseQuantities.Length` (missing 54 to 52, different 0) move as
below, nothing else does, and the same-project gates pass with
`rac_advanced` 2027 going from fail on the base to pass on the head.


- **`ifc.sha256`, base against head:** equal on 105 of 111, moved on 6:
`rac_basic` 2024 to 2027, `rac_advanced` 2027 (above) and the BIM4LCA
office as built. Held-out and spent models: equal on all 19, kept counts
unchanged but for the added `previous lines:` line.
- **Walls read through the rule** (records, with a previous line
(offset), read through the rule): Core Interior 1,209, 281 (0), 281,
export byte for byte main's, so it exercised 281 walls and none reaches
an output (no `REPLAY_DRIFT` is possible: its export and witness
observations are the same); the office at permit 1,137, 76 (24), 76,
byte for byte; `rac_basic` 2023 5, byte for byte (the consumers do not
run there); Snowdon Architectural 2, byte for byte. Every other model
reads none through the rule and exercises nothing.
- **The office as built** (Revit's export exists; 1,082, 52 (23), 51):
the export differs in one door and its opening of 13,688 products: door
2597741, set in the newly read wall 2599599, gains `PlacementAxesSource`
and the rule's axes; no body, class, other property or quantity moves.
`door_axes_vs_ifc`: placed by the rule 193 to 194, differing from
Revit's 0, same 211 to 212. `qtos_vs_ifc`: equal 29,760, different 1 (as
on main), rvt-rs quantities Revit does not write 0, unchanged;
`Qto_WallBaseQuantities.Length` equal 92, different 0, missing 54 to 52,
the 2 walls leaving it being the 2 newly read plain walls, whose Length
Revit's export gives as rvt-rs's curve's or its Axis's (neither stays
0). `psets_vs_ifc`, `wall_bodies_vs_ifc`, `wall_ends_cv_vs_ifc`,
`class_sets_vs_ifc` and `door_bodies_vs_ifc` are identical files.
`wall_length_vs_ends` is not a Measure scorer. The diagnostics gain
exactly the 2 walls; the semantic diff finds 0 elements changed. Nothing
moved away from Revit's.
- **Held-out:** 11 of the 18 hold native wall records (145 in all) and
none holds a previous location line; the other 7 (2018 to 2022) hold
none to read. So no held-out model has an offset previous line. The
offices do (23 of 52, 24 of 76); the walls and the door of the office as
built that reach its export agree with Revit's, but which of the 23
those are was not read.

## Measured result (run 42134051521, samples only)

- **What each save reads** (base, head): `rac_advanced` 2027 162, 180
(2024 to 2026 180, 180); `rac_basic` 47, 52 on 2024 to 2026 and 46, 52
on 2027; `rme_advanced`, `rme_basic`, `rst_basic` unchanged; Snowdon
Architectural 1,202, 1,204. On the head `rac_basic` reads the same 52
walls and `rac_advanced` the same 180 on all four saves, by id. No wall
the old rule read is un-read. 26 walls are newly read over every `SWall`
record of the 25 files (the probe's count), of which 20 can reach an
export: the 18 of `rac_advanced` 2027 and `rac_basic`'s 709245 and
234869, none on Snowdon.
- **What settles which line is the location curve** (RE-360 section 1):
the previous line has the location curve's direction and length, so
length cannot say. On the 4 walls where it is offset it is offset across
the wall by exactly half the type thickness (0.4970 of 0.9941 ft, 0.2272
of 0.4544 ft); `m_pCrv`'s line equals the partition axis (RE-53) to
0.0000 ft on all 13 dumped walls that have one, and
`attach_wall_lengths` gives `m_wall_curve_length` only within 1e-4 ft of
that axis, which all 17 newly read plain walls got. A record whose
`m_pCrv` names the stale line could not be told apart by naming; none
exists in the 25 files. Curtain walls have no axis and no guard, so only
the rule protects them; both here have a coincident previous line.
- **What moves in the IFC:** `rac_basic` 2024 to 2027 and `rac_advanced`
2027 only. `rac_basic`: curtain wall 709245 gains
`Qto_CurtainWallQuantities.Length` 3.01 m, nothing else. `rac_advanced`
2027: curtain wall 149877 gains `Length` 25.6109 m (its 2024 to 2026
value); 14 doors gain `PlacementAxesSource`; 13 doors and their 13
openings change placement. No body volume or world box moves, no product
added or removed. No other wall, neighbour reach, shell or length
changes on any save. **No check holds the two curtain `Length` values**:
no Revit export of these files exists, no gate compares a curtain wall's
`Length`, 709245 gains it on all four saves at once, and only its box
width of 9.8753 ft corroborates it.
- **Pinned walls (`lane/1454-gates`):** one overlap, 234869 on
`rac_basic` 2027; its body, volume, box and properties are unchanged, so
its pin holds. Nothing re-pinned.
- **Snowdon Architectural:** byte for byte the base's; the 2 newly read
walls are not products of rvt-rs's export nor of Revit's IFC4 (counts
only), so nothing is scored and no wall moves from Revit's.
- **The 14 doors:** equal to the 2025 save's (and the 2024 save's) in
axes, origin, body vertices and volume, 14 of 14 (base: 1 of 14), placed
by the RE-347 axes rule. The same-project gate of that run, main's:
`rac_advanced` 2027 compares 79 (61 doors, 18 windows) and leaves 28
out, where the base compared 65 and left 42 out.
- **The 14 cut openings:** placement now equal to the 2025 save's; their
volume and vertices still differ on all 14 (0.3526 ft at the farthest)
before and after, because the cut loop of a door's symbol is read on
2024 and 2025 only. #1454 widens that list; not measured together.
- **Not measured:** any Revit export of the sample files; the newly read
sample walls' lengths and directions against Revit's; whether the 2
walls and the door of the office as built that reach its export are
among its 23 offset previous lines (the probe prints a count, not the
wall).

## Audit-honesty checklist

- [x] README and docs reflect the state: no capability claim changes
beyond the two values above
- [x] Changelog fragment under `changelog.d/fixed/`
- [x] A limitation remains and is stated: the 14 openings' size on 2027
(above)
- [x] Commit messages describe what changed
- [x] No emojis; no private paths or personal addresses in committed
files
- [x] Reverse-engineering finding: a reproducible probe under
`probes/examples/` and the report RE-360

## Legal and contribution hygiene

- [x] I agree this work is licensable under Apache-2.0
- [x] No Autodesk proprietary source, decompiled internals or NDA'd SDK
content: member names and bytes of Autodesk's public sample files
- [x] No fixtures

## Breaking changes

None.
DrunkOnJava added a commit that referenced this pull request Nov 9, 2026
…ss once, not once for each record (#1335) (#1503)

## Summary

Decoding a record works out, for each class it meets, the chain of
classes and the key of each field (the class plan). Each decode made
them afresh, so a pass over a file's 17,000 records made them 17,000
times over. The passes of `extract_records` now keep the plans between
records (`native_parameters::PlanCache`), in a cache whose size is
bounded. A plan depends on the schema, the class and the fields a
projected decode keeps, and nothing else, so a decode that finds one
made earlier reads exactly as it would have with its own.

Measured at 0767639, against #1483's measured head 4140b96 (run
42130101254): the exports of the 33 samples of Revit 2015 to 2023 take
0.974 of #1483's time (per file 0.96 to 1.00; every head run below every
base run on 23 of 39 files, none the other way), `ifc.sha256` and
`diagnostics.json` are equal on all 33 (66 of 66), and peak memory moves
by +0.11 MiB on average (largest rise 1.4 MiB, inside run noise). The
pushed head adds the bound on the cache, the probe's added checks and
docs; bytes are measured at it (Testing) and time is not (the bound runs
only when a plan is made, not when one is found, and no real file
reaches it: the largest cache any of 88 files makes is 17.4% of the
limit, see Testing).

## Motivation

#1335's plan-timing profile (run 42127560399, scratch head 76e8036, an
EPYC 7763, shares only): 1,024,681 class plans were built over the 33
samples of 2015 to 2023, 2,114 ms of 68,189 (3.1%) of the exports' time;
on 2015 `rac_advanced` 47 of the definitions pass's 166 ms (28%), 20 of
the wall records' 61 ms (32%) and 8.5 of the phase read's 111 ms. The
measured gain is 2.6%.

## Changes

- `src/research/native_parameters.rs`: `ClassPlan` no longer borrows the
registry (its chain is the classes' tags, which the loop reads from the
registry), so a plan outlives the decode that made it. `PlanCache` holds
them by class tag and the address and length of the kept fields; the
plan records which fields it was made for, and a hit is taken only where
they are the same fields, so another list at the same address is not
taken for it. A cache is for one schema: `decode_graph_cached` empties
it when the schema's checksum is another's. A plan's depth check on a
hit is the one the building made. `decode_graph_with_catalog_usage` and
`decode_graph_projected` take a fresh cache, as each decode made its own
plans before.
- **The cache is bounded.** A plan costs `PLAN_ENTRY_COST` (8) and one
unit for each field of every class of its chain and each field kept; the
cache holds at most `PLAN_CACHE_COST` (1,000,000, an estimate of about
60 bytes a unit, so about 60 MB, not measured) of cost,
`PlanCache::with_limit` sets another. A plan that would pass the limit
empties the cache first; a plan dearer than the whole limit is not kept
at all. Without it a crafted schema (one class of 50,000 fields and
30,000 empty child classes, each child's plan holding its 50,000
ancestor field names, about 2 MB, and 2,000 of them enough for wasm32's
4 GiB) or a caller of the public `decode_graph_cached` that passes a new
field list each call would grow the cache without bound, where before
each plan was freed with its record. **The bound cannot change a
graph:** a decode that finds no plan makes its own, which is what every
decode did before the cache, so a cleared cache or a plan that is not
kept only costs the rebuilding. The probe decodes every record through a
cache whose limit is 48 (so it empties itself or keeps nothing) and
compares each with the decode that makes its own plans.
- `src/research/native_document.rs`: `extract_records` makes one cache
for its pass and decodes through `decode_graph_cached`.
- `probes/examples/probe_1335_projected_graphs.rs`: decodes every record
through one cache shared by the whole file and every list, and through
the 48-cost cache, in full and projected, and compares each with the
same decode that makes its own plans: same refusal or the same graph
(every object's class, token, start, end and fields, the edges, the
consumed bytes, the usage). It prints the most the shared cache holds
after any decode (`plan-cache size`), states its FACT in its module doc,
and now exits 1 where anything it compares differs, so a job can turn
red on it. What it proves is that a shared cache equals a fresh one;
that a decode without a cache equals the one before the cache existed
rests on the exports' byte identity, which Measure shows, not on this
probe.
- `docs/maintaining.md`: the section on projected graphs covers the
cache and says to run the probe after a change to the cache.
- `tools/ci/scrub-holdout-results.sh`: the probe's count lines (records
decoded, differences, verdict words, schema class names, the readers'
field names, never the file's name or an ElementId) are kept for
held-out models, with its `exit N`; checked on a copy of a real probe
output.
- `changelog.d/changed/1335-plan-cache.md`.

## Testing

Measure run 42130101254 (`-f ref=0767639e -f base=4140b96c -f
samples=true -f sample_years="2015 2023" -f models="-" -f scorers=none
-f timing=true -f probe=probe_1335_projected_graphs`; this head's first
commit against #1483's measured head; shard 1 an EPYC 9V74 and shard 2 a
9V45; median of three exports each) and run 42130115171 (the probe
alone, Revit 2024 to 2027 samples and the Revit 2025 models).

- [ ] `tools/check-local.sh`: nothing is built on this Mac (no local
compute); CI's fast jobs run the draft.
- [x] The decodes through one shared cache against the decodes with
their own plans, at 0767639: 505,203 records of the 33 samples of 2015
to 2023, and 622,840 of the 2024 to 2027 samples, the reference models
and the Revit 2025 models (88 files): 7,896,301 cached decodes compared,
0 mismatches. The probe's other checks are as in #1483 (0 mismatches
over 6,768,258 projected decodes in these two runs' six lists).
- [x] The decodes through the limited cache, and the size the shared
cache reaches on real files: run 42136187580 (`-f ref=274c1f4c -f
base=none -f samples=true -f r2025=true -f scorers=none -f
probe=probe_1335_projected_graphs`; every sample of 2015 to 2027 and the
Revit 2025 models, 88 files, the probe's status 0 on all 88). 7,896,301
decodes through the shared cache and 7,896,301 through the cache limited
to 48 (which empties itself or keeps nothing) were each compared with
the decode that makes its own plans: 0 mismatches in either, and 0 in
the 6,768,258 projected decodes, with `wall_facts` the same on every
wall and the catalog the same on 79 files and refused alike on 9. **The
largest the shared cache reached on any file: 8,127 plans and a cost of
174,316 (Snowdon Towers architectural, 2024), 17.4% of the 1,000,000
limit, and no file emptied it** (clears 0 on all 88; the smallest peak
cost is 75,426 and the median 145,608; the next largest are 2027, 2026
and 2025 `racadvanced` at 163,236, 160,478 and 158,647). That cache
holds each class under seven field lists at once (no list, the readers'
four and two that stress the mechanism), more than any pass shares (the
definitions pass uses three), so a real pass holds less. No real file
pays for the bound: none empties the cache, so none rebuilds a plan.
- [x] Byte identity: `ifc.sha256` and `diagnostics.json` of the 33
samples against #1483's head, 66 of 66 equal, at 0767639. At the pushed
head: run 42144456661 (unfiltered, `-f ref=2e5bc4cb -f base=e3cc717f -f
samples=true -f r2025=true -f nordic=true -f holdout=true`, every
scorer, no `ifc_flags`, from `main`, which holds
`tools/re/bodies_across_saves.py`; `main` at e3cc717 is #1483 landed)
measures 2e5bc4c against `main` at #1483: `ifc.sha256` is identical on
111 of 111 models (58 samples, the 24 Revit 2025 models, 18 held-out
models, the 4 office files, the 4 RE1 models, Core Interior, Einhoven
and 1 spent pair), the only scorer output that differs is the two
`areas_across_saves` files, which are the gate's own, the same-project
gates pass and the semantic check passes on 34 models. BIMcollab's Revit
2015 example was not in that run.
- [x] Time, against #1483's head, at 0767639:

| class | files | #1483 (s) | this PR (s) | sum | mean | median | per
file | peak memory |
|---|---:|---:|---:|---:|---:|---:|---|---|
| samples 2015 | 6 | 7.8 | 7.6 | 0.973 | 0.971 | 0.973 | 0.96 to 0.98 |
1.00 to 1.02 |
| samples 2016 to 2018 | 9 | 8.0 | 7.8 | 0.977 | 0.976 | 0.977 | 0.97 to
0.98 | 1.00 |
| samples 2019 to 2022 | 15 | 16.7 | 16.3 | 0.975 | 0.976 | 0.976 | 0.96
to 1.00 | 1.00 |
| samples 2023 | 3 | 3.9 | 3.8 | 0.965 | 0.965 | 0.960 | 0.96 to 0.98 |
1.00 |
| 33 samples | 33 | 36.3 | 35.4 | 0.974 | 0.974 | 0.976 | 0.96 to 1.00 |
1.00 to 1.02 |
| reference models | 6 | 5.8 | 5.7 | 0.990 | 0.984 | 0.984 | 0.96 to
1.01 | 1.00 |

Peak memory: the largest rise is 1.4 MiB, on 2015 `rst_basic` (the
medians of three runs are 81,784 and 83,216 KiB, 79.9 and 81.3 MiB; the
three runs of the base alone span 81,740 to 83,120 KiB and those of the
head 80,920 to 83,352, so the rise is inside the run's own noise), the
mean change over the 39 files is +0.11 MiB, and no file rises by 2 MiB.
The profile estimated 3.1% of the export time for building plans; 2.6%
is measured.

## Audit-honesty checklist

- [x] No capability changes; no export is meant to change, and none does
on the 111 models of run 42144456661.
- [x] A user-visible change has its entry as a fragment under
`changelog.d/changed/`.
- [x] No limitation resolved or added. #1335 stays open.
- [x] No emojis, no private paths.

## Breaking changes

None to the stable API, the CLIs or any export. `rvt::research`
(unstable): `native_parameters` gains `PlanCache` (with `with_limit`,
`entries`, `cost` and `clears`), `PLAN_CACHE_COST`, `PLAN_ENTRY_COST`
and `decode_graph_cached`.

## Related issues

Refs #1335.
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