- Japhy
2010/12/10 Rickard Böttcher <rickard....@gmail.com>:
FWIW on my laptop (i.e. the least scientific or reproducible
environment possible), I see a much less dramatic performance drop -
~20% fewer requests per second today compared to the 1.0 release.
On Fri, Dec 10, 2010 at 5:09 AM, Jacob Kristhammar
<krist...@gmail.com> wrote:
> The following points are at least worth mentioning:
> 1. The performance number in [1] is no longer true. (We haven't
> compared Tornado against Django or web.py though)
> 2. A lot of the performance hits seems to be a result of the
> introduction of StackContext (maybe a fair tradeoff?)
This is very surprising to me and warrants further analysis.
Fundamentally StackContext is doing the same sort of thing the old
async_callback wrappers were doing, so it really shouldn't add that
much overhead (although it does add the equivalent of a couple of
async_callback wrappers to purely synchronous handlers like the hello
world handler used in this benchmark). I think the convenience of
StackContext is worth a small performance hit, but it's hard to
justify in the face of such a large slowdown.
For Craig, and anyone else following along who is unfamiliar with
StackContext, it was added in Tornado 1.1 primarily as an
error-handling mechanism for asynchronous operations. It eliminated
the need to explicitly wrap your callbacks in self.async_callback().
> 3. Many selected Tornado because of it's simplicity and performance
> which seems to be the things in decay.
Personally my attraction to Tornado has always been its simplicity,
with performance being a secondary concern. Where do you feel that
Tornado is losing simplicity? (or maybe this should be a separate
thread).
> 4. We're no longer sure if we should invest more time in Tornado
> (unless this trend changes) and start to look at other options.
That would be unfortunate, since you've made a number of valuable contributions.
>
> In general...
> What's your thoughts about the future of Tornado?
I think the core of Tornado (IOLoop, HTTPServer, etc) is fairly stable
now, and I don't anticipate major changes in that area (certainly not
anything as invasive as StackContext was). I don't think we'll see
this downward trend in performance continue, and now that you've
called my attention to it things should start to improve.
> What's changed since you first open sourced Tornado e.g. in this tech-
I've taken over the project from Bret, for one thing. :) But
seriously, I don't think there's been a change in philosophy or
strategy. If I had been looking at benchmark numbers more closely I
probably wouldn't have added StackContext (at least not in its current
form), but my performance analysis was always in the context of a
non-trivial application, where per-request overhead tends to fade into
the background (if you had asked me before this email which part of
tornado was most in need of performance improvements, I probably would
have said template rendering).
-Ben
It turns out that the 'with' statement has a huge amount of overhead -
a with statement is more than 5 times as expensive as a try/except,
and the @contextlib.contextmanager decorator is another factor of 5
slower than a manually-written class with __enter__/__exit__ methods.
(benchmark: https://gist.github.com/736778).
It's easy enough to get rid of the @contextmanager decorator, and I'll
look into whether we can do without the with statement at all.
-Ben
It's great to see that you've already started to find weak spots and potential improvements, nice work!
More comments below,
-- Jacob
On Dec 10, 2010, at 9:12 PM, Ben Darnell wrote:
> Wow, thanks a lot for the detailed analysis. This is great
> information and I'd love to get these scripts or something like it
> running on a regular basis.
>
We actually realized the same thing for some of our other projects while compiling this data ;)
Maybe it would be a good thing to revive one of the SC threads, but here's some thoughts.
Wrapping your head around how StackContext changes the internals of Tornado is not the most straight forward task. We've been messing around quite a lot in the internals of Tornado writing some client libraries etc. and hence had to get our hands dirty (or at least understand how SC changed things).
Even though it's clearly "easier" from the standard users point of view, it added "magic" making people less conscious about what is actually is going on. Prior to SC it was easier to have a mental model of how things worked all the way to the ioloop, which is something I found very nice in comparison to more complex frameworks that makes it close to impossible to know everything.
Writing asynchronous code is not the most straight forward task in it self, but Tornado was/is a very clean framework providing you with a minimal toolkit to do it. Most everything just made sense when Tornado was released to the public. The fact that you explicitly had to wrap with async_callback worked as a good sanity check that you were doing things right and it felt very natural IMHO. Maybe it's just my lack of deep understanding how SC really works, but I actually find myself thinking "hmm, well, SC just fixed it" (without knowing why) sometimes when things blow up (which I guess is part of it's purpose).
TL;DR; It's harder to track a requests lifetime, from seed to bread so to speak.
>
>> 4. We're no longer sure if we should invest more time in Tornado
>> (unless this trend changes) and start to look at other options.
>
> That would be unfortunate, since you've made a number of valuable contributions.
We still depend heavily on Tornado and will continue to use it for now. I've also gained confidence in a brighter future after the good reaction to this post. As long as we know that performance is still valuable we can dig in to fix it. I liked the idea of not putting to much features in there (i.e. brets quote).
>
>>
>> In general...
>> What's your thoughts about the future of Tornado?
>
> I think the core of Tornado (IOLoop, HTTPServer, etc) is fairly stable
> now, and I don't anticipate major changes in that area (certainly not
> anything as invasive as StackContext was). I don't think we'll see
> this downward trend in performance continue, and now that you've
> called my attention to it things should start to improve.
>
>> What's changed since you first open sourced Tornado e.g. in this tech-
>
> I've taken over the project from Bret, for one thing. :) But
> seriously, I don't think there's been a change in philosophy or
> strategy. If I had been looking at benchmark numbers more closely I
> probably wouldn't have added StackContext (at least not in its current
> form), but my performance analysis was always in the context of a
> non-trivial application, where per-request overhead tends to fade into
> the background (if you had asked me before this email which part of
> tornado was most in need of performance improvements, I probably would
> have said template rendering).
This is a good point. These numbers doesn't mean the world. But it's probably a good trend indicator of overall performance.
I've just committed a few changes that in my tests reclaim about 40%
of the performance lost since 1.0.
-Ben
Totally agree - keep rocking Ben.
Josh Marshall
On Dec 11, 2010 1:41 AM, "Romy" <romy.m...@gmail.com> wrote:
+1
On Dec 10, 8:06 pm, Landon <lando...@gmail.com> wrote:
> Ben-
>
> As a side note to the discussion ...
On 10/12/10 21:52, Ben Darnell wrote:
> It turns out that the 'with' statement has a huge amount of overhead -
> a with statement is more than 5 times as expensive as a try/except,
> and the @contextlib.contextmanager decorator is another factor of 5
> slower than a manually-written class with __enter__/__exit__ methods.
> (benchmark: https://gist.github.com/736778).
>
> It's easy enough to get rid of the @contextmanager decorator, and I'll
> look into whether we can do without the with statement at all.
Could I suggest to file a bug in python?. It would be an improvement for
python 3.3. That would be not of help for Tornado, since it doesn't
support Python 3.x (yet), but filing a bug seems appropiate and sensible.
- --
Jesus Cea Avion _/_/ _/_/_/ _/_/_/
jc...@jcea.es - http://www.jcea.es/ _/_/ _/_/ _/_/ _/_/ _/_/
jabber / xmpp:jc...@jabber.org _/_/ _/_/ _/_/_/_/_/
. _/_/ _/_/ _/_/ _/_/ _/_/
"Things are not so easy" _/_/ _/_/ _/_/ _/_/ _/_/ _/_/
"My name is Dump, Core Dump" _/_/_/ _/_/_/ _/_/ _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQCVAwUBTQNu05lgi5GaxT1NAQJoUAQAnsBKbV4mBAHsqNUrp3a7OvQ8J0EohHDi
QqAWPte9r2qBrsVMaJoBtRMIRHTRt1s6nxeA9eYlc2hiEX3hnsK4I2MEodDmazj8
PB7p/5LQ4FbB2EJOJADeeaw5IHFeFxMxt7Z1NS324unFrZzPZkb1v4S6vnoD78Vx
wm47YTtSW/Q=
=1O8x
-----END PGP SIGNATURE-----