Skip to content

perf(saved-graphics): read and mesh saved graphics faster, same output - #882

Merged
DrunkOnJava merged 3 commits into
DrunkOnJava:mainfrom
n3ur0m4n:perf/saved-scene
Oct 23, 2026
Merged

DrunkOnJava merged 3 commits into
DrunkOnJava:mainfrom
n3ur0m4n:perf/saved-scene

Conversation

@n3ur0m4n

@n3ur0m4n n3ur0m4n commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Saved graphics are read and meshed 10-24% faster by rvt-gltf --saved-meshes on the reference models (13-40% for
a model's full saved scene), and the .glb written is byte-identical.

Motivation

Closes #881. Pointer tables were rebuilt on every lookup, the saved-scene passes paid for a
parameter-definition pass they never use, and elements were meshed serially.

Changes

  • src/native_parameters.rs: ObjectGraph caches its pointer lookup tables (edges by source object and offset,
    objects by token) in a OnceLock, built on first use; not serialized.
  • src/native_saved_mesh.rs: PointerIndex borrows the cached tables; pointer() resolves through them instead
    of scanning every edge and object. Same checks and errors as before.
  • src/native_saved_scene.rs: the three passes use native_document::extract_graphs; elements are meshed in
    parallel over available_parallelism() workers and put back in document order (the first error in that order
    is returned, as before); the decoded records are dropped on a background thread.
    Where there are no threads (the browser build, wasm32-unknown-unknown) and on a single core, elements are
    meshed one after the other and the records are freed in place, as before.

Testing

  • tools/check-local.sh passes (fmt, clippy, rustdoc, build, real-file / CLI / contract checks), with the
    reference models from tools/fetch-reference-models.sh in place.

  • Verified end to end on real files: rvt-gltf <file> --saved-meshes writes byte-identical output before and
    after on the six redistributable reference models (licences in research/witness-registry.json) and the three
    tier1 fixtures. Reproduce:

    git switch --detach upstream/main && cargo build --release --bin rvt-gltf && cp target/release/rvt-gltf /tmp/before
    git switch perf/saved-scene && cargo build --release --bin rvt-gltf
    for f in _project_corpus/Revit/*.rvt corpus/tier1/*/*.rvt; do
      /tmp/before "$f" --saved-meshes -o /tmp/a.glb && ./target/release/rvt-gltf "$f" --saved-meshes -o /tmp/b.glb
      cmp -s /tmp/a.glb /tmp/b.glb && echo "same  $f" || echo "DIFF  $f"
    done

    The sequential path, forced on for the check, writes the same byte-identical files.
    cargo check -p rvt-wasm --target wasm32-unknown-unknown passes.
    The saved scene serialized as JSON has identical elements; see "Breaking changes" for its summaries.

  • N/A: does not touch the IFC exporter's output (byte-identical).

  • Performance change: tools/bench.sh does not exercise saved graphics; the before/after on this path is in
    perf(saved-graphics): saved graphics are read and meshed 10-24% faster with byte-identical output #881.

Audit-honesty checklist

  • README / docs reflect the current state: no claims change.
  • N/A: no limitation resolved.
  • No new limitation.
  • Commit message describes what changed and why.
  • No emojis.
  • No private paths, personal email addresses, or internal jargon in committed files.
  • N/A: not a reverse-engineering finding.

Legal and contribution hygiene

  • I agree this work is licensable under Apache-2.0.
  • No proprietary source, decompiled internals, or NDA'd SDK content: the change only restructures existing
    rvt-rs code (caching, parallelism, choice of an existing extraction entry point). The work was done with the
    help of Claude, as the commit's Co-Authored-By trailer says, under the same clean-room rules.
  • N/A: no new fixtures.

Breaking changes

native_saved_scene::SavedScene::summaries no longer carry parameter_definitions, unit_formats and
parameter_binding_context, because the passes now use extract_graphs. Nothing in the crate reads them from a
saved scene; a caller that needs them can run native_document::extract itself.

Screenshots or output samples

N/A: output is byte-identical.

Related issues

Closes #881.

- Pointer lookup tables are built once per object graph (cached on
  `ObjectGraph`) instead of on every `PointerIndex::new`, and the free
  `pointer()` uses them instead of scanning every edge and object.
- The saved-scene passes read graphs with `extract_graphs`, skipping the
  parameter-definition pass they never used.
- Elements are meshed in parallel over the available cores; results are
  put back in document order, and the first error in that order is the
  one returned, as before.
- The decoded graphs are freed on a background thread.

`rvt-gltf --saved-meshes` writes byte-identical .glb files on the six
redistributable reference models and the three tier1 fixtures, and the
saved scene's elements are identical. One visible difference: the saved
scene's `summaries` no longer carry parameter definitions, unit formats
and binding context, which `extract_graphs` does not read; nothing in the
crate uses them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013R5i8yaee9fxwTCUC1Qkbg
@n3ur0m4n
n3ur0m4n requested a review from DrunkOnJava as a code owner October 21, 2026 12:32
n3ur0m4n and others added 2 commits October 21, 2026 14:44
The browser build (wasm32-unknown-unknown, rvt-wasm) cannot spawn
threads, so a saved scene read there would panic. There, and on a
single core, elements are meshed one after the other and the decoded
graphs are freed in place, as before this change.

Checked: `cargo check -p rvt-wasm --target wasm32-unknown-unknown`;
with the sequential path forced on, `rvt-gltf --saved-meshes` writes
byte-identical .glb files on the six reference models and the three
tier1 fixtures, as the parallel path does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013R5i8yaee9fxwTCUC1Qkbg
@DrunkOnJava

Copy link
Copy Markdown
Owner

Thanks for this, and sorry it sat for two days: fork runs need a maintainer's approval, and I've approved them now. I also merged main into the branch. Since you opened it, #890 moved the native_* modules under rvt::research (behind unstable-research). Your crate::native_parameters::PointerLookup path still resolves through the crate-internal re-export, so nothing here needed to change.

I read the diff. The cached lookup is the same pair of maps PointerIndex built, and pointer() now goes through it with the same checks. Sorting by index before collect::<Result<_>> keeps the first error in document order. Dropping the three summaries is fine: native_saved_scene is research API, and nothing in the crate, the bindings or the viewer reads them. One small thing, not blocking: h.join().expect(...) re-panics with a new message, so the worker's own panic message is lost. std::panic::resume_unwind(e) would keep it.

CI never reaches saved graphics: they're opt-in, and only Measure with --saved-meshes reads them. So I've dispatched Measure on this head against main with ifc_flags=--saved-meshes and timing=true: https://github.com/DrunkOnJava/rvt-rs/actions/runs/39956807932. If the IFC hashes match on every model and the timings bear out #881, I'll merge it.

@DrunkOnJava

Copy link
Copy Markdown
Owner

Merged as 7c4e87f. Thank you!

Measure confirmed it (run 39956807932, --saved-meshes with timing). The IFC export is byte-identical to main's on all six reference models, and every scorer's output matches. Saved-mesh exports on one runner, head/base time:

Model base (ms) head (ms) head / base
2024_Core_Interior 8808 8244 0.94
RE1-Architecture 2636 1700 0.64
RE1-Electrical 3375 2557 0.76
RE1-Mechanical 1902 1456 0.77
RE1-Plumbing 1606 1234 0.77
Revit_IFC5_Einhoven 444 392 0.88

Saved graphics also had no CI coverage until now; #909 adds an export of Einhoven and Core Interior with --saved-meshes that IfcOpenShell validates, so a later change to this path gets checked too. It will be in the next release's changelog.

DrunkOnJava added a commit that referenced this pull request Oct 23, 2026
DrunkOnJava added a commit that referenced this pull request Oct 23, 2026
…em, the only CI that reads saved graphics (#908) (#909)

The IfcOpenShell job exports Einhoven and Core Interior with `--saved-meshes`, requires a positive count of bodies drawn from saved graphics for each, and schema-validates both exports: until now no CI job read saved graphics. The CHANGELOG credits n3ur0m4n's #882. Fixes #908.
@DrunkOnJava DrunkOnJava mentioned this pull request Oct 24, 2026
10 of 12 tasks
DrunkOnJava added a commit that referenced this pull request Oct 24, 2026
## Summary

Prepares v0.7.0 (RELEASE.md steps 4 to 8): the version files, the
`[0.7.0]` changelog section assembled from `changelog.d/`, the README's
release section, and corrections to the status docs where they still
described the state before RE-212 or before the BIM4LCA office was
measured. Merging this is not the release; the signed tag on its squash
commit is.

## Motivation

Griffin's go-ahead (2026-10-24, about 3:00 PM): tag v0.7.0 once #887,
#930, #935, #940, #942 and #943 are on main with CI green. All six have
landed, the last at b04c0cb (#930). #934 (`--revit-property-sets`,
breaking) and #923 (the `ElementId` newtype, breaking) go in the next
release.

## Changes

- **Version files** (0.6.1 to 0.7.0): `Cargo.toml`, `rvt-py/Cargo.toml`
(and its `=0.7.0` pin on `rvt`), `rvt-wasm/Cargo.toml`, the `rvt` pin in
`tools/stream_evidence/Cargo.toml`, `viewer/package.json`,
`CITATION.cff` (`date-released: 2026-10-24`),
`.release-please-manifest.json`, and the workspace crates' entries in
`Cargo.lock` and `fuzz/Cargo.lock`.
- **`CHANGELOG.md`**: `python3 tools/release/changelog.py assemble`
moved the nine fragments in, then `[Unreleased]` became `[0.7.0] —
2026-10-24`, with an introduction, credits to puzzbobb (#870, #886,
#887, #935) and n3ur0m4n (#882), and "Upgrading from 0.6": the research
readers behind `unstable-research`, the `#[non_exhaustive]` types, the
error variants (and Python's `ValueError`), `SimpleDecoder`, the
property set builders' `Vec`, the removed `ifc::pset_validate`, the
element walk failing closed, and changed exports. Headings in the
assembler's order (Added, Changed, Fixed, Removed, Research), one each.
`[Unreleased]` is left empty.
- **Entries corrected for the release as a whole**: #847's pipe-port
entry said In ports' axes were wrong because their flow direction was
not read, and that other family-instance ports had no placement; RE-212
and #943 changed both, and it now gives main's counts (Measure
40126110706, base side: 124 of 124 and 62 of 62 with Revit's axis;
joined ports 108 and 53 as Revit's, 10 and 6 opposite). The
unjoined-ports entry says Revit 2025 in its headline. RE-215's entry
adds the office.
- **`README.md`**: "Release 0.7.0 and main", what 0.7.0 adds in brief.
The 0.6.1 section listed RE-215 under 0.6.0's additions; it shipped in
neither.
- **`docs/support-matrix.json`**:
- `native-symbol-cut-sizes`: the BIM4LCA office's result, and
`user_impact` limited to families whose symbol cuts an outline;
- `element-record-mep-connections`: still said HVAC and piping
directions, names and descriptions are not read and In ports' axes are
reversed; it now states RE-212 (direction, `InPort_`/`OutPort_` names,
`Flow` descriptions, axes), keeps SystemType and the electrical
description as unread, and lists RE-212's probe, scorer, test and report
as evidence.
- **`docs/status.md`** and
**`reports/element-framing/RE-215-symbol-cut-loops.md`**: the office,
which §6 called NOT MEASURED, as measured on 2026-10-24 (Measure
40121636312 and 40122363218): 187 of its 269 doors cut an outline and
have Revit's sizes; its 269 windows and other 82 doors are drawn by
symbols with no cut loop (#810).

## Testing

Unit tests are banned in this repository: do not add them. Show the
change working end to end on real files instead.

- [ ] `tools/check-local.sh` passes: this PR's CI. No code changes; the
version string changes the IFC header.
- [x] Verified end to end on real Revit files: no behaviour changes; the
measurements cited are the runs named above.
- [ ] If this touches the IFC exporter: the IFC header carries the
version (#417), so both Core Interior `rvt-rs.json` observations and
their verdicts are refreshed from this PR's CI run (its
`octetproof-core-interior` artifact) in a follow-up commit here,
differing only in `witness_version` and the verdict hashes.
- N/A: performance.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR
- [x] The changelog section is assembled from the fragments;
`changelog.py check` passes with none left
- [x] Resolved limitations updated (RE-212's in the support matrix, the
office's NOT MEASURED)
- N/A: no new limitation
- [x] Commit messages describe what changed and why
- [x] No emojis in code, docs, or commit messages
- [x] No private paths, personal email addresses, or internal jargon in
committed files
- N/A: not a reverse-engineering finding

## Legal and contribution hygiene

- [x] Apache-2.0
- [x] No Autodesk proprietary content
- [x] No fixtures

## Breaking changes

The release's, listed under "Upgrading from 0.6" in `CHANGELOG.md`. This
PR itself changes no API.

## Screenshots or output samples

N/A: the IFC changes only in its header's version.
@DrunkOnJava

Copy link
Copy Markdown
Owner

This shipped in v0.7.0, released today (2026-10-24) on crates.io, PyPI, the release archives and the container image, and it is credited in the release notes. Thank you.

n3ur0m4n added a commit to n3ur0m4n/rvt-rs that referenced this pull request Oct 27, 2026
The parallel meshing joined its workers with expect(), which panics again
with a new message and loses the worker's. resume_unwind carries the
original panic through, as suggested in the review of DrunkOnJava#882.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DrunkOnJava pushed a commit that referenced this pull request Oct 27, 2026
…ontrol (#1073)

rvt-gltf gave no sign of life while converting: the export walked the elements without a WalkerControl, and reading saved graphics, about half the time with --saved-meshes, had no stage. control::Stage gains SavedGraphics (0 then 1/1) and SavedMeshes (one report per element meshed). native_saved_scene::extract_at_detail_with_control, ifc::saved_meshes::attach_with_control and RvtDocExporter::export_with_mode_limits_and_control take a WalkerControl; the existing functions call them with the default one. A cancelled walk stops the export with Error::Cancelled instead of being taken for a failed walk. rvt-gltf --progress prints the lines of rvt-elements --progress. The parallel meshing joins its workers with resume_unwind, so a worker's panic keeps its own message (the note from the review of #882).

Measure runs 40557530610 (default) and 40557542838 (ifc_flags=--saved-meshes) against main: the IFC export is byte-identical on every reference model. The .glb is byte-identical with and without the flag (tests/rvt_gltf_progress_cli.rs, on the tier-1 fixture and RE1 Architecture).

Closes #1072.
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.

perf(saved-graphics): saved graphics are read and meshed 10-24% faster with byte-identical output

2 participants