Skip to content

perf(parsing): isolate per-field helpers in ViewReader and ViewReaderWithDefault - #234

Open
clockblocker wants to merge 1 commit into
queue/fix-extra-fields-key-collisionfrom
queue/perf-view-reader-isolation
Open

clockblocker wants to merge 1 commit into
queue/fix-extra-fields-key-collisionfrom
queue/perf-view-reader-isolation

Conversation

@clockblocker

@clockblocker clockblocker commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

AI-authored below this line.

Related munich-data-engineering/reflect-cpp#795 · Related munich-data-engineering/reflect-cpp#582 · Related munich-data-engineering/reflect-cpp#799

Stacked on: #221 (queue/fix-extra-fields-key-collision)

Problem

ViewReader and ViewReaderWithDefault instantiated per-field read, move, error, and extra-field helpers inside templates parameterized on the full ViewType.

Because every field's mangled symbol repeated the entire enclosing struct, wide structs suffered $O(N^2)$ symbol and DWARF bloat on the read path.

Before (O(N^2) read-side symbol & DWARF growth):
  ViewReader<R, W, ViewType, Ps>::assign_if_field_matches<i>  // repeats full ViewType per field
  ViewReader<R, W, ViewType, Ps>::move_field                  // duplicated per enclosing struct

After (O(N) isolated helpers, shared across structs):
  assign_uninitialized_view_field<R, W, FieldType, Ps>        // keyed on 1 field type only
  placement_move_field<Target, Source> / move_assign_field    // reused across all structs

Summary

  • Extracts per-field reading, placement-move, move-assign, cold error recording, and extra-field insertion into free templates decoupled from the enclosing ViewType.
  • Keeps linear field-name dispatch (<= 4 inline, > 4 out-of-line) without capture-lambda wrappers.
For Agents

…WithDefault

Lifts per-field parsing, placement-move, move-assign, error-recording, and
extra-field helpers out of `ViewReader<..., ViewType, ...>` and
`ViewReaderWithDefault<..., ViewType, ...>` into free function templates
parameterized only by each field's type (never the enclosing `ViewType`),
keeping linear field-name dispatch (inline for `size_ <= 4`, out-of-line for
wider structs) and the compile-time positional read fast path.

Parent: depends on `fix(parsing): capture input keys matching ExtraFields member name`
(preserving the `is != ViewType::pos_extra_fields()` guard). Independent of
`NamedTupleParser` helper isolation; wide-struct `FieldNameLookup` follows in
a dedicated child commit.

Judge polish applied:
- Zero `[[maybe_unused]]` annotations (per munich-data-engineering#582): unmatched-name handling
  dispatches directly into `handle_extra_field*` / `handle_no_extra_fields_error`
  with only the parameters used by each branch.

Follow-up to: munich-data-engineering#795, munich-data-engineering#799
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