Skip to content

Make typed struct construction trim-friendly - #65

Merged
quinnj merged 1 commit into
mainfrom
codex/table-make-redesign
Aug 5, 2026
Merged

Make typed struct construction trim-friendly#65
quinnj merged 1 commit into
mainfrom
codex/table-make-redesign

Conversation

@quinnj

@quinnj quinnj commented Aug 5, 2026

Copy link
Copy Markdown
Member

Summary

  • route struct-shaped construction through a compact FieldSink{T}
  • use a concrete Val{T} token and a bounded generated field assignment ladder
  • preserve ordinary constructors, custom styles, hooks, defaults, tags, and mutable construction
  • add an opt-in ordered-source cursor without exposing JSON-specific key behavior
  • apply inbound ignore=true tags consistently during construction
  • raise the package version to 2.8.3 for the companion JSON.jl integration

Why

This keeps typed construction statically reachable for trim compilation without adding a second interpreter, a package-specific hot registry, or per-struct annotations. It still uses normal Julia specialization per target type. Applications can persist those specializations with the standard PrecompileTools.@compile_workload pattern.

This is a smaller alternative to #63. The companion JSON.jl change is JuliaIO/JSON.jl#475. It requires StructUtils 2.8.3 and should land after this PR.

Performance

The coupled JSON/StructUtils audit used Julia 1.12.6 and one pinned Parsers revision across every variant.

  • 100 mixed DTO first-use time: 9.78 seconds versus 16.48 seconds upstream
  • standard workload precompile: 16.44 seconds and a 10.1 MB DTO cache
  • the same old :hot workload: 58.07 seconds and a 40.5 MB DTO cache
  • 100 DTO parses after restart: 2.1 milliseconds with the standard workload
  • annotation-free 100-DTO trim executable: 9.96-second build, 3.9 MB binary, and successful execution

Small typed structs remain 10-16% slower than the current JSON/StructUtils pair. Bulk vectors of small structs remain 16-24% slower. Larger nested and ordered-wide cases improve by 3-31x. These tradeoffs are documented for review rather than hidden in an aggregate score.

Validation

  • StructUtils construction, defaults, tags, custom styles, hooks, mutable targets, and table extensions
  • inbound-ignore behavior and alias handling
  • coupled JSON public API and semantic matrix
  • safe-trim construction lanes with zero per-struct annotations
  • 100-type compile-scaling and precompile-persistence tests

Full downstream application trim validation remains a pre-merge integration gate for the coupled change.

Co-authored by Codex

Replace the closure-based field loop with linear generated match and assignment ladders. Preserve constructors, custom make dispatch, tags, aliases, defaults, and inbound ignore semantics. Add focused regression and trim coverage.
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