Make typed struct construction trim-friendly - #65
Merged
Conversation
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.
This was referenced Aug 5, 2026
Closed
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
FieldSink{T}Val{T}token and a bounded generated field assignment ladderignore=truetags consistently during constructionWhy
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_workloadpattern.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.
:hotworkload: 58.07 seconds and a 40.5 MB DTO cacheSmall 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
Full downstream application trim validation remains a pre-merge integration gate for the coupled change.
Co-authored by Codex