Repository navigation
Description
Part of #138
Popularity: 1/7 corpus consumers (slang-server)
Related issues
- Related fork issues: Map (Lane 1): Core Hygiene & Perf #85 (
Map (Lane 1): Core Hygiene & Perf), Profile and root-cause 101 MiB Debug object-file and compile-time explosion on wrapper-annotated structs #90 (Profile and root-cause 101 MiB Debug object-file and compile-time explosion), Prototype zero-bloat metadata attachment and compile-time isolation for large structs #91 (Prototype zero-bloat metadata attachment and compile-time isolation for large structs).
Observed Downstream Workarounds (hudson-trading/slang-server @ 1b413a46)
slang-server models the full LSP 3.17/3.18 wire surface (~7,000 lines of structs, std::optional, rfl::Variant, rfl::Literal, rfl::Box) in include/lsp/LspTypes.h (which includes <rfl/json.hpp>) and instantiates rfl::from_generic / rfl::to_generic across dozens of registered LSP handlers inside SlangServer::getInitialize:
- Mandatory precompiled header around
LspTypes.h(CMakeLists.txt#L381-L382):target_precompile_headers(slang_server_obj_lib PRIVATE "${PROJECT_SOURCE_DIR}/include/lsp/LspTypes.h")
- Explicit MSVC
/bigobjflag (CMakeLists.txt#L120-L123):if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") add_compile_options(/utf-8 /bigobj /permissive-) add_compile_options(/Zc:preprocessor) endif()
- Explicit compile-time pain TODO in
SlangServer::getInitialize(src/SlangServer.cpp#L61-L62):lsp::InitializeResult SlangServer::getInitialize(const lsp::InitializeParams& params) { // TODO: may want to use raw strings here bc all these types make compile time longer
Root Cause & Suggested Direction
Deeply nested protocol structs containing many std::optional, rfl::Variant, and rfl::Description fields trigger heavy template instantiation and large object files when parsed/serialized in a single translation unit.
Continue the compile-time & object-size reduction track in #85 / #90 / #91 (reducing template instantiation depth for Variant / optional / Generic / to_named_tuple, and supporting explicit out-of-line parser/writer instantiation or compile-time isolation for large schema headers).
Upstream Overlap
- rfl::to_generic is more than ten times slower than rfl::json::write. For a requirement like JSON-RPC, how can it be implemented better? munich-data-engineering/reflect-cpp#368 (open, partial) — "rfl::to_generic is more than ten times slower than rfl::json::write. For a requirement like JSON-RPC, how can it be implemented better?" (directly overlaps
slang-server's JSON-RPCto_generic/from_genericbottleneck and raw-string escape hatch TODO; maintainer noted "this is tricky"). - Recursive error in
internal::no_duplicate_field_namesmunich-data-engineering/reflect-cpp#350 (open, partial; addressed by merged PR Avoid O(N^2) template instantiations in no_duplicate_field_names munich-data-engineering/reflect-cpp#799, post-slang-serverpin) — Recursive template complexity inno_duplicate_field_nameson large structs/enums;#799eliminated the$O(N^2)$ template instantiations. - Excessively high compile times munich-data-engineering/reflect-cpp#86 (closed/completed, partial, with merged PRs
#120,#136,#204,#211, plus post-pin compile-time PRs Some compile-time optimizations; particularly for larger structs munich-data-engineering/reflect-cpp#675 and Compile-time optimizations for rfl::Generic munich-data-engineering/reflect-cpp#698) — Historical high compile-time issue; maintainer recommended isolating serialization into separate.cpptranslation units.
Activity
[-]Compile-Time/Perf (slang-server): heavy rfl instantiation on LspTypes.h forces PCH, /bigobj, and prompts raw-string escape hatch TODO[/-][+]Compile-Time/Perf: heavy rfl instantiation on LspTypes.h forces PCH, /bigobj, and prompts raw-string escape hatch TODO[/+]clockblocker commentedon Nov 29, 2026
Tracking & PR Cross-Reference
Status: Partially addressed by Wave 1 compile-time / object-size PRs in
upstream-queue(Draft PR #191); deeper core rewrite parked.upstream-queue(Draft PR Upstream PR Queue (sorted by mergeability score) #191):210d6715, score 92/100, fork PR Trim <functional>, <sstream>, and unused <map> from thin wrapper and validator headers #135): trim<functional>,<sstream>, and unused<map>from thin headers (~40k fewer preprocessed lines).eac74650, score 85/100, split 2/5 of fork PR perf(parsing): isolate per-field parser helpers from enclosing NamedTuple/ViewType #118): isolate per-field helpers inNamedTupleParser, destructors, and flatten.2abb51f9, score 84/100, fork PR Avoid instantiating named_tuple_t<T> in HasDefaultVal via apply_to_fields #126):apply_to_fieldsavoidingNamedTupleinstantiation inHasDefaultVal.065d7f7d, score 83/100, Wave 1B / branchwave1/num-fields-binary-search):cpp20::num_fields.4fb6d2ee, score 83/100, split 3/5 of fork PR perf(parsing): isolate per-field parser helpers from enclosing NamedTuple/ViewType #118, parent Rank Say why default construction failed when reading a struct with defaults #11): isolate per-field helpers inViewReaderandViewReaderWithDefault.cac875c5, score 82/100, split 4/5 of fork PR perf(parsing): isolate per-field parser helpers from enclosing NamedTuple/ViewType #118, parent Rank Add --help/--version handling to rfl::cli and cover the CLI stack in rfl::cli::usage #15): fast-path scalar defaults inNamedTupleParser::to_schema.5eb2a956, score 72/100, split 5/5 of fork PR perf(parsing): isolate per-field parser helpers from enclosing NamedTuple/ViewType #118, parent Rank Write optional fields wrapped in rfl::Short or rfl::Positional #19):FieldNameLookupcursor-hint + binary-search field dispatch.643fb431, score 71/100, fork PR Add rfl::json::Raw for passthrough raw JSON subtrees #67, refs upstreammunich-data-engineering/reflect-cpp#368):rfl::json::Rawpassthrough raw JSON values (directly addressesslang-server's raw-string escape hatch TODO).TableStructParsercore rewrite — fork Draft PR perf(parsing): add type-erased descriptor-table core (TableStructParser) bypassing NamedTuple for aggregates #125 (branchesperf-descriptor-table-core/perf/table-struct-parser).