From: Eric Wong <e@80x24.org>
To: rack-devel@googlegroups.com
Subject: Re: Less allocated objects on each request
Date: Fri, 3 Oct 2014 20:08:37 +0000 [thread overview]
Message-ID: <20141003200836.GA4664@dcvr.yhbt.net> (raw)
Hi all, this is about a recent rack.git commit:
dc53a8c26dc55d21240233b3d83d36efdef6e924
I don't disagree with this commit at this time, but I hope much of
it will become unnecessary as older versions of Ruby get phased out.
Since Ruby 2.1.0, constant string keys are deduplicated in hash
literals. Thus the following reuses the same "key" string in every
case:
{ "key" => val }
# ref: r44058
Ruby 2.2 (coming December 2014) will also deduplicate the "key" literal
allocation for lookups and assignment on regular hashes:
regular_hash["key"] # opt_aref_with (in insns.def)
regular_hash["key"] = val # opt_aset_with
This speeds up the Rack env hash, but unfortunately won't help with
Rack::Utils::HeaderHash :<
(ref: r44551 + a few subsequent bugfixes)
We originally planned to support dedupe for all strings (not just
literals), but that caused performance regressions :<
On a related note, Ruby 2.2 will also use power-of-two sized hash
tables, speeding up lookups/assignments a little
(~10-20%, CPU-dependent) for String keys [Feature #9425]
This only applies to mainline Ruby, I am not up-to-date with
Rubinius/JRuby internals.
Thanks for reading!
--
---
You received this message because you are subscribed to the Google Groups "Rack Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rack-devel+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
next reply other threads:[~2014-10-03 20:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-03 20:08 Eric Wong [this message]
2014-10-05 8:15 ` [PATCH] conditionalget: avoid const lookup in case/when Eric Wong
2014-10-05 21:37 ` James Tucker
2014-10-06 20:00 ` richard schneeman
2016-05-12 3:04 ` Less allocated objects on each request Eric Wong
2016-05-12 16:54 ` Aaron Patterson
2016-05-12 17:01 ` richard schneeman
2016-05-13 23:41 ` Eric Wong
2016-06-17 19:43 ` richard schneeman
2016-06-17 21:00 ` Aaron Patterson
2016-06-17 23:12 ` Eric Wong
2016-06-17 23:19 ` Aaron Patterson
2016-06-17 23:43 ` Eric Wong
2014-10-05 21:31 ` James Tucker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://groups.google.com/group/rack-devel
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141003200836.GA4664@dcvr.yhbt.net \
--to=rack-devel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).