Homec4science

Dramatically increase cache hit rate for feed

Authored by epriestley <git@epriestley.com> on Jun 30 2015, 20:19.

Description

Dramatically increase cache hit rate for feed

Summary:
Ref T8631. The query plan for feed stories is really bad right now, because we miss caches we should be hitting:

  • The workspace cache is stored at each query, so adjacent queries can't benefit from the cache (only subqueries). Feed has primarily sibling queries.
    • There is no technical reason to do this. Store the workspace cache on the root query, so sibling queries can hit it.
  • In ObjectQuery, we check the workspace once, then load all the PHIDs. When the PHIDs are a mixture of transactions and objects, we always miss the workspace and load the objects twice.
    • Instead, check the workspace after loading each type of object.
  • HandleQuery does not set itself as the parent query for ObjectQuery, so handles never hit the workspace cache.
    • Pass it, so they can hit the workspace cache.
  • Feed's weird PhabricatorFeedStory::loadAllFromRows() method does not specify a parent query on its object/handle queries.
    • Just declare the object query to be the "root" query until this eventually gets cleaned up.

Test Plan: Saw queries for each object drop from 4-6x to 1x in /feed/.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8631

Differential Revision: https://secure.phabricator.com/D13479

Details

Committed
epriestley <git@epriestley.com>Jun 30 2015, 20:19
Pushed
aubortJan 31 2017, 17:16
Parents
rPH0ef1d4bc17bb: Don't try to load profile images for projects with no profile image
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPH4adaf53bf0cb: Dramatically increase cache hit rate for feed (authored by epriestley <git@epriestley.com>).Jun 30 2015, 20:19