From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from mail-ig0-f191.google.com (mail-ig0-f191.google.com [209.85.213.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 90B7920D59 for ; Thu, 12 May 2016 16:55:01 +0000 (UTC) Received: by mail-ig0-f191.google.com with SMTP id sq19sf15690698igc.1 for ; Thu, 12 May 2016 09:55:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=hVVIev4B9/+xGlIAaBBGtPPQcnQjvugReF6sEdJU1ZU=; b=YFsnNscAfJV5gCwf3k/+gRma88jHaKEyywcjvvkNnDXyt3EQAtS9rubGifZq6UGZ7M /htdKR9CTTBhtqb+xU4R/zSidRY3l0pF648hcdE3hjBSkSCRPU7UkW7TloKMrz2zNGg3 ExvAE9mMhDwzN6ZGK6MTjvfkiiXD1qpy+hrC5fIqXK8LumUy9n8mPj6ZuaYtBu/IcvtM qn5XeKRxJTGn7eV8kkMc1GXHVJE6P3QMA2DU/G0BLgaHIUD430l1PZnwcqMtw8jLCw92 sNdaEuEP13UT1W1ZSuf9EvVI/2cgPwTDJ/kUXkcnhHjhj8Kv/CW+93P4Z/88xgTIwQqf d9Tg== X-Gm-Message-State: AOPr4FWBjej7kGZCruP6iAzbpSdSwzDKQUhpeKE5DCCvd2p2nLOp6Vk3Z3JFNt8psK2RPA== X-Received: by 10.140.100.142 with SMTP id s14mr348759qge.3.1463072100867; Thu, 12 May 2016 09:55:00 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.140.88.21 with SMTP id s21ls1885781qgd.94.gmail; Thu, 12 May 2016 09:55:00 -0700 (PDT) X-Received: by 10.31.169.140 with SMTP id s134mr6908155vke.7.1463072100182; Thu, 12 May 2016 09:55:00 -0700 (PDT) Received: from mail-pf0-x230.google.com (mail-pf0-x230.google.com. [2607:f8b0:400e:c00::230]) by gmr-mx.google.com with ESMTPS id d141si2629083pfd.1.2016.05.12.09.54.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 May 2016 09:54:59 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c00::230 is neither permitted nor denied by best guess record for domain of aaron@tenderlovemaking.com) client-ip=2607:f8b0:400e:c00::230; Received: by mail-pf0-x230.google.com with SMTP id 206so32798356pfu.0 for ; Thu, 12 May 2016 09:54:59 -0700 (PDT) X-Received: by 10.98.152.71 with SMTP id q68mr4408087pfd.49.1463072099632; Thu, 12 May 2016 09:54:59 -0700 (PDT) Received: from TC.local (c-24-56-229-227.customer.broadstripe.net. [24.56.229.227]) by smtp.gmail.com with ESMTPSA id n66sm21143836pfb.17.2016.05.12.09.54.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 May 2016 09:54:58 -0700 (PDT) Sender: Aaron Patterson Date: Thu, 12 May 2016 09:54:56 -0700 From: Aaron Patterson To: Eric Wong Cc: rack-devel@googlegroups.com, richard schneeman Subject: Re: Less allocated objects on each request Message-ID: <20160512165456.GA79225@TC.local> References: <20141003200836.GA4664@dcvr.yhbt.net> <20141005081525.GA8997@dcvr.yhbt.net> <20160512030454.GA10916@dcvr.yhbt.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="1yeeQ81UyVL57Vl7" Content-Disposition: inline In-Reply-To: <20160512030454.GA10916@dcvr.yhbt.net> User-Agent: Mutt/1.5.23 (2014-03-12) X-Original-Sender: aaron@tenderlovemaking.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@tenderlovemaking-com.20150623.gappssmtp.com; spf=neutral (google.com: 2607:f8b0:400e:c00::230 is neither permitted nor denied by best guess record for domain of aaron@tenderlovemaking.com) smtp.mailfrom=aaron@tenderlovemaking.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , --1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline On Thu, May 12, 2016 at 03:04:54AM +0000, Eric Wong wrote: > richard schneeman wrote: > > That first SVN commit is > > > > *https://github.com/ruby/ruby/commit/779ae78995977305aa5aec9cb5b562dcf54c22e7* > > > > The second commit is: > > *https://github.com/ruby/ruby/commit/58f800a278b8b70463f4afdbb23a918d8ab441ff* > > > > Eric's proposal: *https://bugs.ruby-lang.org/issues/9425* > > > > > > I agree that the patch should one day be unnecessary, > > Hi Richard, ressurrecting since I believe the day has come :) > > Since rack.git depends on Ruby 2.2.2+ which has the > aforementioned string deduplication, I think we can undo > most (if not all) of these ugly constants and reduce constant > cache overheads while we're at it. > > I can followup with patches to the list hopefully in the next > few weeks if nobody beats me to it (occupied with other stuff, > at the moment) > > To summarize, the following are optimized in 2.2 (or earlier): > > { "foo" => "bar" } # "foo" is deduped > # "bar" is duplicated unless 'frozen_string_literal: true' > > base_hash["foo"] = "bar" # same as above > base_hash["foo"] # "foo" is deduped ditto > > The Hash#[] and Hash#[]= optimizations unfortunately do not > transfer to subclasses like HeaderHash. > > # string literals in the "when" statement > # this has been optimized for many years, now. > case var > when "foo" > do_foo > when "bar" > do_bar > end > > "string".freeze on any string literal is deduped since 2.1, > which might be useful for performance-critical subclasses of Hash. > > "frozen_string_literal: true" magic comment exists since 2.3; > but I'm not sure how much it helps and it's easy to introduce > new bugs, so I'm not enthusiastic about it for old code. > > Regardless, constants are expensive in both space and time. The > inline constant cache takes space, and the cache needs to be > checked every time a constant is accessed. String literals do > not have that cost. > > Constants still have one minor advantage: runtime NameError in > case of typos. But I don't think that benefit is worth it > as they make code harder-to-read. > > I mainly bring this up because I had trouble following some > of the hijack code for webrick: > http://mid.gmane.org/20160511050451.GA23544@dcvr.yhbt.net > > (Only speaking for MRI optimizations, I don't know other VMs) Yes please! If you have time. Otherwise I can take care of it. -- Aaron Patterson http://tenderlovemaking.com/ -- --- 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. --1yeeQ81UyVL57Vl7 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJXNLVgAAoJEJUxcLy0/6/G0dUH/j5ItWGxT9IFsAzdGvfoH68L kybGCH1kJsXkUiyWRj2PxK9OSURd/9Hn6q1ye3tMlwNdZXxo0iXeb72e4aaIrFy6 CMJBT78ftwYvsmeMS9LYw66Iyq68fcbblYsjpswF+jhb6xB5Kj40OvmtNi4EyQ6y 6lSpRGdIx0BBdyDDfvXqAfrAtHxiUUjkt261oIfRyFimL/LS4k7X/MF3vJ621FB7 wV27d+m1MfVU74RkgGm6QY7Yenfu/rBLcEQOQGHamZdR7U92llmLzbg2OmCg9S2X TsepqsxbKdHkXZjt++0ceKWKBgderQDYHALksJi7P+Kyrfp+TDKScVRSG5dzm7c= =OzzC -----END PGP SIGNATURE----- --1yeeQ81UyVL57Vl7--