Read the versioners' version options off instance variables - #2923
Closed
ericproulx wants to merge 1 commit into
Closed
ericproulx wants to merge 1 commit into
ericproulx wants to merge 1 commit into
Conversation
`vendor`, `strict`, `parameter` and `cascade` were delegated through `version_options` into `config`, so each read went two Forwardable frames and two Data readers deep, about 150 ns, for a value fixed when the middleware was built. The header versioner reads `vendor` and `strict` on every request, the accept-version one `strict`, and the param one `parameter` twice. They are now plain readers over instance variables set in `#initialize`, the pattern the formatter adopted for its own options. The extra variables ride along on the per-request `dup`; the path versioner, which reads none of them, stays in the same object slot. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ericproulx
force-pushed
the
perf/versioner-options-ivars
branch
from
September 10, 2026 19:18
502cbad to
58ef5dd
Compare
Danger ReportNo issues found. |
5 tasks
Contributor
Author
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
Versioner::Basedelegatedcascade,parameter,strictandvendorthroughversion_optionsintoconfig, so each read went two Forwardable frames and two Data readers deep (about 150 ns) for a value fixed when the middleware was built. The header versioner readsvendorandstricton every request, the accept-version onestrict, and the param oneparametertwice.They are now plain readers over instance variables set in
#initialize, the pattern the formatter's options already use. The public readers keep their names.Benchmarks
Median of 7 interleaved subprocess rounds against master, Ruby 4.0.6, no JIT:
The path versioner carries the four extra variables on its per-request
dup, but stays in the same 160-byte object slot (15 of its 18 embedded slots).Test plan
strictto false,vendorto nil, a wrongparameteror an invertedcascadefails 10, 36, 18 and 34 specs respectively.🤖 Generated with Claude Code