Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upLess allocated objects on each request #737
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
nthj
commented
Oct 2, 2014
|
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bbwharris
commented
Oct 2, 2014
|
|
added a commit
that referenced
this pull request
Oct 2, 2014
rkh
merged commit ab172af
into
rack:master
Oct 2, 2014
1 check passed
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Thank you! <3 |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pedrocarrico
commented
Oct 2, 2014
|
A big |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
tak1n
commented
Oct 2, 2014
|
Nice :) |
raggi
reviewed
Oct 2, 2014
| def respond_to?(*args) | ||
| return false if args.first.to_s =~ /^to_ary$/ | ||
| super or @body.respond_to?(*args) | ||
| def respond_to?(method_name) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
schneems
Oct 2, 2014
Contributor
Right you are: http://ruby-doc.org/core-2.1.3/Object.html#method-i-respond_to-3F Looks like 1.8.7 & 2+ also take multiple arguments. I did this because the *args causes us to have an extra array allocation. If we match the method signature respond_to?(string, include_all=false) then the include_all would be an extra object. If I remember this only decreased the overall count by around 100. I'm going to open a new PR to revert these changes, I don't think we can do better than the previous case and still maintain compatibility.
schneems
Oct 2, 2014
Contributor
Right you are: http://ruby-doc.org/core-2.1.3/Object.html#method-i-respond_to-3F Looks like 1.8.7 & 2+ also take multiple arguments. I did this because the *args causes us to have an extra array allocation. If we match the method signature respond_to?(string, include_all=false) then the include_all would be an extra object. If I remember this only decreased the overall count by around 100. I'm going to open a new PR to revert these changes, I don't think we can do better than the previous case and still maintain compatibility.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
schneems
Oct 2, 2014
Contributor
Fix is here: #739 sorry about that, should have known better. Thanks for the catch!
schneems
Oct 2, 2014
Contributor
Fix is here: #739 sorry about that, should have known better. Thanks for the catch!
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
raggi
Oct 2, 2014
Member
Sorry, but false.object_id == 0, include_all in your example only takes a reference slot, not an RObject structure.
raggi
Oct 2, 2014
Member
Sorry, but false.object_id == 0, include_all in your example only takes a reference slot, not an RObject structure.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
schneems
Oct 3, 2014
Contributor
Updated in #742 also can get rid of a string allocation in method_missing
schneems
Oct 3, 2014
Contributor
Updated in #742 also can get rid of a string allocation in method_missing
added a commit
to schneems/rack
that referenced
this pull request
Oct 2, 2014
added a commit
to soulim/rack
that referenced
this pull request
Oct 2, 2014
tjwallace
reviewed
Oct 3, 2014
| @@ -12,13 +12,14 @@ def initialize(app, name = nil) | ||
| @header_name << "-#{name}" if name | ||
| end | ||
| FORMAT_STRING = "%0.6f" |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
GetSetExecute
reviewed
Oct 3, 2014
| @@ -72,7 +72,7 @@ def check_forbidden | ||
| body = "Forbidden\n" | ||
| size = Rack::Utils.bytesize(body) | ||
| return [403, {"Content-Type" => "text/plain", |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
GetSetExecute
Oct 3, 2014
Missed opportunity to replace "Content-Type" with CONTENT_TYPE. Also on line 132
GetSetExecute
Oct 3, 2014
Missed opportunity to replace "Content-Type" with CONTENT_TYPE. Also on line 132
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
schneems
Oct 3, 2014
Contributor
RIght you are. I love open source, thanks for pointing this out! Updated in #742
schneems
Oct 3, 2014
Contributor
RIght you are. I love open source, thanks for pointing this out! Updated in #742
added a commit
to soulim/rack
that referenced
this pull request
Oct 3, 2014
added a commit
to caius/rack
that referenced
this pull request
Oct 3, 2014
added a commit
to caius/rack
that referenced
this pull request
Oct 3, 2014
added a commit
to schneems/rack
that referenced
this pull request
Oct 3, 2014
added a commit
to schneems/rack
that referenced
this pull request
Oct 3, 2014
added a commit
to schneems/rack
that referenced
this pull request
Oct 3, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zaidakram
commented
Oct 5, 2014
|
Nice Stuff! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
stungeye
commented
Oct 5, 2014
|
|
added a commit
to schneems/rack
that referenced
this pull request
Oct 6, 2014
added a commit
to schneems/rack
that referenced
this pull request
Oct 6, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
frodsan
Jan 22, 2015
Contributor
@schneems The same change can be made in line 113 (env["PATH_INFO"])?
|
@schneems The same change can be made in line 113 ( |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
schneems
Jan 22, 2015
Contributor
Probably. I never hit this in my benchmarks. Also more benchmarks here #742
|
Probably. I never hit this in my benchmarks. Also more benchmarks here #742 |
schneems commentedOct 1, 2014
How many? Using
memory_profilerand a Rails app (codetriage.com), master uses:After this patch, the app uses:
Or
(7318 - 4598) / 7318.0 * 100 # => 37.16% fewer objects PER REQUEST.To do this, I extracted really commonly used strings into top level Rack constants. It makes for a bit of a big diff, but I believe the changes are worth it.
Running benchmark/ips against the same app, I'm seeing a performance boost of
2~4%across the entire app response. This doesn't just make Rack faster, it will make your app faster.While we could certainly go overboard and pre-define ALL strings as constants, that would be pretty gnarly to work with. This patch goes after the largest of the low hanging fruit.