On Oct 9, 4:54 pm, Jacob Kaplan-Moss <ja...@jacobian.org> wrote:
> One big question I have is about performance: have you done any a/b
> testing against trunk to see how much adding logging -- especially
> upon every SQL query -- impacts performance?
>
> For me, at least, performance is going to be the critical factor. It's
> clear that even a do-nothing logger will add some overhead. If we're
> talking fractions of percents here, fine... but if there's a
> measurable performance hit that's going to be a big problem, and it's
> probably best to be tracking speed as we go along here.

Nothing scientific yet - I've run the full unit test and got these
results:

master: 314.442s
logging: 317.096s

Since there's nothing at all in my logging code that will speed
anything up, I'm putting that down to chance (I did run the suite a
few times first to "warm up" the VM I used, but like I said, this is
pretty much the opposite of science).

Microbenchmarks I performed with the timeit module suggest we can log
to a NullHandler logger at a rate of over 100,000 log messages a
second, which is why I haven't paid performance much attention since
running the microbenchmark. Here's how to replicate it (using Python
2.6, which lets you pass a callable to the timeit.timeit function):

import logging

class NullHandler(logging.Handler):
    def emit(self, record):
        pass

logger = logging.getLogger('django')
logger.addHandler(NullHandler())
logger.propagate = False

time_for_a_million_messages = timeit.timeit(lambda: logger.info('a log
message'), number=1000000)
messages_per_second = 1 / (time_for_a_million_messages / 1000000)

I ran that just now and got 137,223 messages per second. I figure even
a really heavy Django page will execute maybe a couple of hundred SQL
queries, which would add about 0.0015 of logging time if no handler
was hooked up. Hence why I'm not too worried.

Is there a reasonable benchmark I can be using for this? The test
suite run time doesn't seem particularly finely grained. I know Jeremy
Dunck was talking about this a while back.

Cheers,

Simon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to