Skip to content

Commit be281ed

Browse files
edwinsmithfacebook-github-bot
authored andcommitted
perf logging to Scuba
Summary: Adds a new option Autoload.PerfSampleRate which enables sampled logging of AutoloadMap and FactsStore API call latency. If the configured rate is 0, we don't install any FactsLogger, so there is no logging overhead. Added a new `key` column so events can be grouped by symbol or path. Removed the old XLOG based performance logging since it doesn't provide any good way to analyze distributions, trends, A/B tests, etc. Differential Revision: D52539718 fbshipit-source-id: 414d7e5096de6af788c898fe6335d98f5b1cf164
1 parent 7ecd1d2 commit be281ed

File tree

7 files changed

+169
-82
lines changed

7 files changed

+169
-82
lines changed

hphp/runtime/base/runtime-option.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ std::string RuntimeOption::AutoloadLogging;
893893
bool RuntimeOption::AutoloadLoggingAllowPropagation;
894894
bool RuntimeOption::AutoloadRethrowExceptions = true;
895895
int RuntimeOption::DeclExtensionCacheSize = 500000;
896+
uint32_t RuntimeOption::AutoloadPerfSampleRate = 0;
896897
std::string RuntimeOption::FileCache;
897898
std::string RuntimeOption::DefaultDocument;
898899
std::string RuntimeOption::GlobalDocument;
@@ -2523,6 +2524,10 @@ void RuntimeOption::Load(
25232524

25242525
Config::Bind(DeclExtensionCacheSize, ini, config, "Ext.Decl.CacheSize", 500000);
25252526

2527+
// Sample rate for Autoload & Facts API latency logging
2528+
Config::Bind(AutoloadPerfSampleRate, ini, config,
2529+
"Autoload.PerfSampleRate", 0);
2530+
25262531
Config::Bind(FileCache, ini, config, "Server.FileCache");
25272532
Config::Bind(DefaultDocument, ini, config, "Server.DefaultDocument",
25282533
"index.php");

hphp/runtime/base/runtime-option.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ struct RuntimeOption {
589589
static std::string AutoloadLogging;
590590
static bool AutoloadLoggingAllowPropagation;
591591
static bool AutoloadRethrowExceptions;
592+
static uint32_t AutoloadPerfSampleRate;
592593

593594
static int DeclExtensionCacheSize;
594595

hphp/runtime/ext/facts/facts-store.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,10 @@ std::shared_ptr<FactsStore> make_watcher_facts(
11891189
if (shouldSubscribe) {
11901190
inner->subscribe();
11911191
}
1192-
return FactsLogger::wrap(std::move(inner));
1192+
return FactsLogger::wrap(
1193+
std::move(inner),
1194+
"ext_facts watcher",
1195+
RuntimeOption::AutoloadPerfSampleRate);
11931196
}
11941197

11951198
std::shared_ptr<FactsStore> make_trusted_facts(
@@ -1203,7 +1206,10 @@ std::shared_ptr<FactsStore> make_trusted_facts(
12031206
}
12041207
auto inner = std::make_unique<FactsStoreImpl>(
12051208
std::move(root), std::move(dbOpener), std::move(indexedMethodAttrs));
1206-
return FactsLogger::wrap(std::move(inner));
1209+
return FactsLogger::wrap(
1210+
std::move(inner),
1211+
"ext_facts trusted",
1212+
RuntimeOption::AutoloadPerfSampleRate);
12071213
}
12081214

12091215
} // namespace Facts

0 commit comments

Comments
 (0)