Skip to content

perf(parsing): isolate per-field parser helpers from enclosing NamedTuple/ViewType - #118

Closed
clockblocker wants to merge 4 commits into
mainfrom
perf-parser-symbol-isolation
Closed

clockblocker wants to merge 4 commits into
mainfrom
perf-parser-symbol-isolation

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Follow-up to munich-data-engineering#795 and munich-data-engineering#799 with zero public API changes. Isolates per-field parsing, writing, schema, and destruction helpers from enclosing NamedTuple<FieldTypes...> / ViewType packs so symbol-table and DWARF debug-info size stop scaling quadratically ($O(N^2)$) with struct field count.

Compile-time & binary impact

48-field ConfigData struct (read + write + JSON schema, AppleClang 17 arm64, zero user code changes):

Build Wall time .o size Symbol-name bytes
Debug (-O0 -g) 2.23 s → 2.02 s (-9.4%) 13.85 → 9.00 MiB (-35.0%) 4.49 → 2.17 MiB (-51.6%)
RelWithDebInfo (-O2 -g) 3.08 s → 2.71 s (-12.0%) 6.49 → 4.15 MiB (-36.0%) 1.03 → 0.13 MiB (-87.4%)

Key details

  • Extracts per-field NamedTupleParser, ViewReader, ViewReaderWithDefault, and destructor helpers parameterized only by the individual field type rather than the full enclosing NamedTuple/ViewType pack, skipping trivially destructible fields at compile time.
  • Shares field-name lookup (FieldNameLookup) across readers, writers, and processors keyed only on the field-name Literal pack (linear scan for ≤ 8 fields, constexpr heapsort + binary search above 8).
  • Replaces linear aggregate field-count probing in cpp20::num_fields with $O(\log N)$ exponential + binary search.

AI-authored.

…uple/ViewType and optimize num_fields/ViewReader lookup
… Judge nits

- Restore rfl::ExtraFields + schemaful::IsSchemafulReader static_assert guards in
  ViewReader::read(integral_constant) and assign_to_matching_index (chained with
  else if constexpr for NoExtraFields).
- Factor field-name lookup into shared detail::FieldNameLookup<ViewType::Names>
  (linear scan for <=8 fields, constexpr std::sort + binary search for >8 fields).
- Move new free helpers into rfl::parsing::detail and qualify internal calls to
  avoid ADL collisions.
- Guard empty-struct size_ > 0 paths, tighten direct standard includes, drop
  unreachable set_schema_default_value recursion and unnecessary RFL_ALWAYS_INLINE.
- Add edge-case unit tests in tests/json/test_parser_isolation_edge_cases.cpp.
clockblocker added a commit that referenced this pull request Nov 29, 2026
…tors, and flatten

Moves per-field serialization, schema building, missing-field handling, and
destructor helpers out of `NamedTupleParser<..., FieldTypes...>` into free
templates parameterized only on each field's type (never the enclosing
`NamedTuple` pack), and skips instantiating destructors for trivially
destructible fields/arrays. Eliminates O(N^2) symbol-table and DWARF growth on
wide structs with zero public API changes.

Split from parser-symbol-isolation (#118) into an independent, reviewable chunk
(no lookup algorithm changes; `to_default_generic` fast-path and `ViewReader`
isolation follow in separate commits).

Follow-up to: munich-data-engineering#795, munich-data-engineering#799
Downstream receipts (combined Wave 1 N=3 interleaved medians vs main):
- hudson-trading/slang-server (`SlangServer.cpp` Debug): -15.0% `.o` Clang, -9.6% GCC, -6.1% wall
- openmoq/moqx (`Loader.cpp` Debug): -17.5% `.o` Clang, -13.5% GCC, -4.4% wall
- FANUC-CORPORATION/fanuc_driver (`serialization.cpp` Debug): -27.1% `.o` Clang, -9.9% wall
- games-on-whales/wolf (`unix_socket_server.cpp` Release): -19.4% `.o` Clang
clockblocker added a commit that referenced this pull request Nov 29, 2026
…tors, and flatten

Moves per-field serialization, schema building, missing-field handling, and
destructor helpers out of `NamedTupleParser<..., FieldTypes...>` into free
templates parameterized only on each field's type (never the enclosing
`NamedTuple` pack), and skips instantiating destructors for trivially
destructible fields/arrays. Eliminates O(N^2) symbol-table and DWARF growth on
wide structs with zero public API changes.

Split from parser-symbol-isolation (#118) into an independent, reviewable chunk
(no lookup algorithm changes; `to_default_generic` fast-path and `ViewReader`
isolation follow in separate commits).

Follow-up to: munich-data-engineering#795, munich-data-engineering#799
Downstream receipts (combined Wave 1 N=3 interleaved medians vs main):
- hudson-trading/slang-server (`SlangServer.cpp` Debug): -15.0% `.o` Clang, -9.6% GCC, -6.1% wall
- openmoq/moqx (`Loader.cpp` Debug): -17.5% `.o` Clang, -13.5% GCC, -4.4% wall
- FANUC-CORPORATION/fanuc_driver (`serialization.cpp` Debug): -27.1% `.o` Clang, -9.9% wall
- games-on-whales/wolf (`unix_socket_server.cpp` Release): -19.4% `.o` Clang
clockblocker added a commit that referenced this pull request Nov 29, 2026
…tors, and flatten

Moves per-field serialization, schema building, missing-field handling, and
destructor helpers out of `NamedTupleParser<..., FieldTypes...>` into free
templates parameterized only on each field's type (never the enclosing
`NamedTuple` pack), and skips instantiating destructors for trivially
destructible fields/arrays. Eliminates O(N^2) symbol-table and DWARF growth on
wide structs with zero public API changes.

Split from parser-symbol-isolation (#118) into an independent, reviewable chunk
(no lookup algorithm changes; `to_default_generic` fast-path and `ViewReader`
isolation follow in separate commits).

Follow-up to: munich-data-engineering#795, munich-data-engineering#799
Downstream receipts (combined Wave 1 N=3 interleaved medians vs main):
- hudson-trading/slang-server (`SlangServer.cpp` Debug): -15.0% `.o` Clang, -9.6% GCC, -6.1% wall
- openmoq/moqx (`Loader.cpp` Debug): -17.5% `.o` Clang, -13.5% GCC, -4.4% wall
- FANUC-CORPORATION/fanuc_driver (`serialization.cpp` Debug): -27.1% `.o` Clang, -9.9% wall
- games-on-whales/wolf (`unix_socket_server.cpp` Release): -19.4% `.o` Clang
clockblocker added a commit that referenced this pull request Nov 30, 2026
…tors, and flatten

Moves per-field serialization, schema building, missing-field handling, and
destructor helpers out of `NamedTupleParser<..., FieldTypes...>` into free
templates parameterized only on each field's type (never the enclosing
`NamedTuple` pack), and skips instantiating destructors for trivially
destructible fields/arrays. Eliminates O(N^2) symbol-table and DWARF growth on
wide structs with zero public API changes.

Split from parser-symbol-isolation (#118) into an independent, reviewable chunk
(no lookup algorithm changes; `to_default_generic` fast-path and `ViewReader`
isolation follow in separate commits).

Follow-up to: munich-data-engineering#795, munich-data-engineering#799
Downstream receipts (combined Wave 1 N=3 interleaved medians vs main):
- hudson-trading/slang-server (`SlangServer.cpp` Debug): -15.0% `.o` Clang, -9.6% GCC, -6.1% wall
- openmoq/moqx (`Loader.cpp` Debug): -17.5% `.o` Clang, -13.5% GCC, -4.4% wall
- FANUC-CORPORATION/fanuc_driver (`serialization.cpp` Debug): -27.1% `.o` Clang, -9.9% wall
- games-on-whales/wolf (`unix_socket_server.cpp` Release): -19.4% `.o` Clang
clockblocker added a commit that referenced this pull request Dec 1, 2026
…tors, and flatten

Moves per-field serialization, schema building, missing-field handling, and
destructor helpers out of `NamedTupleParser<..., FieldTypes...>` into free
templates parameterized only on each field's type (never the enclosing
`NamedTuple` pack), and skips instantiating destructors for trivially
destructible fields/arrays. Eliminates O(N^2) symbol-table and DWARF growth on
wide structs with zero public API changes.

Split from parser-symbol-isolation (#118) into an independent, reviewable chunk
(no lookup algorithm changes; `to_default_generic` fast-path and `ViewReader`
isolation follow in separate commits).

Follow-up to: munich-data-engineering#795, munich-data-engineering#799
Downstream receipts (combined Wave 1 N=3 interleaved medians vs main):
- hudson-trading/slang-server (`SlangServer.cpp` Debug): -15.0% `.o` Clang, -9.6% GCC, -6.1% wall
- openmoq/moqx (`Loader.cpp` Debug): -17.5% `.o` Clang, -13.5% GCC, -4.4% wall
- FANUC-CORPORATION/fanuc_driver (`serialization.cpp` Debug): -27.1% `.o` Clang, -9.9% wall
- games-on-whales/wolf (`unix_socket_server.cpp` Release): -19.4% `.o` Clang
@clockblocker

Copy link
Copy Markdown
Owner Author

Superseded by split queue PRs on the PR-keyed upstream queue (#209):

Closing this bundled PR.

clockblocker added a commit that referenced this pull request Dec 2, 2026
…tors, and flatten

Moves per-field serialization, schema building, missing-field handling, and
destructor helpers out of `NamedTupleParser<..., FieldTypes...>` into free
templates parameterized only on each field's type (never the enclosing
`NamedTuple` pack), and skips instantiating destructors for trivially
destructible fields/arrays. Eliminates O(N^2) symbol-table and DWARF growth on
wide structs with zero public API changes.

Split from parser-symbol-isolation (#118) into an independent, reviewable chunk
(no lookup algorithm changes; `to_default_generic` fast-path and `ViewReader`
isolation follow in separate commits).

Follow-up to: munich-data-engineering#795, munich-data-engineering#799
Downstream receipts (combined Wave 1 N=3 interleaved medians vs main):
- hudson-trading/slang-server (`SlangServer.cpp` Debug): -15.0% `.o` Clang, -9.6% GCC, -6.1% wall
- openmoq/moqx (`Loader.cpp` Debug): -17.5% `.o` Clang, -13.5% GCC, -4.4% wall
- FANUC-CORPORATION/fanuc_driver (`serialization.cpp` Debug): -27.1% `.o` Clang, -9.9% wall
- games-on-whales/wolf (`unix_socket_server.cpp` Release): -19.4% `.o` Clang
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