Skip to content

perf(research): a decoded graph's fields are the compact value from the decoder to its readers (#1694) - #1800

Merged
DrunkOnJava merged 20 commits into
mainfrom
perf/1694-fv-graphs
Nov 12, 2026
Merged

DrunkOnJava merged 20 commits into
mainfrom
perf/1694-fv-graphs

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

A decoded graph's fields are the compact value Fv (#1793) from the decoder on: class_in and field_as build it directly, GraphObject.fields, ObjectFields.fields, Parameters.fields and Parameter.raw_value hold it, and the readers read it through the names they used on serde_json::Value. An object keeps its values in one slice and shares the list of its field names with every object of its class, so a node costs 32 to 34 bytes where a Value cost 172 to 215. Nothing a reader reads changes: the exports must be byte-identical (row 1 below), and the peak memory of the saved-mesh pass falls with the nodes it is made of (rows 2 and 3).

Motivation

#1694: 75% to 87% of the saved-mesh pass's peak is decoded graph nodes. #1793 priced the typed value on 14 files before any reader moved (0.157 to 0.185 of a clone's heap, 4,276,161 objects round-tripped with 0 mismatches). This is the move itself. The rows are on the issue before any run: #1694 (comment)

Changes

  • src/research/native_parameters.rs: a ClassPlan holds two views of a class's fields, each its sorted field names (shared, Names) and a slot for each field: every field the chain reads (an inline object, and any object of a decode that is not projected) and the kept fields alone (the top object of a projected decode). class_in writes a field's value into its slot, and the old "ambiguous native field key" error is raised at the same point (through a filled check only for views whose keys collide); field_as builds scalars, strings, arrays, guid bytes and the pointer (Fv::pointer_value) as Fv. A first version gave an inline object of a projected decode the kept fields only, and the PR's Corpus health caught it (RE1 Electrical and Plumbing wrote 21 of 23 and 135 of 136 family-instance ports); the two views are the fix.
  • src/research/graph_value.rs: what the readers need beside research(graph): a compact value for a decoded graph's fields, exact to serde_json::Value, and a probe that sizes it on real graphs (#1694) #1793's conversions: get, indexing, pointer, the is_* and as_* tests, comparison with a bool, a string or a number, Display, Serialize (byte for byte the JSON of the Value it stands for), From impls, Fv::object and Fv::from_pairs, a process-wide table of names, and iteration of an object as (&str, &Fv). Failure-first tests of each (pure, no file or clock). The four public types allow unnameable_types with the reason beside them: rustc counts the IntoIterator impl on &Obj as public, so a build without unstable-research reads them as reachable, though no stable item names one (with every top-level item crate-private the public API compiled without a private_interfaces or private_bounds finding).
  • 40 files of src/ read a decoded graph as Fv: the 26 that took GraphObject, ObjectGraph, decode_graph or ObjectFields, and the modules that hold a field of one (native_document, native_index, native_json, native_es_catalog, native_element_parameters, mep, slabs, framing, rooms, family_revolutions, revit_property_sets). as_array is a slice and as_object an Obj, the two differences from Value.
  • 93 probes and 2 test files: a probe that only reads a graph reads Fv; one that builds JSON for its output keeps serde_json::Value and takes a graph value as Fv::to_json() at the edge, so what it prints is what it printed. probe_1694_compact_graph sets what the decoder builds against the JSON of the same fields.

Testing

  • A keep-going cargo check --workspace --all-targets --all-features, cargo clippy ... -D warnings, RUSTFLAGS="-D warnings -D unnameable_types" cargo check --lib --bins, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --lib and the module's lib tests, all clean on the head (a scratch workflow on a scratch branch, not on this one); the PR's fast CI is green on it, Corpus health included.
  • full / CI passed on the final head (the head measured below is b512ec42; the changelog fragment is the only commit after it).
  • Row 1, #1694 comment 6812365949: Measure 43144800763, unfiltered with every flag and holdout=true: ifc.sha256 of all 145 exports identical to main's, the diagnostics of the 120 that write them identical, no line of the censuses different, the semantic check and same-project gates pass (read on #1694).
  • Row 3, same comment: Measure 43144804167 (timing, three rounds, both builds on one runner): time 0.75 to 0.94 of main's on all 29 files (together 0.83), at most 1.03 asked.
  • Row 2, same run: peak held on 8 of the 11 files it named (rac_basic 0.72, rac_advanced 0.66, rst_basic 0.50, every other file at most 1.00) and missed on the three largest: Snowdon Towers Architectural 0.79, the BIM4LCA office as built 0.78 and at permit 0.76, against 0.70 (read). A measured negative, reported as one; the dhat run registered next names what is left.

Audit-honesty checklist

  • No capability claim: a memory change inside the research modules. The changelog entry is added with the measured figures, after the runs.
  • No reverse-engineering finding.
  • No emojis, no private paths in committed files.

Legal and contribution hygiene

  • Apache-2.0. No Autodesk proprietary source, internals or NDA material.
  • No new test fixtures.

Breaking changes

None to the stable API. rvt::research (unstable-research) types that held a serde_json::Value of a graph now hold an Fv.

Related issues

Refs #1694.

…to serde_json::Value, and a probe that sizes it on real graphs (#1694)

A decoded graph object's fields are serde_json::Values, and 75% to 87% of the
saved-mesh pass's peak is those nodes: a BTreeMap leaf is 631 bytes however few
fields it holds, every key is a heap String, and a pointer, an object of three
numbers, costs about 730 bytes. graph_value::Fv holds the same content with an
object's values in one slice and its names once for every object that has
them. from_json and to_json are exact (number kinds, key order and all), with
failure-first tests of the conversion, and nothing reads a graph through Fv yet.

probe_1694_compact_graph decodes every native record of a file one record at a
time, counts the live heap bytes of the decoded graph, of a clone of its
objects' fields and of their conversion, and checks the round trip on every
object. Whether the readers move onto Fv is decided by its rows on the issue.
… probes, Fv::from_pairs builds an object from pairs
# Conflicts:
#	probes/examples/probe_1694_compact_graph.rs
#	src/research/graph_value.rs
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 12, 2026 03:42
@DrunkOnJava
DrunkOnJava merged commit 3312271 into main Nov 12, 2026
63 checks passed
@DrunkOnJava
DrunkOnJava deleted the perf/1694-fv-graphs branch November 12, 2026 03:54
DrunkOnJava added a commit to puzzbobb/rvt-rs that referenced this pull request Nov 12, 2026
…e report takes RE-445

Merging main brought DrunkOnJava#1800, which makes a decoded graph's fields rvt::research::graph_value::Fv: forge reads its format map through it. RE-439 is DrunkOnJava#1791's report on main, so this one is RE-445 (report, probe and every citation of the units reading).
DrunkOnJava pushed a commit that referenced this pull request Nov 12, 2026
…1797)

## Summary

Read a zero `RuledSurf` profile pointer as its separately saved point,
bounded to point/arc patches with a unit envelope and rectangular trim.
Bodies containing these patches are admitted only when their source
element record has `OST_DUCT_FITTING`.

On the public Revit 2023 basic MEP sample this recovers **105 duct
fittings**. The two sanitary terminals keep their record boxes and an
explicit refusal. Output remains `IfcTriangulatedFaceSet`.

## Motivation

One shared pointer rule recovers measured bodies without
element-specific decoders. RE-443 records the public file, streams,
record hashes, offsets, bytes and values. The body category restriction
follows the review of `5a0f8d1f`: the terminals miss the strict
native-reference threshold even with fine tessellation.

## Changes

- Merge upstream `97397b9e`, preserving its project-unit and type-layer
changes and both independent reconnaissance addenda. The comparisons
below were rerun against that refreshed base.
- Read `m_Point1`/`m_Point2` only for a zero profile pointer, including
the limiting pole normal and collapsed rectangular trim side. Both-null
profiles, missing/invalid points, unresolved nonzero pointers, other
curve combinations, non-unit envelopes and other trims remain refused.
- Keep one cell along the straight generator, the reviewed arc grid and
all trim knots. This revision changes no tessellation rule or positive
accuracy bound.
- Gate body admission using the source `BuiltInCategory` from the cached
production walk, independently of IFC class or fixture ids.
Unknown/conflicting categories fail closed. Other complete bodies
containing these patches retain their boxes with `collapsed ruled
profile outside the measured duct fittings`; already-partial bodies
retain their existing decoder refusal.
- Move terminals 543319 and 593903 from positive targets to explicit
box/refusal controls. Add a real-file control that changes all 105
fittings' IFC classes to proxies and both terminals' classes to duct
fittings: the source categories still decide admission.
- Update RE-443, the manifest, status, support notes, reconnaissance
addendum and changelog to the narrower scope and measured costs.

## Screenshots or output samples

Local exports against base `97397b9e`, with deterministic headers:

| Export | Recovered fittings | Triangles in those fittings | IFC bytes:
base → new head |
|---|---:|---:|---:|
| Basic MEP 2023 | 105 | 64,380 | 101,091,346 → 105,006,306 |
| Basic MEP 2024 | 105 | 64,380 | 103,550,587 → 107,465,590 |
| Snowdon HVAC 2024 | 32 | 5,856 | 65,514,494 → 65,858,488 |

The MEP fittings average 613.143 triangles, maximum 636. HVAC averages
183, maximum 212. Compared with `5a0f8d1f`, exactly the two terminals
return to boxes on each locally checked MEP save; all 105 fitting
representations and all placements are unchanged. HVAC, architectural
basic 2024 and the BIM4LCA concrete office IFCs are byte-identical to
that head.

Local native-reference figures from RE-443:

| Native reference tessellation | Fittings | Maximum sampled two-way
distance | Maximum volume difference |
|---|---:|---:|---:|
| Default, primary | 105 | 0.696493 mm | 0.178479% |
| Fine, supplementary | 105 | 0.131137 mm | 0.019083% |

**Default: 0/105 pass the strict 0.001 ft threshold; fine: 105/105
pass.** Fine does not replace the default verdict. The two terminals
previously missed at 0.720662 mm with both settings and are now refused,
not accepted under a looser bound.

## Reproduction and evidence availability


[`research/collapsed-ruled.json`](https://github.com/BIM4GIB/rvt-rs/blob/abd1db62e4c5687cbdd7897ff27acd4e17198e04/research/collapsed-ruled.json)
pins the public Autodesk RVT, seven source records, 105 positive
targets, two refusal controls and reference hashes/bounds. The RVT is
also pinned in `research/autodesk-sample-projects.tsv` for Measure.

The public source suffices for the byte and category controls:

```sh
cargo build --locked --profile ci --bin rvt-ifc
cargo run --locked --profile ci -p rvt-probes --example probe_collapsed_ruled -- /path/to/rmebasicsampleproject.rvt
```

Native scoring additionally requires the local **not-shared** archive.
Its redistribution terms are not established; there is no reference
download URL. Its unchanged SHA-256 is
`77322bed93a88f027f473cd71578fa27aaeabf9402eaab99a445a1a138d6f93a`
(52,288 bytes).

```sh
python3 -m pip install --require-hashes -r tools/ci/requirements-ifc.txt
python3 tools/re/replay_collapsed_ruled.py --work target/collapsed-ruled \
  --reference-zip /path/to/collapsed-ruled-native-v1.zip --fine
```

The archive still contains the original 107 references, but only the 105
fittings are positive geometry targets. Both terminals must retain boxes
with the exact refusal. Native comparison cannot be reproduced from
public downloads alone. Source/archive/member hashes are checked; a
failed replay cannot leave an old success result. No Revit automation is
included.

## Testing

- All required local workspace gates pass: formatting, clippy, strict
checking, rustdoc, all-target/all-feature build, doc tests,
real-file/CLI/contracts, MCP checks, examples and existing pure helpers.
No new unit tests are added.
- Against `97397b9e`, the 12-project comparison changes only the
intended 105 MEP representations. Eight other project IFCs are
byte-identical; three change only the established 6, 9 and 15 refusal
notes.
- All six REV/ARC fixture IFCs remain byte-identical, including
partial-arc refusals. Source hashes are unchanged.
- The focused comparison covers MEP 2023/2024, HVAC 2024, architectural
basic 2024 and the office; its results are above.
- All 608 graph refusal controls, 105 fitting/2 terminal IFC-class
override controls and both terminal body-refusal checks pass. Native
replay passes the existing default/fine regression bounds for all 105
fittings.
- The merged tree was checked against upstream `97397b9e` across the 12
projects, six families and three additional focused projects (21
distinct inputs). All five focused IFC exports are byte-identical to
`070a1436`, and the full native replay reproduces its results exactly.
Documentation and measurement-claim checks pass.

These are local results. The maintainer's unfiltered Measure and
supplemental run passed the registered criteria on **the previous head
`5a0f8d1f`**, before this category restriction. A fresh unfiltered
Measure is required for this merged head, against `97397b9e`. Measure
has no native IFC oracle for these samples; the accuracy figures above
remain local RE-443 measurements.

## Audit honesty and contribution hygiene

No workflow, dependency, build-script or README change. No model or
native geometry archive is redistributed by this revision. The
contribution uses public RVT bytes, Revit's own IFC export and existing
rvt-rs readers/scorers; it includes no proprietary orchestration, SDK
source, decompiled internals or copied revit-ifc implementation. Code is
licensable under Apache-2.0.

## Breaking changes

None to the stable API.

## Related issues

RE-443, RE-430, #1737 and #1800.
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