rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / code / Atom feed
From: James Tucker <jftucker@gmail.com>
To: rack-devel@googlegroups.com
Cc: Aman Gupta <aman@tmm1.net>
Subject: Re: [PATCH] builder: avoid to_app on every request when using map
Date: Mon, 14 Jul 2014 21:09:46 -0700	[thread overview]
Message-ID: <CABGa_T9SEM8_ceQ8dy2KnBfLG3CvY7t61FgftR-7udbKuOf90w@mail.gmail.com> (raw)
In-Reply-To: <20131106031207.GA4213@dcvr.yhbt.net>

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

Thanks!


On Tue, Nov 5, 2013 at 7:12 PM, Eric Wong <normalperson@yhbt.net> wrote:

> Eric Wong <normalperson@yhbt.net> wrote:
> > Eric Wong <normalperson@yhbt.net> wrote:
> > > James Tucker <jftucker@gmail.com> wrote:
> > > > Yeah, Builder#call leads to mistakes all the time and then people
> claiming
> > > > performance sucks. I don't think the simple use case there ever
> helped.
> > >
> > > Just curious, is this in test suites or code running on live servers?
> > > I can't imagine there are many one-off webservers existing and using
> > > that directly...
> >
> > Answering my own question, the "map" directive in Builder seems to
> > trigger Builder#to_app in every single request.
> >
> > It looks like map completely defeats warmup and preloading...
>
> OK, I can't tell if my this has any bad side effects (specs pass!),
> but I'm already running this on yhbt.net:
>
> From: Eric Wong <normalperson@yhbt.net>
> Date: Wed, 6 Nov 2013 03:02:48 +0000
> Subject: [PATCH] builder: avoid to_app on every request when using map
>
> By calling to_app immediately after initializing the per-map
> Rack::Builder instances.  Otherwise, benefits of warmup and web
> servers taking advantage of CoW are lost.
>
> This passes tests, and is lightly tested and I have not verified
> this for any negative consequences or incompatibilities.
> ---
>  lib/rack/builder.rb | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/rack/builder.rb b/lib/rack/builder.rb
> index fa3a1ea..2aa37b6 100644
> --- a/lib/rack/builder.rb
> +++ b/lib/rack/builder.rb
> @@ -157,7 +157,7 @@ module Rack
>
>      def generate_map(default_app, mapping)
>        mapped = default_app ? {'/' => default_app} : {}
> -      mapping.each { |r,b| mapped[r] = self.class.new(default_app, &b) }
> +      mapping.each { |r,b| mapped[r] = self.class.new(default_app,
> &b).to_app }
>        URLMap.new(mapped)
>      end
>    end
> --
> The following changes since commit
> df1506b0825a096514fcb3821563bf9e8fd52743:
>
>   Merge pull request #617 from tmm1/builder-warmup (2013-10-25 21:10:40
> -0700)
>
> are available in the git repository at:
>
>   git://git.bogomips.org/rack.git builder-map-to_app
>
> for you to fetch changes up to fd023bafed0ad97e08d15381f35600e3a5b32808:
>
>   builder: avoid to_app on every request when using map (2013-11-06
> 03:08:38 +0000)
>
> ----------------------------------------------------------------
> Eric Wong (1):
>       builder: avoid to_app on every request when using map
>
> --
>
> ---
> 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/groups/opt_out.
>

-- 

--- 
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: 4438 bytes --]

      reply	other threads:[~2014-07-15  4:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02 23:10 [RFC/PATCH] Add Rack::Builder#warmup method for app preloading ruby
2013-10-02 23:55 ` Konstantin Haase
2013-10-29  0:02   ` James Tucker
2013-10-29  0:21     ` Santiago Pastorino
2013-10-29 17:54     ` Eric Wong
2013-11-06  2:57       ` Eric Wong
2013-11-06  3:12         ` [PATCH] builder: avoid to_app on every request when using map Eric Wong
2014-07-15  4:09           ` 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_T9SEM8_ceQ8dy2KnBfLG3CvY7t61FgftR-7udbKuOf90w@mail.gmail.com \
    --to=rack-devel@googlegroups.com \
    --cc=aman@tmm1.net \
    --subject='Re: [PATCH] builder: avoid to_app on every request when using map' \
    /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

rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/rack-devel

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 rack-devel rack-devel/ https://public-inbox.org/rack-devel \
		rack-devel@googlegroups.com
	public-inbox-index rack-devel

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.rack.devel
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.rack.devel
	nntp://news.gmane.io/gmane.comp.lang.ruby.rack.devel
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/rack.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git