Skip to content

Commit 68bd87b

Browse files
avpfacebook-github-bot
authored andcommitted
Add -sample-profiling-freq flag
Summary: This flag allows us to set the profiling frequency in Hz. Reviewed By: neildhar Differential Revision: D69156565 fbshipit-source-id: 52bae04c4da95d44c0e4e04c156e676fb96cd3e6
1 parent 46e8b30 commit 68bd87b

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

include/hermes/ConsoleHost/ConsoleHost.h

+3
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ struct ExecuteOptions {
169169
/// If not None, run sampling profiler and dump the result.
170170
SampleProfilingMode sampleProfiling{SampleProfilingMode::None};
171171

172+
/// Sampling profiler frequency.
173+
double sampleProfilingFreq{100};
174+
172175
/// Start tracking heap objects before executing bytecode.
173176
bool heapTimeline{false};
174177
};

include/hermes/VM/RuntimeFlags.h

+6
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ struct VMOnlyRuntimeFlags {
102102
"Dump profile in Tracery format")),
103103
llvh::cl::cat(RuntimeCategory)};
104104

105+
llvh::cl::opt<double> SampleProfilingFreq{
106+
"sample-profiling-freq",
107+
llvh::cl::init(100),
108+
llvh::cl::desc("Sampling profiler frequency (in Hz)"),
109+
llvh::cl::cat(RuntimeCategory)};
110+
105111
llvh::cl::opt<MemorySize, false, MemorySizeParser> MaxHeapSize{
106112
"gc-max-heap",
107113
llvh::cl::desc("Max heap size. Format: <unsigned>{K,M,G}{iB}"),

lib/ConsoleHost/ConsoleHost.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ bool executeHBCBytecodeImpl(
452452

453453
#if HERMESVM_SAMPLING_PROFILER_AVAILABLE
454454
if (options.sampleProfiling != ExecuteOptions::SampleProfilingMode::None) {
455-
vm::SamplingProfiler::enable();
455+
vm::SamplingProfiler::enable(options.sampleProfilingFreq);
456456
}
457457
#endif // HERMESVM_SAMPLING_PROFILER_AVAILABLE
458458

tools/hermes/hermes.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static int executeHBCBytecodeFromCL(
124124
options.stopAfterInit = flags.StopAfterInit;
125125
options.forceGCBeforeStats = flags.GCBeforeStats;
126126
options.sampleProfiling = flags.SampleProfiling;
127+
options.sampleProfilingFreq = flags.SampleProfilingFreq;
127128
options.heapTimeline = flags.HeapTimeline;
128129

129130
bool success;

0 commit comments

Comments
 (0)