perf(ext/web): optimize URLPattern ops to reduce serde overhead and GC pressure#32766
Merged
bartlomieju merged 1 commit intodenoland:mainfrom Mar 18, 2026
Merged
Conversation
…C pressure Replace serde-serialized return values in URLPattern ops with leaner alternatives: - `op_urlpattern_process_match_input`: return a concatenated string + u32 offset buffer instead of `#[serde] Option<(MatchInput, Inputs)>`. The `Inputs` return (which just echoed back the caller's arguments) is eliminated entirely and reconstructed on the JS side. - `op_urlpattern_parse`: return a lean struct that excludes the unused `matcher` field (with its prefix/suffix/InnerMatcher sub-objects) from each UrlPatternComponent. On the JS side, components are stored as an indexed array instead of a keyed object, and match values are accessed by index. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
crowlKats
approved these changes
Mar 18, 2026
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
op_urlpattern_process_match_input: Replace#[serde] Option<(MatchInput, Inputs)>return with#[string] Option<String>+#[buffer] &mut [u32]. The 8 URL component values are concatenated into a single string with offsets written to a sharedUint32Array(9)buffer. TheInputsreturn (which just echoed back the caller's arguments) is eliminated entirely and reconstructed on the JS side.op_urlpattern_parse: Return a lean struct that excludes the unusedmatcherfield (containingprefix,suffix, andInnerMatchersub-objects) from eachUrlPatternComponent.JS side: Components stored as indexed array instead of keyed object. Match values accessed by index. Inner loop variable shadowing fixed.
Benchmark
Test plan
./x test-unit urlpatternpassestest(),exec(), property getters, string/init/baseURL inputs🤖 Generated with Claude Code