Skip to content

Prototype zero-bloat metadata attachment and compile-time isolation for large structs #91

Done

Description

@clockblocker

Question

Can we prototype a zero-bloat metadata attachment mechanism (e.g., out-of-band traits/descriptions avoiding long StringLiteral NTTP mangling in Debug DWARF and/or explicit compile-time isolation boundaries) that dramatically reduces Debug .o size and compile time on large reflected structs without hurting ergonomics?

Prototype & Measurement Plan

  • Parent map: Map (Lane 1): Core Hygiene & Perf
  • Blocked by: Profile and root-cause 101 MiB Debug object-file and compile-time explosion on wrapper-annotated structs (consume its -ftime-trace and DWARF root-cause findings before coding).
  • Prototype on: showcase/all-lanes.
  • Measure against real Showcase Migration: ccache#2 config.cpp.o (baseline: 106.25 MB / ~101 MiB Debug .o, ~35s Debug compile on 48-field ConfigData). Target a dramatic reduction in both Debug .o size and compile time while keeping schema/CLI metadata intact.
  • Judges & landing: Run Judges (gemini-4-neon + claude-opus-5-5 high via antigravity delegates) on the prototype diff and measurements; if green, hand to coordinator to land on showcase/all-lanes.

Activity

  1. added
    wayfinder:prototype
    on Nov 27, 2026
  2. clockblocker commented on Nov 27, 2026

    @clockblocker
    OwnerAuthor

    Additional Measurement Target (clockblocker/transmission#1, 6478ae0d0):

    • In addition to ccache#2 (config.cpp.o), measure transmission/libtransmission/rpc-schema.h (TorrentInfo: 81 fields; SessionSetParams: 53 fields; baseline ~25–59s user compile time per RPC TU on AppleClang arm64 RelWithDebInfo, validating #799 / Wave 10 #61).
  3. clockblocker commented on Nov 27, 2026

    @clockblocker
    OwnerAuthor

    Recipient update: ccache has been retired as a Showcase Migration recipient (fork being deleted). Measure before/after Debug .o size and compile time against the self-contained 48-field rfl::Description<StringLiteral, DefaultVal<T>> repro from #90 plus transmission#1 and slang-server.

  4. clockblocker commented on Nov 27, 2026

    @clockblocker
    OwnerAuthor

    Active Regression Harness Target (clockblocker/slang-server#1, bf857f4, RelWithDebInfo):

    • Measure Lane 1 compile-time & binary-size fixes against slang-server (slang_server_obj_lib 590.8s vs 389.3s upstream baseline, SlangServer.cpp.o 177.6s vs 121.2s, reflectcpp_json.cpp.o 32.0s vs 19.4s, and bin/gen_config_schema 1.70 MiB vs 1.38 MiB +23.1% from to_schema<T, DefaultIfMissing> per-field to_generic instantiation).
  5. added 3 commits that reference this issue on Nov 27, 2026
  6. clockblocker commented on Nov 27, 2026

    @clockblocker
    OwnerAuthor

    Landed on showcase/all-lanes at b476c548 (f062a379 + 5a263019 + b476c548), reviewed and approved by dual independent Judges (claude-opus-5-5 high + gemini-4-neon high, both APPROVE WITH NITS after fixing all initial blockers and nits).

    Implemented

    1. Out-of-band zero-bloat metadata (include/rfl/Metadata.hpp):
      • rfl::FieldMeta (name, description, deprecation_message) and template <class T> struct rfl::Metadata {} supporting static constexpr contiguous ranges or out-of-line static std::span<const rfl::FieldMeta> fields() (guarded against dangling temporary returns via std::ranges::borrowed_range static_assert), plus optional struct-level description / description().
      • Exact wire-name matching takes precedence over pre-processor field names (including AddStructName prefix alignment); Avro and Cap'n Proto is_named_type unwrap Type::Description/Type::Deprecated cleanly; JSON Type::Deprecated preserves existing inline descriptions when description_ is empty.
    2. Large-struct compile-time & Debug .o isolation:
      • include/rfl/internal/cpp20/num_fields.hpp: $O(\log N)$ exponential + binary search in CountFieldsHelper with sizeof(T) upper-bound static_assert guard.
      • include/rfl/parsing/ViewReader.hpp, ViewReaderWithDefault.hpp, NamedTupleParser.hpp, Parser_default.hpp, call_destructors_where_necessary.hpp: extracted free per-field helpers (never parameterized by enclosing ViewType / FieldTypes...), replaced linear ViewReader fold dispatch with compile-time sorted binary-search NameEntry table, eliminated per-field lambdas in build_schema and deferred-default checks, and added scalar/std::vector<std::string>/std::optional fast path to_default_generic.
    3. Tests & Benchmark:
      • tests/json/test_metadata.cpp & tests/json_c_arrays_and_inheritance/test_c_array_schema_defaults.cpp — 465/465 targets, 0 warnings (-Wall -Werror, REFLECTCPP_STRICT_WARNINGS=ON), 1,093/1,093 CTests passing (1,088 runtime + 5 compile-fail/should-compile).
      • bench/large_struct_metadata/ (bench_48_desc.cpp, bench_48_metadata.cpp, bench_48_plain.cpp, README.md).

    Measured Results (AppleClang 17 arm64)

    Benchmark Mode Wall (s) .o (MiB) __debug_str (MiB) Mangled syms (MiB) __text (MiB)
    bench_48_desc (before #91) -O0 -g 5.75 148.71 82.65 62.77 0.66
    bench_48_desc (after #91, unchanged) -O0 -g 4.78 (-16.9%) 85.57 (-42.5%) 50.24 (-39.2%) 32.13 (-48.8%) 0.66
    bench_48_metadata (rfl::Metadata<T>) -O0 -g 2.76 (-52.0%) 13.21 (-91.1%) 7.31 (-91.2%) 3.61 (-94.2%) 0.47
    bench_48_plain (before → after) -O0 -g 2.78 → 2.65 19.12 → 13.19 (-31.0%) 10.19 → 7.30 6.63 → 3.60 (-45.7%) 0.45 → 0.47
    bench_48_desc (before #91) -O2 -g 6.98 48.25 35.40 10.11 0.15
    bench_48_desc (after #91, unchanged) -O2 -g 6.49 (-7.0%) 25.30 (-47.6%) 19.94 (-43.7%) 2.58 (-74.5%) 0.15
    bench_48_metadata (rfl::Metadata<T>) -O2 -g 3.68 (-47.3%) 5.13 (-89.4%) 3.35 (-90.5%) 0.25 (-97.5%) 0.08 (-46.7%)
    bench_48_plain (before → after) -O2 -g 3.95 → 3.69 8.04 → 5.11 (-36.4%) 4.80 → 3.35 1.29 → 0.25 (-80.6%) 0.12 → 0.08

    slang-server key TUs (-O2 -g, zero source changes):

    • SlangServer.cpp: 60.58 → 57.94 MiB (−4.4% .o, −24.0% mangled, 33.39s → 33.15s)
    • reflectcpp_json.cpp: 12.07 → 11.19 MiB (−7.3% .o, −34.6% mangled)
    • Config.cpp: 13.01 → 12.03 MiB (−7.5% .o, −39.2% mangled, 4.86s → 4.72s)
    • gen_config_main.cpp: 9.46 → 8.17 MiB (−13.6% .o, −67.9% mangled)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wayfinder:prototype

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions