Repository navigation
perf(parsing): isolate per-field parser helpers from enclosing NamedTuple/ViewType - #118
Open
clockblocker wants to merge 3 commits into
Open
clockblocker wants to merge 3 commits into
clockblocker wants to merge 3 commits into
Conversation
…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.
…and parsed-JSON test assertions
This was referenced Nov 27, 2026
feat(schema): add opt-in zero-bloat rfl::Metadata<T> for out-of-band field/struct documentation
#119
Open
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
Follow-up to munich-data-engineering#795 ("More optimizations; particularly for tuples") and munich-data-engineering#799 ("Avoid O(N^2) template instantiations in
no_duplicate_field_names") with zero public API changes.Real-world adoption of
reflect-cppon large configuration and RPC structs surfaced severe compile-time, symbol-table, and DWARF debug-info bloat:slang-server(production SystemVerilog LSP server with large LSP/config structs such asLspTypes.h/Config.cpp) saw measurable compile-time and.osize improvements from this change with zero source changes.transmission(81-fieldTorrentInfo/ 53-fieldSessionSetParamsJSON-RPC 2.0 structs),osmium-tool(23rfl::clicommand translation units), andccache(48-fieldConfigDataprototype) confirmed that per-field template instantiations carrying the entire enclosingNamedTuple<FieldTypes...>pack scale quadratically (What changed (all internal, zero public API changes)
rfl::parsing::detail):include/rfl/parsing/NamedTupleParser.hpp: extractwrite_named_tuple_field,build_named_tuple_field_schema,handle_missing_named_tuple_field,extract_schema_field_ptr, and scalar fast-pathto_default_genericas free helpers parameterized only by the individual field type — never the enclosingNamedTuple<FieldTypes...>pack.include/rfl/parsing/ViewReader.hpp&ViewReaderWithDefault.hpp: extractplacement_move_field,move_assign_field,assign_uninitialized_view_field,assign_default_view_field, and extra-field helpers parameterized only by field type (neverViewType).include/rfl/parsing/call_destructors_where_necessary.hpp: replacecall_destructor_on_one_if_necessary<ViewType, _size, _i>withdetail::destroy_field_if_set(bool, const OriginalType&)and skip trivially destructible types/C-arrays at compile time.include/rfl/internal/copy_flattened_tuple_to_named_tuple.hpp: inlinecopy_one_elementintocopy_flattened_tuple_to_named_tupleto eliminateFieldNames+ flattened tuple types.include/rfl/parsing/find_field_index.hpp):detail::FieldNameLookup<typename ViewType::Names>keyed only on therfl::Literal<names...>pack (independent of field value/wrapper types and shared acrossViewReader,ViewReaderWithDefault, readers, writers, and processors): linear scan for<= 8fields,constexpr> 8fields.include/rfl/internal/cpp20/num_fields.hpp):CountFieldsHelper::count_max_args_in_agg_init()with exponential + binary search (find_first_constructible+expand_and_search+binary_search_max) bounded cleanly bysizeof(T).Note: two internal-only symbols with no in-repo callers (
rfl::parsing::call_destructor_on_one_if_necessaryandrfl::internal::copy_one_element) were replaced by the isolated helpers above.Benchmark (
origin/main290bdb24vs this PR, AppleClang 17 arm64, median of 3 runs)48-field
ConfigDatastruct (read + write + JSON schema, zero user code changes):origin/main(290bdb24)-O0 -gDebug)-O0 -gDebug).osize-O0 -gDebug)__debug_str-O0 -gDebug)-O2 -gRelWithDebInfo)-O2 -gRelWithDebInfo).osize-O2 -gRelWithDebInfo)__textcode size-O2 -gRelWithDebInfo)Description<..., DefaultVal>(-O0 -gDebug)Description<..., DefaultVal>(-O0 -gDebug).osizeDescription<..., DefaultVal>(-O2 -gRelWithDebInfo)Description<..., DefaultVal>(-O2 -gRelWithDebInfo).osizeDescription<..., DefaultVal>(-O2 -gRelWithDebInfo)Testing
generic,json,json_c_arrays_and_inheritance,cli,env,xml): 661/661 passed under AppleClang 17-Wall -Werror+REFLECTCPP_STRICT_WARNINGS=ON.-std=c++20 -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Werrorfor all 7 modified/added headers.tests/json/test_parser_isolation_edge_cases.cppcoveringnum_fieldsbinary-search boundary cases, duplicate keys for both small (<= 8) and wide (> 8) structs withNoExtraFields/ExtraFields,to_default_genericscalar edge cases (uint64_t > INT64_MAX,char,bool,float,std::vector<std::string>,std::optional),Rename<..., DefaultVal<...>>, andAddStructName.