Speedup path lookup by avoiding object allocation #9
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.
Request#resource
relies onURI#full_path
to combine bothpath
andquery
elements of the parsed URI in order to construct another string.By doing that, a few temporary strings are allocated, adding elements for the GC to collect.
That combined with the Regex introduces a slowdown in the lookup, not to mention the call to PCRE (C land).
URI
already providespath
clean from query parameters and that is exposed as part of the request aspath
.You can see the performance differences on the following benchmark:
https://gist.github.com/luislavena/2bbb6befb8c0dd5ea3c7a628aba3d39d
Results:
Thank you. ❤️ ❤️ ❤️