Homec4science

Improve performance of PhutilSymbolLoader::selectAndLoadSymbols()

Authored by epriestley <git@epriestley.com> on Sep 13 2011, 17:37.

Description

Improve performance of PhutilSymbolLoader::selectAndLoadSymbols()

Summary:
This function currently works like this:

foreach (library) {
  foreach (symbol) {
    does it match? -> load it
  }
}

However, we end up here in __autoload() so this pathway is pretty performance
sensitive, and in the common case we have a symbol name. So instead we do:

foreach (library) {
  if (we-know-the-symbol-name) {
    symbols-to-examine = just-that-symbol;
  } else {
    symbols-to-examine = all-symbols;
  }
  foreach (symbols_to_examine) {
    does it match? -> load it
  }
}

This takes the function down from slightly-expensive to pretty-cheap and saves
5-10ms per page on my machine.

Test Plan: Site still works, including reflection interfaces like Conduit, and
it wouldn't if this was broken. Profiles show 5-10ms drop (~25%-50%) in this
function's exclusive time.

Reviewers: jungejason, nh, tuomaspelkonen, aran

Reviewed By: aran

CC: aran

Differential Revision: 922

Details

Committed
epriestley <git@epriestley.com>Sep 13 2011, 19:33
Pushed
aubortMar 17 2017, 12:03
Parents
rPHU277d65b9f448: Add user/pass support to PhutilURI
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPHUe72d530958ea: Improve performance of PhutilSymbolLoader::selectAndLoadSymbols() (authored by epriestley <git@epriestley.com>).Sep 13 2011, 19:33