Repository navigation
perf(parsing): add type-erased descriptor-table core (TableStructParser) bypassing NamedTuple for aggregates - #125
Draft
clockblocker wants to merge 3 commits into
Draft
clockblocker wants to merge 3 commits into
clockblocker wants to merge 3 commits into
Conversation
…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.
…eld short-circuit, and trivial-dtor skip
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
Stacked on PR #118 (
perf-parser-symbol-isolation). Zero public API changes.Replaces the internal
NamedTuple<Field<StringLiteral, T>...>+ per-structNamedTupleParser/ViewReaderpath for aggregate structs with a type-erased descriptor-table core (TableStructParser):include/rfl/internal/DirectFieldNames.hpp):static constexpr std::array<char, N>+ sortedFieldNameEntrylookup table keyed only by(CleanT, DirectCasePipeline).rfl::Flatten<Sub>and all 5 built-in case-transform processors (SnakeCaseToCamelCase,SnakeCaseToPascalCase,CamelCaseToSnakeCase,SnakeCaseToKebabCase,ToAllCaps), preservingrfl::Renameand per-op"xml_content"semantics.T-parameterized view readers & shared drivers (include/rfl/parsing/TableStructParser.hpp):TableViewReader<R, W, ProcessorsType>,TableViewReaderWithDefault,TableViewReaderStripped, and the sharedread/write/to_schemadriver loops are instantiated once per(R, W, ProcessorsType)per TU rather than once per structT.next_idx_sequential-key cursor hint (O(1) on in-order keys, O(log N) binary-search fallback on out-of-order keys),found_count < sizemissing-field loop short-circuit,kHasNonTrivialDtorcleanup skip, and RAIIUninitFieldsGuardfor exception safety.rfl::ExtraFields,rfl::Flatten, C-arrays, inheritance,const/move-only/non-default-constructible members,env::Reader::field_names(),xmlis_view_reader_v, custom/external named readers (viaSizedTableViewReader), andHasNamedTupleFormatPolicyfallback for custom formats.NamedTuplereflection helpers:bind_to_tupleintoapply_to_fields(C++20 and C++26) and replacesHasDefaultVal<named_tuple_t<T>>with directapply_to_fieldsinspection.Benchmarks (AppleClang 17 arm64, median of 3 uncontended runs)
origin/main#118TableStructParsermaint_60_structs_tu(60 LSP structs, camelCase+DefaultIfMissing).ot_60_structs_tut_80_kebab(80 fields, kebab+DefaultIfMissing).ot_80_kebabt_48_desc(inlineDescription<..., DefaultVal>).ot_flatten_extra(Flatten+ExtraFields+ camelCase).oRuntime JSON throughput (
-O3, ns/op — lower is better):wide80_kebab_read:10,011 ns→1,725 ns(5.8× faster)wide48_read_default:3,714 ns→1,054 ns(3.5× faster)wide48_read:999 ns→1,131 ns(+13% vsmain, 1.9× faster than#118)wide48_write:1,138 ns→1,176 ns(+3.3% vsmain)person_write(3 fields):435 ns→437 ns(+0.5% vsmain)person_read(3 fields):396 ns→617 nsVerification
-fsanitize=undefined -fno-sanitize-recover=allacrossgeneric,json,json_c_arrays_and_inheritance,cli,env,xml, andboost_serialization.tests/json/test_descriptor_table_stress.cppandtests/json_c_arrays_and_inheritance/test_descriptor_table_c_arrays.cpp.-std=c++20 -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Werror.