1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00
No description
Find a file
epriestley 431c57688e Improve performance of project list view
Summary:
D477 added functionality to the project list view but had a couple of
performance issues that I missed in review, because it took the query count for
the page from around 3 to as many as 300, including up to 100 heavyweight search
index queries.

This fixes the two simple N+1 query problems. This general pattern of data
access often occurs:

  COUNTEREXAMPLE
  $cats = load_cats();
  foreach ($cats as $cat) {
    $cats_hats = load_hats_for_cat($cat);
    // ...
  }

But this issues "N+1" queries, i.e. if you load 100 cats you issue 101 queries.
It is faster to group the queries instead:

  $cats = load_cats();
  $hats = load_all_hats_for_these_cats($cats);
  foreach ($cats as $cat) {
    $cats_hats = $hats[$cat->getID()];
  }

MySQL can execute one query which returns all the results much faster than 100
queries which return one result, especially if the database is not local (i.e.,
over the network).

However, this doesn't save a ton of time. The bigger issue is that I didn't have
the right keys on the relationship tables in the search engine. This adds them,
and reduces the search engine lookup cost from 25-80ms (for
secure.phabricator.com) down to 1-3ms.

I still probably want to get this out of the loop at some point but it's okay
for now and the page loads in a few ms rather than taking more than a second.

Test Plan:
Used "services" tab, "xhprof" and "EXPLAIN" to analyze page performance. I
measured these changes:

  - Query count: 1 + (3 * N projects) -> 3 + (N projects) (e.g., 301 -> 103)
  - Total time spent querying, ignoring search indexes: 40ms (local.aprhont.com)
-> 20ms (local.aphront.com)
  - Cost for search index query: 25-80ms (secure.phabricator.com) -> 1-3ms

Reviewed By: cadamo
Reviewers: cadamo, aran, jungejason, tuomaspelkonen
CC: aran, cadamo, epriestley
Differential Revision: 485
2011-06-21 14:43:15 -07:00
bin Improve CLI script for account creation and document account/reg setup process 2011-05-12 18:44:53 -07:00
conf Provide basic capabilities to make Differential column width flexible 2011-06-09 12:01:11 -07:00
externals Skip attaching 'inline' text attachments 2011-06-12 22:38:57 -07:00
resources Improve performance of project list view 2011-06-21 14:43:15 -07:00
scripts Ping conduit from PHD and set daemon logfiles. 2011-06-13 18:39:23 -07:00
src Improve performance of project list view 2011-06-21 14:43:15 -07:00
support/aphlict Aphlict, simple notification server 2011-05-17 10:32:41 -07:00
webroot Merge remote branch 'cadamo/devel' 2011-06-20 16:06:03 -07:00
.arcconfig Bring Javelin into Phabricator via git submodule, not copy-and-paste 2011-05-08 13:20:10 -07:00
.divinerconfig Update Herald documentation. 2011-06-14 11:09:40 -07:00
.gitignore Gitignore additions 2011-06-10 12:59:15 -04:00
.gitmodules Just change the location. 2011-05-28 15:14:54 -07:00
CHANGELOG Changelog notice about epriestley/ -> facebook/ move. 2011-05-31 20:14:02 -07:00
README Edited README via GitHub 2011-04-29 16:10:08 -07:00

PROJECT STATUS: CAVEAT EMPTOR

This is an unstable preview release. You can learn more at http://phabricator.org/
as well as click around our development install. Developer mailing list at
https://groups.google.com/group/phabricator-dev and please report issues using
GitHub.

WHAT IS PHABRICATOR?

Phabricator is a suite of web applications that facilitate software development
tasks, particularly code review. The primary application in the suite is
Differential, a code review tool.

Phabricator is highly unstable and has many missing features! These applications
are being brought over from Facebook's internal toolset, but there's a lot of
stuff that hasn't made it over yet. Feel free to follow the project but you
probably shouldn't try to install this yet unless you're extremely ambitious
or just want to take a look at it. 

LICENSE

Phabricator is released under the Apache 2.0 license except as otherwise noted.
http://www.apache.org/licenses/LICENSE-2.0