Skip to content

fix(research): the saved-mesh pass cuts its batches by the body bytes of the symbols they read, sized before any is decoded (#1694) - #1701

Merged
DrunkOnJava merged 4 commits into
mainfrom
fix/1694-batch-bytes
Nov 11, 2026
Merged

DrunkOnJava merged 4 commits into
mainfrom
fix/1694-batch-bytes

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

The saved-mesh pass cuts its batches of shared symbols by the bytes of record body they read, sized before any symbol is decoded, instead of from the objects per symbol of the batch before. The default export's peak memory falls from 875 to 889 MiB to 360 to 392 on Autodesk's rac_basic of 2023 to 2027, from 1,790 to 1,396 on Snowdon Towers Architectural, from 934 to 1,001 to 724 to 792 on rme_advanced and rme_basic, and from 1,439 and 1,550 to 1,301 and 1,436 on the BIM4LCA office. No export changes (126 of 126 byte-identical) and no timed file takes more than 2% longer.

Motivation

#1694 (the pass's peak memory after #1691). Its dhat run named the holder, the decoded graph objects (Measure 42960663793), and its batch-plan probe (Measure 42973819930) found that the plan sizes each batch as 20,000 * records / objects of the one before it while the symbols sort by id with the largest last, so a batch that meets them holds several times its budget. Rows were registered on the issue before every run: #1694 (comment) (the fix's rows), the results at #1694 (comment) and #1694 (comment), and the two levers tried and not carried (a budget of 1,000,000 bytes, and not keeping the owners' graphs) at #1694 (comment) and #1694 (comment).

Changes

  • src/research/native_saved_scene.rs: body_sizes (one extract_graphs walk with Options::graph_classes empty, so each selected record comes back with its Element base and body_bytes and no graph is built) and batch_end (a pure function: a batch takes owners while the bodies of the symbols they name, each counted once, stay within BATCH_BODY_BUDGET = 2,000,000 bytes, always at least one owner, and the owners that name no symbol stay a batch of their own). BATCH_OBJECT_BUDGET and the first-batch, minimum and maximum symbol counts are gone. Seven failure-first tests of batch_end (an owner over the budget is a batch of its own, a zero budget advances, a shared symbol counts once, a symbol with no size counts nothing, sizes that overflow do not wrap, symbol-free owners stay apart, the budget is a ceiling the batch may reach).
  • changelog.d/fixed/1694-saved-mesh-batches-by-bytes.md.

Testing

Measured end to end on the Measure runner (no local builds here; the pure planner's tests also compile and pass in a standalone rustc harness):

  • unfiltered with timing against main 5f928b4 (every flag, every scorer, 126 models each side), 42977559276 on the fix (81a4b59a): 126 of 126 exports byte-identical, no scorer line moves, same-project gates pass; time reads 0.95 to 1.02 on the 68 timed files (offices 1.01, Snowdon Architectural 1.02); the export's peak memory, base to head: rac_basic 2023 to 2027 875, 889, 887, 887, 888 to 360, 378, 376, 375, 392 MiB; rme_advanced 2024 to 2027 981, 968, 970, 971 to 792, 783, 784, 787; rme_basic 945, 934, 934, 1,001 to 734, 724, 724, 724; Snowdon Architectural 1,790 to 1,396; Snowdon Electrical 757 to 643; the BIM4LCA office as built 1,439 to 1,301 and at permit 1,550 to 1,436; Core Interior, Snowdon Structural and rac_advanced unchanged. Two files rose: Snowdon HVAC 366 to 410 and RE1 Architecture 160 to 186 (their symbols come to one or two batches under the budget, which the old first batch of 8 symbols did not allow);

  • probe_1075_saved_batches (the batched read makes the same elements as the one-shot read, four selections of owners per model, exits with an error on any difference), 42977555634: identical true on 19 of 19 models;

  • probe_1075_heap_stages at the fix against the same probe at its base, 42977552233 and 42979872560: the pass's peak over its start, rac_basic 630.7 to 166.0 MiB, rme_advanced 500.0 to 291.7, Snowdon Architectural 869.9 to 558.5, Snowdon Electrical 318.6 to 228.7, with the same triangles on all 19 files.

  • the fix merged with main (which now holds RE-423's beams, whose read cost the 11 Autodesk files in feat(ifc): a beam's six base quantities are the sums of the prism its saved mesh is, and its body does not change (#1693) (RE-423) #1699 their time and memory), the same unfiltered run with timing: 42983301930, its result goes on this PR.

  • tools/check-local.sh: not run locally (no local builds here); CI builds and tests it

  • Verified end to end on real Revit files: the runs above, read against the rows registered on Default saved meshes: after #1691 the peak memory is still 1.4 to 4.4 times 0.17.0's on Revit 2023 to 2027 files; where the rest sits #1694

  • IFC output unchanged: 126 of 126 ifc.sha256 equal

  • Performance change: the timing table above is the before and after

Audit-honesty checklist

  • Changelog fragment under changelog.d/fixed/
  • Limitation stated: two files peak a little higher (above), and rac_advanced and Snowdon Structural do not move (their peak is not a batch: the owners the pass keeps while the batches run, which a lever not carried here takes out at 8 to 26% more stage time)
  • No emojis, no private paths

Legal and contribution hygiene

  • Apache-2.0; no Autodesk proprietary source, decompiled internals or NDA'd SDK content

Breaking changes

None.

Related issues

Refs #1694 (it stays open until the pass is measured against 0.17.0 again).

… of the symbols they read, sized before any is decoded, not from the batch before (#1694)

A batch was sized from the objects per symbol of the one before it, and the
symbols sort by id with the largest last, so on Autodesk's samples of Revit
2023 and 2024 the peak batch held 3 to 7 times its 20,000 graph objects
(rac_basic 99,580, rac_advanced 123,965, Snowdon Structural 135,746; Measure
42973819930). One walk with graph_classes empty now reads the body bytes of
every symbol an owner names without building a graph, and a pure function cuts
the batches at 2,000,000 bytes, a batch holding at least one owner whatever
its symbols weigh. Seven failure-first tests cover the plan.
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 11, 2026 08:05
@DrunkOnJava

Copy link
Copy Markdown
Owner Author

The head merged with main (292ddb2, with RE-423's beams) against main 1641128, every flag, every scorer, timing: Measure 42983301930.

  • 126 of 126 exports byte-identical to main's; the scorer diff holds only the two areas_across_saves files the head side writes; same-project gates pass on 292ddb2.
  • Time reads 0.93 to 1.02 on the 68 timed files.
  • The cost RE-423 put on the Autodesk files is gone. Peak memory, main with the beams to this head, MiB (before the beams, from run 42972934548, in brackets):
file time, ms peak memory, MiB
rac_advanced 2023 / 2024 / 2025 / 2026 / 2027 5,309 to 5,196 / 8,424 to 8,274 / 6,621 to 6,580 / 6,558 to 6,465 / 7,692 to 7,478 1,011 to 571 [557] / 1,090 to 590 [579] / 1,081 to 582 [567] / 1,075 to 576 [562] / 1,077 to 579 [566]
Snowdon Towers Structural 2024 7,698 to 7,381 1,224 to 679 [494]
rac_basic 2023 to 2027 0.93 to 0.95 875, 888, 886, 889, 888 to 360, 376, 376, 375, 377
rme_advanced / rme_basic 2024 to 2027 1.00 to 1.02 0.80 to 0.81 / 0.72 to 0.78
Snowdon Architectural / Electrical 1.01 / 0.99 1,770 to 1,401 / 757 to 649
BIM4LCA office as built 32,980 to 33,320 1,440 to 1,301
RE1 Architecture 1,194 to 1,169 160 to 186 (the one file that rose, as before)

So the batches planned by bytes take rac_advanced back to its peak before the beams (571 to 590 MiB against 557 to 579) and Snowdon Structural from 1,224 to 679 (494 before); rst_basic (326 MiB with the beams, 143 before) is a file of one batch and does not move.

@DrunkOnJava
DrunkOnJava merged commit 15593a3 into main Nov 11, 2026
65 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/1694-batch-bytes branch November 11, 2026 08:26
DrunkOnJava added a commit that referenced this pull request Nov 11, 2026
…-check, and corrects RE-423's controls (#1203) (RE-424)
DrunkOnJava added a commit that referenced this pull request Nov 11, 2026
…rossSectionArea, OuterSurfaceArea and GrossVolume Revit's extrusion gives it (#1203) (RE-424) (#1708)

## Summary

A column Revit's export draws as an extrusion holds four base quantities
in `Qto_ColumnBaseQuantities` (`Length`, `CrossSectionArea`,
`OuterSurfaceArea`, `GrossVolume`) that are the sums of the prism's
faces: the extrusion's depth, the area of one end, the lateral area, the
volume. rvt-rs wrote them for only some columns (the box rule, RE-291).
A column drawn from the mesh Revit saved for it now gets them where that
mesh is one closed solid of flat faces with no hole through it, a prism
along the vertical with two flat, square ends of one area whose volume
is the end area times its extent: RE-423's rule for a beam, with the
axis the vertical. They are written where the column's set holds none of
`CrossSectionArea`, `OuterSurfaceArea` and `GrossVolume` (all four) or
all three (the `Length`); no value a column holds is replaced, and no
body or `NetVolume` changes.

On the BIM4LCA timber office as built they read equal to Revit's on 340
of 344 `CrossSectionArea` (from 60), 339 of 339 `OuterSurfaceArea` (from
59), 338 of 339 `GrossVolume` (from 58) and 339 of 339 `Length` (from
203), at permit on 336 of 340, 335 of 335, 334 of 335 and 333 of 335;
the concrete office at permit gains the four on 6 columns, each of the
housing's six files on 1 to 3 columns, and a held-out Revit 2023 model
on 4 of its 4 extruded columns. 2,022 values on 580 columns of 10 files,
none different, none Revit omits. The 18 cut columns (Revit writes
`CrossSectionArea` alone on them) get nothing, which the vertical axis
alone separates.

Refs #1203 and #1016, neither closed: #1203 keeps the check of box-drawn
columns' types and #1016 is W7's umbrella. The residual is filed as
#1705 (the housing's box-drawn columns, whose box equals Revit's on 46
of 50 and 4 of 4).

## Motivation

#1203 (the meshed columns' values), #1016 (W7's quantities), #1636
(second-project measurement); follows RE-423 (beams), RE-291 and RE-353
(the box rule and the cut columns), RE-387 and RE-416 (a column mesh's
volume). The report also corrects one number in RE-423's (the controls
read 1.01, 0.99, 1.00 and 1.00, not 1.00), which rvtReview found on
#1702. The rows were registered on #1636 before the scorer's run was
read:
#1636 (comment)
(points 1 to 5) and
#1636 (comment)
(points 6 to 9, the change), and the results are read against them at
#1636 (comment).

## Changes

- `src/ifc/mesh_volume.rs`: `longest_flat_prism` (the body of
`beam_quantities`, which still gives the beam what it gave) and
`column_quantities`, which takes its result when the axis is the
vertical (cosine at least 0.9999). Five pure-helper tests of how it
fails: a box lying down or wider than it is tall, a slanted beam, a mesh
that is not one closed solid, a section of many planes and no triangles,
and a column standing on its end as the case it accepts.
- `src/ifc/saved_meshes.rs`: the pass reads `column_quantities` where it
reads each column's mesh, and `add_column_quantities` writes the four
into the column's `Qto_ColumnBaseQuantities` where its set holds none of
the three or all three. It adds no element to the pass's selection.
- `tools/re/column_quantities_vs_ifc.py` (Revit's quantities against the
prism of rvt-rs's own body, per Revit set and body source) and
`tools/re/column_added_quantities.py` (what one export adds to
another's, against the rule).
- Report RE-424, a changelog fragment, the release criteria's W7 entry
and a `docs/format-reconnaissance.md` addendum.

## Testing

Measured end to end on the Measure runner (no local builds here; CI
builds and runs the pure helpers' tests); the helpers compile and pass
in a rustc stub harness here:

- unfiltered run
[42980794133](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42980794133)
(head `cc0e59a2`, kept under
`refs/archive/2026-11-11/cited/cc0e59a2d896`, against `main` at
`16411282`, every flag and `timing`, 126 models each side): 109 exports
byte-identical and 17 move, the housing's six files, the office's three,
the held-out `modelo_bim` and 7 Autodesk samples; no line of
`qtos_vs_ifc` or `psets_vs_ifc` of any model gains a `different` or a
value Revit does not write; the `body_sources` of the 101 models that
report them are identical; `same-project gates` pass;
- run
[42980805331](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42980805331),
both sides' exports of the samples: `tools/re/ifc_element_diff.py` finds
only `IfcColumn` changing, only by quantities added, on 44 columns of 7
samples; `tools/re/column_added_quantities.py` reads every added value
of those 44 as the rule's value of the column's own mesh (44 of 44,
`Length` on 31), and finds no column the rule accepts and the pass reads
left without them in the 49 unmoved samples that hold columns (the 14 in
Snowdon Towers Architectural are meshes of two or three closed pieces,
which the pass refuses);
- scorer run
[42986667074](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42986667074)
(`tools/re/column_quantities_vs_ifc.py`, both sides): the rule is right
on every column the pass reads, refuses the 18 cut columns by their
axis, and what it would still add on the timber office reads 0;
- timing: 64 files of run 42980794133 read 0.98 to 1.04 in time (the 30
samples of 2015 to 2022, which the pass cannot read, read 0.98 to 1.02
in the same run) and 1.00 to 1.04 in peak memory (Core Interior's 437
and 453 MiB, in either order in RE-423's run too); the BIM4LCA files,
[42980801971](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42980801971),
read 0.99 to 1.03 and 1.00; against `main` with #1701 and the head
merged with it, runs
[42987678966](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42987678966)
and
[42987682914](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42987682914):
the ten BIM4LCA files read 0.99 to 1.02 in time and 0.99 to 1.00 in peak
memory, the 64 files 0.94 to 1.10 and 0.97 to 1.01 (the 30 samples of
2015 to 2022 read 0.94 to 1.06); pooled, the 7 samples that move read
+2.2% against +0.6% for those 30, which is two files (Snowdon Towers
Architectural's 28 s and `rst_basic` 2026's 1.1 s), and whether any of
it is the change's is not established.

Two rows registered on #1636 are missed as worded, and the report says
so: row 7's "held-out models' counts do not move" (`modelo_bim`'s column
lines gain 16 equal, no `different`) and row 8's "0.99 to 1.01" (the
runs' own noise is wider, and the files the pass cannot read show it).

- [ ] `tools/check-local.sh`: not run locally (no local builds here); CI
builds and tests it
- [x] Verified end to end on real Revit files: the runs above
- [x] If this touches the IFC exporter: the runs above, and the report
states what it does not touch (cut columns, round and hollow columns,
box-drawn columns, bodies)

## Audit-honesty checklist

- [x] Docs state only what ships (the criteria entry, the addendum, the
fragment and the report describe this change)
- [x] Changelog fragment under `changelog.d/added/`
- [x] Limitations in the report: one project with a Revit export (the
BIM4LCA office and housing, Revit 2024); the 44 sample columns are read,
not scored; the cut, round, hollow and box-drawn columns get none
- [x] No emojis, no private paths

## Legal and contribution hygiene

- [x] Apache-2.0; revit-ifc's `CreateBeamColumnBaseQuantities` cited by
file and function as RE-353 read it (CLEANROOM.md source 5), none of its
code copied
- [x] No Autodesk proprietary source, decompiled internals or NDA'd SDK
content

## Breaking changes

None: no public type or signature changes; a column's export gains
quantities it did not write.
DrunkOnJava added a commit that referenced this pull request Nov 11, 2026
…g reads (#1694) (#1717)

## Summary

The saved-graphics pass builds only the fields of a graph that meshing
reads (`Options::graph_fields`, the projection #1335 added for the
walls, levels, pipes and ducts). No export changes: 125 of 125 exports
of an unfiltered Measure are byte-identical. The pass's peak memory
falls 6% to 10% and a default export's 3% to 7% (0.93 to 1.00 times on
one runner); the registered bar of 0.85 is missed, and the next lever is
read on the issue (a pointer value is a three-entry map of about 730
bytes).

## Motivation

#1694: after #1691 and #1701 the default export's peak memory on Revit
2023 to 2027 files is still 1.3 to 2.5 times 0.17.0's. The dhat run of
the pass
([42996084734](https://github.com/DrunkOnJava/rvt-rs/actions/runs/42996084734))
puts 77% to 87% of its peak in the decoded graph nodes (`class_in`,
`field_as`, a map entry with its own key `String`, about 150 bytes each,
1.33 million on `rst_basic` 2023), and the pass reads a small part of
what a graph holds. Rows were registered on
[#1694](#1694 (comment))
before the runs.

## Changes

- `src/research/native_saved_scene.rs`: `SAVED_GRAPHICS_FIELDS`, the 66
`m_` names (keys inside a field's value included, and `m_id`) that the
seven modules reading a graph object between a graphics record and a
mesh use as string literals (`native_saved_mesh`,
`native_graphics_traversal`, `native_parametric_mesh`,
`native_parametric_surface`, `native_empty_faces`,
`partition_instance_transforms` and this one), and
`saved_graphics_fields`, which both extraction paths (`extract_impl`,
`extract_in_batches_with_control`) set as `graph_fields`.
`decode_graph_projected` reads and checks every field as the full decode
does and builds only the listed ones, so a graph is refused for the same
reasons and a field left out reads as absent. None of those modules
iterates a graph's fields or reads a qualified (`Declaring::name`) key.

## Testing

Measured on the Measure runner, no local build. Rows registered before
the runs on [the
issue](#1694 (comment)),
read on [the
issue](#1694 (comment));
head `af2d861c` against `main` `a0dd7813`:

| run | what | read |
|---|---|---|
|
[43026045106](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43026045106)
| unfiltered, every flag | row 1 held: 125 of 125 exports
byte-identical; `same-project gates` pass |
|
[43026049770](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43026049770)
| `timing`, 2023 and 2024 samples, offices, reference models (29 files)
| row 2 missed: peak 0.93 to 1.00 (`rac_basic` 2023 0.96, Snowdon
Architectural 0.97, offices 0.96 to 0.97; 0.85 asked); row 3: time 0.98
to 1.03 on 28 files, `rac_advanced` 2023 1.05 |
|
[43026053891](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43026053891)
| `probe_1075_heap_sites`, Autodesk's 2023 samples | row 4 missed: the
decode is 75%, 75% and 86% of the pass's peak (from 86%, 77%, 87%; 50%
asked); the peak falls 166.1 to 155.5, 309.1 to 279.6, 233.8 to 213.9
MiB |

- [ ] `tools/check-local.sh`: no local build here; the PR's own CI runs
fmt, clippy, rustdoc and the test matrix
- [x] Verified end to end on real Revit files: the rows above

## Audit-honesty checklist

- [x] Docs reflect what ships: no capability changes; the memory cost is
the issue's table, which the 0.18.0 notes state
- [x] A user-visible change has its fragment
(`changelog.d/changed/1694-saved-graphics-fields.md`)
- [x] Commit messages say what and why
- [x] No emojis; no private paths

## Legal and contribution hygiene

- [x] Apache-2.0; no Autodesk proprietary source or NDA'd SDK content
- [x] No fixtures added

## Breaking changes

None expected: row 1 is that no export moves.

## Related issues

Refs #1694.
DrunkOnJava added a commit that referenced this pull request Nov 12, 2026
…o the 2023 rac_basic sample's peak no longer rises (#1808)

The backport of #1441 gave the owners that name no symbol a batch of their
own, and let only a batch of symbols size the next. On Autodesk's 2023
rac_basic sample that raised the saved-mesh stage's peak from 537 to 790 MiB
with the same output (Measure 43305037655). Neither #1441's re-read of freed
owners (43309303255) nor sizing over symbol records alone (43309312639)
explains it. 0.14.0's batch plan with the owners still freed peaks at 523
MiB and keeps the BIM4LCA offices at 0.87 and 0.97 of 0.14.0's peak
(43312088155); without the freeing the rise stays (803 MiB, 43312097066).

main plans its batches with #1701's weighted planner, so this changes 0.14
only.
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