Skip to content

perf: share wrapper field metadata across variants - #41

Draft
felixge wants to merge 2 commits into
masterfrom
perf/shared-wrapper-metadata
Draft

felixge wants to merge 2 commits into
masterfrom
perf/shared-wrapper-metadata

Conversation

@felixge

@felixge felixge commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Summary

Related to #40.

  • Nest the writer and hook fields in a shared, value-embedded rwFields type, so all 512 wrapper variants describe one embedded field instead of repeating 14 field descriptors.
  • Preserve wrapper methods, exact interface sets, hook initialization, memory layout, and the single state allocation.
  • Add a layout regression test and a reproducible release/local binary-size comparison experiment.

This is a metadata-only improvement. It does not include method promotion or metrics-specific initialization, and does not eliminate the full size increase reported in #40.

Binary-size results

Same HTTP server before/after, darwin/arm64, CGO disabled, with identical module replacement and build settings:

Toolchain Default bytes saved Stripped bytes saved
Go 1.26.7 232,144 (2.35%) 232,192 (3.39%)
Go 1.27.1 232,160 (2.30%) 232,160 (3.33%)

Machine-code section sizes and allocation counts are unchanged. Full reproduction instructions and measurements are in experiments/binary-size/README.md.

Validation

  • go test ./... on Go 1.26.7 and Go 1.27.1, including all 512 interface combinations.
  • go test -race ./... and go vet ./... on Go 1.27.1.
  • Allocation benchmarks: Wrap remains 128 B/1 allocation; CaptureMetrics remains 417 B/13 allocations.
  • Regeneration consistency, shell syntax, and diff checks.

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