Repository navigation
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
Merged
Conversation
…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.
DrunkOnJava
marked this pull request as ready for review
November 12, 2026 01:21
8 of 10 tasks
DrunkOnJava
added a commit
that referenced
this pull request
Nov 12, 2026
…he decoder to its readers (#1694) (#1800) ## 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 #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 - [x] 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). - [x] Row 1, [#1694 comment 6812365949](#1694 (comment)): Measure [43144800763](https://github.com/DrunkOnJava/rvt-rs/actions/runs/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](#1694 (comment))). - [x] Row 3, same comment: Measure [43144804167](https://github.com/DrunkOnJava/rvt-rs/actions/runs/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](#1694 (comment))). A measured negative, reported as one; the dhat run registered next names what is left. ## Audit-honesty checklist - [x] No capability claim: a memory change inside the research modules. The changelog entry is added with the measured figures, after the runs. - [x] No reverse-engineering finding. - [x] No emojis, no private paths in committed files. ## Legal and contribution hygiene - [x] Apache-2.0. No Autodesk proprietary source, internals or NDA material. - [x] 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.
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
A compact value for a decoded graph's fields,
rvt::research::graph_value::Fv, and a probe that sizes it on real graphs.Fvholds what aserde_json::Valueholds with an object's values in one slice and its field names once for every object that has them;Fv::from_jsonandFv::to_jsonare exact (number kinds, key order and all). Nothing reads a graph through it yet: this prices the one lever left on #1694 before a reader is touched, and the readers move only if the probe's rows hold. It changes no export.Motivation
#1694: after levers (c) (#1717) and (e) (#1731), 75% to 87% of the saved-mesh pass's peak is decoded graph nodes, and what makes them large is the container: a
BTreeMapleaf is 631 bytes however few fields it holds, every key is a heapString, and a pointer (an object of three numbers) costs about 730 bytes. Levers (d) and (f) keptserde_json's object map and were worth 3% to 8% of the export's peak, so the issue left a typed compact value, "a refactor of its own". The rows it must meet are on the issue before the probe runs: #1694 (comment)Changes
src/research/graph_value.rs(new, declared insrc/research.rs):Fv(null, bool,U64,I64,F64, string, array, object),Obj,NameTable(the lists of names objects share),Fv::from_json,Fv::to_json,Fv::get,Fv::node_count. Failure-first tests of the pure conversion: a number keeps the kindserde_jsonheld it in (1and1.0differ,u64::MAX,i64::MIN, negative zero), an object keepsserde_json's key order, empty and odd containers and strings survive, objects with the same names share one list and others do not, two lists with the same letters are two lists,getandnode_count.probes/examples/probe_1694_compact_graph.rs(new): decodes every native record of a file one at a time, counts the live heap bytes of the decoded graph, of a clone of its objects'fields(a floor for today's, since a clone is built whole) and of their conversion, and compares the round trip on every object; exit status 1 where it differs.Testing
-D warnings, the lib tests including the six conversion tests).full / CI passedon the final head (nothing uses the module, so the exports cannot move).Fvholds 0.157 to 0.185 of a clone of today's heap bytes (0.20 asked), 4,276,161 objects round-trip with 0 mismatches.Audit-honesty checklist
Legal and contribution hygiene
Breaking changes
None.
unstable-researchonly.Related issues
Refs #1694.