Closed (won't fix)
Project:
Drupal core
Version:
6.x-dev
Component:
database system
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
31 Aug 2007 at 06:35 UTC
Updated:
4 Sep 2007 at 14:42 UTC
Jump to comment: Most recent file
In _db_query(), we call variable_get('dev_query', 0) to know if we should cache the query or not. In fact, we call it twice. While the value of that variable does, in fact, change over the course of a complete page run it never changes within a single _db_query() call, so there's no good reason to issue two function calls. Attached patch changes it to just one call that we save to a variable, which saves us one function call per query issued regardless of whether dev_query is TRUE or not. (That's 50-100 function calls on many sites.)
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | dev_query.benchmark.tar_.gz_.txt | 3.43 KB | hswong3i |
| dev_query.patch | 2.72 KB | Crell |
Comments
Comment #1
hswong3i commentedmay i have some solid supporting about performance improvement? as varibale_get is just something as simple as this format:
an additional function call may reduce performance (which is usually truth), but it may be something need not to be consider, too. i guess it may have 0.5% of overall performance improvement, but it will need to be proved by benchmarking :-)
Comment #2
Crell commentedFresh checkout of HEAD, devel-generate 300 nodes, put 30 on the front page. Total queries for the front page: 291. Running ab with 100 requests:
Apply patch, rerun test:
I have to say I'm surprised at that. In D5, we were able to get a 5% boost by skipping init_theme() in theme(), which is called a few zillion times as well. (In that case init_theme() was also just doing an if(isset($foo)) return; check, so it was trivial as well.) Perhaps function calls are less expensive in PHP 5.2 (what I run now) than they were in 5.1 (what I was running then)?
Comment #3
hswong3i commentedi would like to give a hand for an indeed benchmarking, so we will able to have a much complete picture about the case (again, same configuration as http://drupal.org/node/172541#comment-298711):
Comment #4
chx commentedCommon sense says this is a performance boost, no doubt small but that's no reason to not do it. benchmarking these small steps are not easy at this stage because what you can bench with? node_page_default which runs what, a dozen queries? A complex Drupal install runs hundreds and hundreds of queries on a page. Every little piece helps.
Comment #5
hswong3i commented@chx: it is not only a default installation: i active ALL core module (+ devel) when doing these benchmarking. i shouldn't forget to mention about this, it is totally my fault :(
BTW, if this benchmarking it not meaningful, even though having 3 different concurrency level (1, 5, 10), with each 3 set of result samples, for totally 18 times of benchmarking on top of same platform and settings, i would really interesting about what you would like to believe with?
i don't care to do a much larger scale of benchmarking if i am able to do so (with the help of a very simple script, all we need is time), but may you give me some hints about how can let you believe it as a scientific benchmarking result? i really hope to know what should we believe with, other than these solid result :(
P.S. i am not opposing this patch, but only hope to provide a better and complete picture about the real case, and so we will able to support what we are believing with, with some solid factors :)
Comment #6
dries commentedI don't think this is worth fixing. It's not necessarily faster as we have more code to parse.