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