Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
779 views
in Q2A Core by

Just looking at debugging performance on a few big pages on my site. Below are the numbers I got loading a page on localhost, though they are at least twice those numbers on the live site. This is a question with over 100 answers in total, but I show 20 per page. There are 6 comments on a few of the answers, and 1-3 comments on the rest.

Total – 1253.3ms (100%) – PHP 1252.1ms (99%), MySQL 2.4ms (0%), Other 0.0ms (0%) – 45 PHP files, 18 DB queries, 5349k RAM (100%)
Setup – 18.3ms (1%) – PHP 20.0ms (1%), MySQL 0.3ms (0%), Other 0.0ms (0%) – 23 PHP files, 2 DB queries, 1339k RAM (25%)
Control – 944.2ms (75%) – PHP 944.1ms (75%), MySQL 1.4ms (0%), Other 0.0ms (0%) – 7 PHP files, 12 DB queries, 3088k RAM (57%)
View – 204.1ms (16%) – PHP 204.0ms (16%), MySQL 0.0ms (0%), Other 0.1ms (0%) – 10 PHP files, 0 DB queries, 0k RAM (0%)
Theme – 86.6ms (6%) – PHP 84.0ms (6%), MySQL 0.6ms (0%), Other 2.0ms (0%) – 5 PHP files, 4 DB queries, 1281k RAM (23%)

So from the look of it, the "Control" section is taking a lot of time. On other pages it's only around 30-40%. And it's a problem with the PHP processing rather than the MySQL queries. I have tested with all plugins removed and the performance remains the same.

What can I learn from this? And is there any way to further debug performance?

Q2A version: 1.5.3

1 Answer

+1 vote
by

'Control' is used in an MVC sense, and is the code that runs on a page before qa_content_prepare() is called. The problem is probably that qa-page-question.php is retrieving and unpacking all of the question's answers from the database, even though it will only show some of them.

by
How come it gets all the answers? Can't we do one query to get the total number of answers, then select only the ones needed?
by
Yes, I'm sure it could be done better, but it won't be a small amount of work. I'll think about it for 1.6...

In the meantime if you sprinkle a few more qa_usage_mark() calls in qa-page-question.php you should be able to home in on the most problematic part - you'll see more categories in the performance report.
...