Repository navigation
perf(ifc): inflate each partition stream once per export instead of a dozen times - #266
Merged
Merged
Conversation
… dozen times The weekly Performance Budgets workflow fails the `medium` category on 2024_Core_Interior.rvt: `ifc_export` 24.5 s against a 15 s budget and `viewer_parse_render` 24.5 s against 18 s, while `element_decode` on the same file passes at 8.5 s. The gap is not in the geometry the August element-record work added — it is in how many times that work re-reads the same bytes. Every partition consumer opened the CFB stream, inflated all its gzip members and concatenated them for itself: the element-record category sweep (once per BuiltInCategory: columns, walls, doors, windows, and floors/pads/sketch-lines), the arc-wall scan, the plan-loop floor scan, the rect-opening index, the level records, the IFC export overrides and the partition scanner. `RvtDocExporter::export_with_diagnostics` then walks the document a second time to build diagnostics, doubling all of it. On this file that is ~180 MiB of inflate repeated more than twenty times, plus a byte-at-a-time `chunks.into_iter().flatten().collect()` for each pass, which cost more than the inflate itself. Memoise it on the handle. `RevitFile::inflated_partition` reads and inflates a stream once and hands out a shared `InflatedStream` that already holds the concatenation and each member's end offset — the two shapes the callers were rebuilding. `RevitFile::partition_string_records` does the same for the `Partitions/NN` string extraction, which unit recovery, storey names and the partition MVP each asked for separately. `RevitFile` never writes a stream, so one inflate is valid for the life of the handle. Two scans then dominated what was left, and both were doing avoidable work per byte: - `object_graph::extract_string_records` decoded UTF-16 and allocated a String at every offset whose length field happened to land in 1..=400, which binary data does often, only to reject nearly all of them. The strict test it applies — every char graphic, space, tab or newline — is decidable on the raw code units, because only ASCII encodes as `[byte, 0x00]` in UTF-16LE and everything else fails that test. Screen on the bytes and bail on the first bad code unit. - `partition_element_records::find_category_records` searched ~180 MiB per category with a hand-rolled first-byte-then-compare loop. Use `memchr::memmem`, which is the vectorised form of exactly that loop. This adds no crate to the build graph: memchr is already a normal (non-dev) transitive dependency through quick-xml and serde_json. Output is unchanged. `rvt-ifc --mode geometry` on 2024_Core_Interior.rvt emits the same 1,557,498 bytes before and after, identical apart from the two wall-clock fields the writer stamps (the FILE_NAME timestamp and the IfcOwnerHistory epoch); normalising those, both sides hash to b185cfb06f48b7c5a7fe7da6275c635370bc3b531b848ea97f3babe91469b6f8. The Revit_IFC5_Einhoven.rvt control is identical on the same basis. tools/perf_budget.py --require-category medium, this machine (M-series macOS, release profile, RVT_PROJECT_CORPUS_DIR on the magnetar Revit tree): operation before after budget element_decode 5623 ms / 1683.8 MiB 889 ms / 479.9 MiB 12000 ms / 1024 MiB ifc_export 17247 ms / 2684.2 MiB 1378 ms / 492.5 MiB 15000 ms / 1024 MiB viewer_parse_render 17081 ms / 2664.8 MiB 1379 ms / 497.9 MiB 18000 ms / 1024 MiB All three failed locally before (ifc_export on time, all three on peak RSS); all three pass after. `rvt-ifc --mode geometry` under /usr/bin/time -l, best of three: 24.16 s / 2635 MiB before, 1.58 s / 492 MiB after.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_4e89aede-d28f-4263-8533-35e04bb19aa2) |
`scan_partition_level_ids` is the sweep RE-27 added to recover the broad `OST_Levels` id set that the reference-list join tests for uniqueness. It read and inflated every `Partitions/*` stream for itself, which is the ~2 s its author measured on 2024_Core_Interior.rvt. Route it through `RevitFile::inflated_partition` like every other partition consumer. The streams are already inflated by the time it runs, so the sweep costs a scan rather than a decompress and the 2 s goes away. Output is unchanged: `rvt-ifc --mode geometry` emits the same 1,633,625 bytes for 2024_Core_Interior.rvt and 44,701 for Revit_IFC5_Einhoven.rvt, with the same clock-normalised hashes as RE-27 alone.
3 tasks done
DrunkOnJava
added a commit
that referenced
this pull request
Sep 19, 2026
…roughput (#271) ## Summary The loading card derived its "about N s" hint from 1.15 MB/s, measured when the 33.7 MB project took 30 s to decode. After #266 the deployed viewer decodes it in about 3 s (measured live: toast reports 3 s, 6.7 s including the 32 MB download), so the hint promised ten times the real wait. The constant now reflects the measured 11 MB/s. ## Testing - [x] `npm run typecheck` - [x] Display-only constant; no test asserts the number ## Legal and contribution hygiene - [x] Licensable under Apache-2.0; no Autodesk material; no PII <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Display-only constant and comment; no decode, worker, or parsing logic changes. > > **Overview** > Updates the viewer load overlay’s **“about N s”** hint to match decode speed after **#266** (partition streams inflated once per file). **`DECODE_BYTES_PER_SECOND`** rises from **~1.15 MB/s** to **~11 MB/s**, so a **33.7 MB** demo is estimated at **~3 s** instead of **~30 s**. > > The nearby comment now documents the new measurement basis (deployed site) and why the progress bar stays indeterminate. **`loadExpectation`** behavior is unchanged; only the constant and documentation differ. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 69df439. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
8 tasks done
DrunkOnJava
added a commit
that referenced
this pull request
Sep 19, 2026
## Summary Docs-only. PR #261 described the state at that moment; #266, #267/#268, #272, #273 and #274 landed after it and left several pages understating or contradicting what ships. Every number here is re-read from the linked report, the corpus gate, or the count manifest that backs it — nothing is carried over from the PR descriptions. ## Motivation Two pages disagreed with themselves. `docs/user-guide.md` gave both 853 of 872 and 801 of 872 storey containment in adjacent paragraphs, and quoted 336 of 360 walls, which #274 superseded. `docs/status.md` still said the wall-join decision "is in neither wall's box nor in 4 KiB past its record" — #274 found the carrier. Four pages still promised a ~28 second browser decode that #266 cut to about 3 seconds. The audit-honesty rule cuts both ways here: the same pass also had to avoid over-claiming #273, whose wall-type join is exact but emits nothing. ## Changes - **`docs/status.md`** — re-dated the RE-26 wall and column residuals as historical; added RE-29 (wall ends 689 → 711 of 720, bodies 336 → 351 of 360, 15 improved / 345 unchanged / 0 regressed, 9 residual ends at two true L corners; columns 176 → 256 of 256 at a worst residual of 9.4e-13 ft, `difference_box` fail-closed, `IFCPROPERTYSINGLEVALUE` 9231 → 9311) and RE-28 (the `0xffff8080` wall-type record, 360 of 360, distribution 129/127/100/4, #240 as an index artifact) with an explicit **library-side only, nothing emitted** paragraph; recorded #88's no-oracle finding and the 86-record `OST_Materials` bound; new `## Performance` section. - **`docs/user-guide.md`** — deleted the contradictory 801 of 872 paragraph; 336 → 351 of 360 plus the 256 of 256 column cut; added the #272 panel/schedule paragraph and a `### Performance` note; corrected the demo-gallery decode time. - **`README.md`** — the headline paragraph, the gaps table row and the demo-gallery line now carry the RE-27/RE-28/RE-29 state; new `### Performance on large projects`. - **`docs/contribution-map.md`** — the closed-issue list is now twelve issues, not six; the #33 / #219 row reads 853 of 872 and keeps the reference side marked `NOT MEASURED`; new rows for #238, #88, #227, #34 and #90; the closed #32 row is gone. - **`docs/support-matrix.json`** — `reviewed` to 2026-09-19; the walls and columns rows carry the RE-29 measurements and **stay `partial`**; a new `element-record-wall-type-join` row records RE-28 at `partial` with "None yet in the exported file" as its user impact; the instance-recovery and level-record rows no longer read 801 as current. - **`docs/supported-profile.md`** — IFC output and browser viewer rows; the compound-layer and family-profile bullets now name the no-oracle finding and the 9-end residual. - **`docs/ifc-compare.md`** — divergence table updated to the measured state, plus a plain statement that `catalogued_divergence_notes` in `src/ifc/compare.rs` still quotes the pre-#274 figures and still names #219 for slabs and windows. - **`docs/viewer-api.md` / `docs/viewer-build-pipeline.md`** — the #266 throughput and the `DECODE_BYTES_PER_SECOND` basis; the pre-#266 figures are kept but dated; the `build_gltf` `extras` fix and the panel / schedule contract from #272. ## Testing - N/A: docs-only PR — no Rust, viewer, workflow or test file is touched. - `docs/support-matrix.json` re-validated against `docs/schemas/support-matrix.schema.json` (required keys, `additionalProperties`, id pattern, status vocabulary, unique ids) and against the `honesty_invariants` that `tests/support_matrix.rs` enforces: `never_verified_capability_ids`, `max_status_by_capability_id`, and the COR-001 converter-grade rule. All pass; the new row is `partial`. - Every test and function name cited in the new prose was checked to exist: `the_surviving_side_of_a_true_l_corner_is_still_over_trimmed`, `core_interior_2024_column_join_cut_plan_extents`, `core_interior_2024_wall_joins_are_named_in_the_reference_list`, `core_interior_2024_wall_type_record_join`, `core_interior_2024_material_record_family`, `core_interior_2024_wall_join_trimmed_bodies`, `core_interior_2024_column_type_symbol_join`, plus `partition_type_records::{type_definition_ids, unique_type_reference}` and `element_record_column_cuts::{difference_box, column_cut_boxes}`. - `core_interior_2024_wall_join_trimmed_bodies` asserts `resolved == 360` and `trimmed == 322`, which is what the support-matrix evidence string now says. - Every relative link and repo path added resolves on disk. ## Audit-honesty checklist - [x] README / docs reflect the current state after this PR — no claims of features that are not actually shipped - [x] Resolved limitations updated: #239 (columns), #240 (the `18" Basement` slot), and the plate / window storey containment #219 tracked - [x] New limitations documented: the 9 true-L-corner ends, and #88 being unwitnessable on this corpus - [x] No emojis, no private paths, no personal email addresses - [x] N/A: no reverse-engineering finding is introduced here — the reports (RE-27, RE-28, RE-29) already shipped with their own PRs **Three claims deliberately not written:** 1. **Nothing about rooms.** `gh pr view 275` reported `OPEN` (checked twice, at the start and just before committing), so the existing space claims are untouched and `IFCSPACE` still reads "name-only, placeholder body" everywhere. 2. **The wall → `IfcWallType` join is never described as shipping in the export.** RE-28 §7 says "Library only. No emitted IFC entity, property or relation changes", and §8 says the join "is not yet a property on the emitted wall". Every mention says so explicitly. 3. **README's "419 MB of linear memory" is left alone.** That is a wasm32 figure from #256. #266 re-measured native peak RSS (490.1 MiB) and the browser decode time, but not wasm linear memory, so there is no measurement to replace it with. Also left as-is, and now flagged in `docs/ifc-compare.md` rather than silently papered over: the note constants in `src/ifc/compare.rs` still say "31 over-trimmed wall ends" and still name #219 for `IFCSLAB` and `IFCWINDOW`. Fixing those is a code change and out of scope for a docs-only PR. ## 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 - [x] N/A: no new test fixtures ## Breaking changes None. ## Screenshots or output samples N/A: docs-only PR — no UI or IFC output changed. ## Related issues Refs #88, #219, #238, #239, #240, #266, #272, #273, #274. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Documentation and support-matrix metadata only; no Rust, viewer, or export logic changes. > > **Overview** > **Docs-only refresh** so README, status, user guide, contribution map, supported profile, IFC compare notes, viewer docs, and `docs/support-matrix.json` match what landed after #266–#274 — without changing runtime behavior. > > **Capability numbers and gaps** are brought up to date: wall runs trimmed using the record **reference list** (351/360 world-exact, 9 L-corner ends still wrong), **column bodies** as prism minus named cutting walls (256/256), **storey binding** via record Level ids (853/872), and **wall→wall-type** join exact in the library but **not written to IFC** (#88 compound layers marked **no oracle** on the ReferenceView corpus). > > **Performance narrative** is added/updated everywhere it was still ~28s: partition inflate **memoized on `RevitFile`** (#266), Core Interior **~1.7s / ~490 MiB** native and **~3s** browser decode, byte-identical IFC aside from timestamps. > > **Viewer docs** now describe **glTF `extras`** for picking (#272), the typed info panel / schedule / host navigation, and **`DECODE_BYTES_PER_SECOND`** for loading hints. > > **Contribution map & matrix** list twelve closed issues, new remainder rows (#238, #88, #227, …), RE-29 evidence on wall/column rows, and a new **`element-record-wall-type-join`** row at `partial`. **`docs/ifc-compare.md`** documents the measured divergence table and explicitly notes that **`catalogued_divergence_notes` in `src/ifc/compare.rs` still lags** (separate code fix). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d5c32eb. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This was referenced Nov 11, 2026
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.
Summary
The weekly Performance Budgets workflow fails the
mediumcategory on2024_Core_Interior.rvt. The cost is not the geometry the August element-record work added — it is that work re-inflating the same partition bytes more than twenty times per export. This memoises the inflate on theRevitFilehandle and fixes the two per-byte scans that dominated what was left. IFC output is byte-identical.Measured against
mainat8425a3f(i.e. after #267, #268 and #269),ifc_exportgoes 17.88 s to 1.45 s and peak RSS 2642.0 MiB to 516.2 MiB, and everymediumbudget passes.Motivation
Every partition consumer opened the CFB stream, inflated all its gzip members and concatenated them for itself:
partition_element_records::scan_category_records_multi— once perBuiltInCategory: columns (RE-26), walls (Partition element-record recovery for walls / doors / windows: recall is 100%, precision is not #211), doors and windows (RE-23), and floors / building pads / sketch lines (RE-22, RE-25)partition_arc_walls::scan_partition_arc_walls_with_limitspartition_schema_mvp::floors_from_partition_plan_loopsandrect_openings_from_partitionspartition_level_records::scan_partition_levels(RE-24) andscan_partition_level_ids(RE-27, feat(ifc)!: bind storeys from the Level ElementId the element record names #267)partition_ifc_export_overrides::scan_ifc_export_overridespartition_scanner::scan_partitions_with_controlobject_graph::string_records_from_partitions, asked for separately by unit recovery, storey names and the partition MVPRvtDocExporter::export_with_diagnosticsthen walks the document a second time to build diagnostics, doubling all of it. On this file the eightPartitions/*streams inflate to 178.9 MiB, so that is well over 3 GiB of redundant inflate per export — plus a byte-at-a-timechunks.into_iter().flatten().collect()per pass, which profiled higher than the inflate itself.Hotspot shares from a
samplyprofile ofrvt-ifc --mode geometryon the pre-change tree (inclusive, 14,467 samples):inflate_all_chunks_for_streamand theflatten().collect()join, repeated per consumerobject_graph::extract_string_recordsPartitions/NN, run once per consumerfind_category_recordsChanges
src/compression.rs— newInflatedStream: all gzip members of one stream inflated and concatenated once, with each member's end offset. That is exactly the two shapes the callers were rebuilding (plain concatenation; concatenation pluschunk_endsfor the scanner), and it reserves the exact total instead of growing throughFlatten.src/reader.rs—RevitFile::inflated_partitionmemoises it per stream path,RevitFile::partition_stream_namesreplaces six copies of the same filter, andRevitFile::partition_string_recordsmemoises thePartitions/NNstring extraction.RevitFilenever writes a stream, so one inflate is valid for the life of the handle.src/partition_element_records.rs,src/partition_arc_walls.rs,src/partition_level_records.rs,src/partition_ifc_export_overrides.rs,src/partition_scanner.rs,src/partition_schema_mvp.rs— read through the cache instead of re-inflating.src/object_graph.rs—extract_string_recordsscreens candidates on the raw code units before decoding. The strict test it applies (every char graphic, space, tab or newline) is decidable on the bytes: only ASCII encodes as[byte, 0x00]in UTF-16LE, and every other sequence — non-ASCII, an astral pair, a lone surrogate that decodes to U+FFFD — yields a char outside that set. Previously it decoded and heap-allocated at every offset whose length field happened to land in1..=400, which binary data does at a large fraction of offsets, then threw nearly all of them away.src/partition_element_records.rs—find_subslicenow callsmemchr::memmem::find, the vectorised form of the first-byte-then-compare loop it spelled out by hand. The category sweep runs it over ~180 MiB per category.src/ifc/mod.rs—recover_project_unitsandcollect_partition_building_storey_namestake the shared string records.Cargo.toml— addsmemchr = "2". This adds no crate to the build graph:cargo tree -p rvt -e normal -i memchrshows memchr 2.8.0 is already a normal (non-dev) transitive dependency through both quick-xml and serde_json.cargo deny checkpasses (advisories ok, bans ok, licenses ok, sources ok).Second commit: the RE-27 sweep
#267 landed while this was in review and added
scan_partition_level_ids, a new sweep over everyPartitions/*stream — the ~2 s its author measured on Core Interior. The follow-up commit here routes it throughRevitFile::inflated_partitionlike every other partition consumer, so it costs a scan rather than a decompress. With that, no partition sweep insrc/re-inflates:No behaviour flags, no new public semantics, no geometry changes.
Testing
All numbers below were re-taken against
mainat8425a3f, after merging it into this branch.cargo test --allpasses locally —tools/check-local.sh(fmt, clippy-D warnings, rustdoc-D warnings,cargo test --workspace --all-targets --all-features) exits 0. WithRVT_PROJECT_CORPUS_DIRset to the magnetar Revit tree: 1252 passed, 0 failed, including feat(ifc)!: bind storeys from the Level ElementId the element record names #267's newcore_interior_2024_storey_containment_is_evidence_backedcorpus gate.cargo clippy --all-targets --all-features -- -D warningspassescargo fmt --checkpassestests/project_count_fixtures.rsandtests/witness_registry.rspass against the real reference exports (IFC Exports/2024_Core_Interior_slim.ifcsha256bfdf36ff…andRevit/2024_Core_Interior.ifcsha256d07c7462…, both matching the manifests), so every scored count — 15 storeys, 360 walls, 80 slabs, 132 doors, 6 windows, 256 columns, 20 shading devices, 138IFCRELFILLSELEMENTpairs — is reproduced.tools/bench.sh— not run: it needs the phi-agrac*.rfasample family, which is not in this checkout.tools/perf_budget.pywas used instead, which is the harness the failing workflow actually runs.Byte-identical output
rvt-ifc --mode geometry, a binary built frommainat8425a3fversus this branch, same input:8425a3f2024_Core_Interior.rvtRevit_IFC5_Einhoven.rvtdiffof the two STEP files with theFILE_NAMEtimestamp line stripped reports exactly one remaining line, the other wall-clock field the writer stamps:Normalising both clock fields (drop
FILE_NAME(, replace theIFCOWNERHISTORYepoch), the two sides hash the same:Note these hashes differ from the pre-#267 ones — that is #267's intended storey-binding change, which this branch reproduces exactly.
There is no deterministic-timestamp switch (no
SOURCE_DATE_EPOCHsupport inifc::step_writer), so the two clock fields cannot be pinned without a behaviour change; adding one is out of scope here.Performance
tools/perf_budget.py --require-category medium, release profile,RVT_PROJECT_CORPUS_DIRon the magnetar Revit tree. Both columns measured on the same machine (Apple Silicon, macOS) minutes apart, baseline from a cleanmaintree at8425a3f:8425a3fopensummarizeschema_parseelement_decodeifc_exportviewer_parse_renderOn this machine
mainfails all three heavy rows —ifc_exportandviewer_parse_renderon time, all three on peak RSS. After, every row passes with an order of magnitude of headroom.rvt-ifc --mode geometryon2024_Core_Interior.rvtunder/usr/bin/time -l, best of three:8425a3fRevit_IFC5_Einhoven.rvtcontrol: 0.44 s / 25.1 MiB on main, 0.12 s / 20.7 MiB on this branch.For reference, the same comparison taken before #267 landed (main at
730699c):ifc_export17352 ms to 1366 ms,element_decode5682 ms to 866 ms. #267 added roughly 0.5-0.9 s ofifc_exporton the unoptimised side and none on this one, because its new sweep now reads an already-inflated buffer.No budget change is proposed and none is needed. Extrapolating to the GitHub runner from the ratio the workflow reported on the pre-#267 tree — CI
element_decode8.5 s against 5.62 s here, CIifc_export24.5 s against 17.25 s here, so roughly 1.4–1.5× — these numbers project to about 1.3 s forelement_decode, 2.1 s forifc_exportand 2.1 s forviewer_parse_render, against budgets of 12 s, 15 s and 18 s. Worth noting that on this machine #267 pushedviewer_parse_renderpast its 18 s budget too (18014 ms against 18000 ms), so themediumcategory was getting worse, not stable.One honest caveat on the memory column: the workflow reported ~480–510 MB peak RSS for the failing baseline, where this macOS machine measures ~2640 MiB for the same baseline binary. That is an allocator difference, not a measurement error — glibc returns freed pages to the OS where macOS libmalloc retains them, and the baseline's repeated 180 MiB transient allocations are exactly the pattern that exposes it. The direction of the change is the same on both platforms: one retained copy of the inflated partitions replaces many transient ones, and peak RSS should fall on Linux too.
Audit-honesty checklist
RevitFile::inflatedandInflatedStream: the inflatedPartitions/*bytes (178.9 MiB on this file) now stay resident for the life of the handle rather than being rebuilt per consumer. Measured peak RSS falls sharply anyway, because the transient copies it replaces cost more than the one it keeps.Legal and contribution hygiene
Breaking changes
None. Three additions to
RevitFile's public surface (inflated_partition,partition_stream_names,partition_string_records) and one new public type (compression::InflatedStream);object_graph::string_records_from_partitionskeeps its signature and now returns a clone of the shared result.Screenshots or output samples
IFC output is byte-identical to
mainat8425a3f— see the diff and hashes above.Related issues
Refs the
Performance Budgetsworkflowmediumcategory failure. Builds on #267 (RE-27), whose new partition sweep the second commit routes through the same cache. No issue number was given for the budget failure.