Regex string allocation - #1943
Merged
Merged
Conversation
Generated by 🚫 danger |
dblock
reviewed
Dec 14, 2019
| #### Features | ||
|
|
||
| * Your contribution here. | ||
| * [#1943](https://github.com/ruby-grape/grape/pull/1943): Regex string allocation - [@ericproulx](https://github.com/ericproulx). |
Member
There was a problem hiding this comment.
Nitpick, this should describe what it does, eg. "Reduce number of regex string allocations"
Member
|
Great work. Rebase, I'll merge. |
ericproulx
force-pushed
the
regex_string_allocation
branch
from
December 14, 2019 21:07
a1a3a03 to
85346f2
Compare
…string allocation. Changelog
ericproulx
force-pushed
the
regex_string_allocation
branch
from
December 14, 2019 21:09
85346f2 to
489e900
Compare
dblock
reviewed
Dec 15, 2019
dblock
reviewed
Dec 15, 2019
| * Your contribution here. | ||
| * [#1942](https://github.com/ruby-grape/grape/pull/1942): Optimized retained memory methods - [@ericproulx](https://github.com/ericproulx). | ||
| * [#1943](https://github.com/ruby-grape/grape/pull/1943): Reduce number of regex string allocations - [@ericproulx](https://github.com/ericproulx). | ||
| [#1942](https://github.com/ruby-grape/grape/pull/1942): Optimized retained memory methods - [@ericproulx](https://github.com/ericproulx). |
Member
|
Merged thank you |
basjanssen
pushed a commit
to basjanssen/grape
that referenced
this pull request
Feb 28, 2020
Use Regexp instead of // for regex in router.rb for a more efficient string allocation.
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.
While memory profilling our app, I found these strange memory allocations :
Turns out, its 2 regex defined in router.rb with interpolation. I replaced the 2 lliteral regexs by the Regexp constructor. Therefore, the strings above (memory profiling) are just allocated once and benefits from the frozen_string_literal