Skip to content

perf(parsing): add type-erased descriptor-table core (TableStructParser) bypassing NamedTuple for aggregates - #125

Draft
clockblocker wants to merge 3 commits into
perf-parser-symbol-isolationfrom
perf-descriptor-table-core
Draft

clockblocker wants to merge 3 commits into
perf-parser-symbol-isolationfrom
perf-descriptor-table-core

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stacked on #118. Replaces the per-struct NamedTuple<Field<StringLiteral, T>...> / ViewReader instantiation path for aggregate structs with a type-erased descriptor-table core (TableStructParser). Zero public API changes.

Compile-time & runtime impact

AppleClang 17 arm64 (origin/main → TableStructParser):

Benchmark Debug .o size RelWithDebInfo wall time
60 LSP structs (camelCase + DefaultIfMissing) 223.09 → 5.15 MiB (-97.7%) 31.53 s → 5.99 s (-81.0%)
80-field struct (kebab-case + DefaultIfMissing) 59.90 → 1.48 MiB (-97.5%) 7.12 s → 2.03 s (-71.5%)
48-field inline Description<..., DefaultVal> 102.88 → 15.25 MiB (-85.2%) —
Flatten + ExtraFields + camelCase 22.23 → 3.50 MiB (-84.3%) —

Runtime -O3 JSON reads are 3.5–5.8× faster on wide structs (wide80_kebab_read: 10.0 → 1.7 µs; wide48_read_default: 3.7 → 1.1 µs) and near parity on writes (+0.5–3.3%).

Key details

  • Stores flattened field names in a value-level constexpr buffer + sorted lookup table keyed only by (CleanT, DirectCasePipeline), supporting recursive Flatten, Rename, and all 5 built-in case-transform processors.
  • Instantiates TableViewReader* and read/write/to_schema drivers once per (Reader, Writer, ProcessorsType) per TU instead of once per struct, using an $O(1)$ sequential cursor hint with $O(\log N)$ binary-search fallback.
  • Supports ExtraFields, Flatten, C-arrays, inheritance, const/move-only/non-default-constructible members, env::Reader, XML, and custom named readers (with HasNamedTupleFormatPolicy fallback).
  • Generalizes bind_to_tuple into apply_to_fields (C++20 & C++26) and drops named_tuple_t<T> from HasDefaultVal<T>.

AI-authored.

…er) bypassing NamedTuple for aggregates

- Add value-level DirectFieldNames<T, CasePipeline> with packed null-terminated
  char storage, sorted binary-search lookup, recursive rfl::Flatten support, and
  all 5 built-in case-transform processors (preserving xml_content and Rename).
- Add non-T-parameterized TableViewReader / TableViewReaderWithDefault and
  shared driver loops in TableStructParser, eliminating NamedTuple, Tuple, and
  per-struct ViewReader/read_object instantiations across wide structs and
  multi-struct TUs.
- Generalize bind_to_tuple into apply_to_fields (C++20 and C++26) and replace
  HasDefaultVal<named_tuple_t<T>> with direct apply_to_fields inspection.
- Support rfl::ExtraFields, rfl::Flatten, custom/external named Readers (via
  SizedTableViewReader), env::Reader field_names(), xml is_view_reader_v, and
  RAII UninitFieldsGuard exception safety.
- Add UBSan stress and regression test suites covering lifetime tracking,
  partial destruction, throwing readers, non-standard-layout aggregates,
  C-arrays, inheritance, Flatten, ExtraFields, and case-transform pipelines.
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