rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: James Tucker <jftucker@gmail.com>
To: rack-devel@googlegroups.com
Subject: Re: Less allocated objects on each request
Date: Sun, 5 Oct 2014 14:31:23 -0700	[thread overview]
Message-ID: <CABGa_T9YXCQ+tMcxs2JXvGNFRTeZ4Ojw5Uo4y0qK0u3xY3wzvA@mail.gmail.com> (raw)
In-Reply-To: <20141003200836.GA4664@dcvr.yhbt.net>

[-- Attachment #1: Type: text/plain, Size: 2455 bytes --]

Yeah, I've refused a previous patch on related grounds - this should be a
language implementation target. I'm glad to hear that reached patches.

Previously, back in the 1.8 days, I benched the aforementioned patch and it
was slower than allocating the strings. It turns out that a simple Rack
app, when you bench, will happily free these objects and not suffer major
problems under high load with the allocations. If I remember correctly the
prior patch added constant and method lookup time due to adding hierarchy
too.

On Fri, Oct 3, 2014 at 1:08 PM, Eric Wong <e@80x24.org> wrote:

> 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.
>

-- 

--- 
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.

[-- Attachment #2: Type: text/html, Size: 3362 bytes --]

      parent reply	other threads:[~2014-10-05 21:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03 20:08 Less allocated objects on each request Eric Wong
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 [this message]

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=CABGa_T9YXCQ+tMcxs2JXvGNFRTeZ4Ojw5Uo4y0qK0u3xY3wzvA@mail.gmail.com \
    --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).