Skip to content

Look up the header versioner's vendor pattern once, when it is built - #3098

Merged
ericproulx merged 1 commit into
masterfrom
refactor/versioner-vendor-pattern
Nov 21, 2026
Merged

ericproulx merged 1 commit into
masterfrom
refactor/versioner-vendor-pattern

Conversation

@ericproulx

@ericproulx ericproulx commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Part of making Grape's internals readable from a non-main Ractor, without calling the Ractor API from lib/ (groundwork for #2978). Split from #3095, with the rest in #3096 and #3097.

When an Accept header missed the table the header versioner builds, Grape::Util::MediaType read VendorVersionHeaderRegexCache per request: a singleton behind a Monitor, which a non-main Ractor cannot read. The versioner now looks its vendor's pattern up as it is built and passes it down, so a request reads no shared, mutable state.

MediaType.parse, .best_quality and .new take vendor_pattern: in place of vendor:, and MediaType.vendor_pattern(vendor) answers it. vendor: shipped in 4.1.0 (#3013), hence the UPGRADING note.

Throughput

Ruby 4.0.6, 6 rounds from one checkout, alternating which side runs first, median of the per-round ratios. The versioner no longer takes the cache's Monitor on that path:

YJIT interpreter
Accept header outside the table −4.1% (6/6 rounds faster) −3.3% (6/6)

🤖 Generated with Claude Code

A request whose Accept header missed the versioner's table read
VendorVersionHeaderRegexCache, a singleton behind a Monitor. The
versioner now passes the pattern down, and Grape::Util::MediaType takes
vendor_pattern: in place of vendor:.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ericproulx
ericproulx force-pushed the refactor/versioner-vendor-pattern branch from 712b029 to 2038ad9 Compare November 21, 2026 17:39
@ericproulx
ericproulx merged commit 000d9ec into master Nov 21, 2026
52 checks passed
@ericproulx
ericproulx deleted the refactor/versioner-vendor-pattern branch November 21, 2026 17:43
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