Skip to content

Commit a5fc4e0

Browse files
rmcilroyCommit Bot
authored andcommitted
[Counters] Add histogram timers for StreamingSource compiles.
Adds histogram timing for main-thread portions of streaming source compilation. Also adds a histogram timer for capturing the amount of time spent for off-thread parse / compile of streaming sources. BUG=v8:5203 Change-Id: Ie9f16052205832a620cfbf266d3d66d3fe9d6c12 Reviewed-on: https://chromium-review.googlesource.com/797038 Reviewed-by: Adam Klein <[email protected]> Reviewed-by: Leszek Swirski <[email protected]> Commit-Queue: Ross McIlroy <[email protected]> Cr-Commit-Position: refs/heads/master@{#49724}
1 parent 5d433b2 commit a5fc4e0

5 files changed

Lines changed: 21 additions & 7 deletions

File tree

src/compiler.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,8 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForBackgroundCompile(
16311631
CompilationJob* outer_function_job,
16321632
CompilationJobList* inner_function_jobs) {
16331633
Isolate* isolate = script->GetIsolate();
1634+
ScriptCompileTimerScope compile_timer(
1635+
isolate, ScriptCompiler::kNoCacheBecauseStreamingSource);
16341636
PostponeInterruptsScope postpone(isolate);
16351637

16361638
// TODO(titzer): increment the counters in caller.
@@ -1655,6 +1657,8 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForBackgroundCompile(
16551657
Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForStreamedScript(
16561658
Handle<Script> script, ParseInfo* parse_info, int source_length) {
16571659
Isolate* isolate = script->GetIsolate();
1660+
ScriptCompileTimerScope compile_timer(
1661+
isolate, ScriptCompiler::kNoCacheBecauseStreamingSource);
16581662
// TODO(titzer): increment the counters in caller.
16591663
isolate->counters()->total_load_size()->Increment(source_length);
16601664
isolate->counters()->total_compile_size()->Increment(source_length);

src/compiler.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,19 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
128128
static Handle<SharedFunctionInfo> GetSharedFunctionInfoForStreamedScript(
129129
Handle<Script> script, ParseInfo* info, int source_length);
130130

131-
// Create a shared function info object (the code may be lazily compiled).
132-
static Handle<SharedFunctionInfo> GetSharedFunctionInfo(FunctionLiteral* node,
133-
Handle<Script> script,
134-
Isolate* isolate);
135-
136131
// Create a shared function info object for a Script that has already been
137132
// compiled on a background thread.
138133
static Handle<SharedFunctionInfo> GetSharedFunctionInfoForBackgroundCompile(
139134
Handle<Script> script, ParseInfo* parse_info, int source_length,
140135
CompilationJob* outer_function_job,
141136
CompilationJobList* inner_function_jobs);
142137

138+
// Create a shared function info object for the given function literal
139+
// node (the code may be lazily compiled).
140+
static Handle<SharedFunctionInfo> GetSharedFunctionInfo(FunctionLiteral* node,
141+
Handle<Script> script,
142+
Isolate* isolate);
143+
143144
// ===========================================================================
144145
// The following family of methods provides support for OSR. Code generated
145146
// for entry via OSR might not be suitable for normal entry, hence will be

src/counters.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,9 @@ class RuntimeCallTimerScope {
11521152
V8.CompileScriptMicroSeconds.NoCache.ScriptTooSmall, 1000000, \
11531153
MICROSECOND) \
11541154
HT(compile_script_no_cache_because_cache_too_cold, \
1155-
V8.CompileScriptMicroSeconds.NoCache.CacheTooCold, 1000000, MICROSECOND)
1155+
V8.CompileScriptMicroSeconds.NoCache.CacheTooCold, 1000000, MICROSECOND) \
1156+
HT(compile_script_on_background, \
1157+
V8.CompileScriptMicroSeconds.BackgroundThread, 1000000, MICROSECOND)
11561158

11571159
#define AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) \
11581160
AHT(compile_lazy, V8.CompileLazyMicroSeconds)

src/parsing/background-parsing-task.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "src/parsing/background-parsing-task.h"
66

7+
#include "src/counters.h"
78
#include "src/objects-inl.h"
89
#include "src/parsing/parser.h"
910
#include "src/parsing/scanner-character-streams.h"
@@ -20,7 +21,10 @@ void StreamedSource::Release() {
2021
BackgroundParsingTask::BackgroundParsingTask(
2122
StreamedSource* source, ScriptCompiler::CompileOptions options,
2223
int stack_size, Isolate* isolate)
23-
: source_(source), stack_size_(stack_size), script_data_(nullptr) {
24+
: source_(source),
25+
stack_size_(stack_size),
26+
script_data_(nullptr),
27+
timer_(isolate->counters()->compile_script_on_background()) {
2428
// We don't set the context to the CompilationInfo yet, because the background
2529
// thread cannot do anything with it anyway. We set it just before compilation
2630
// on the foreground thread.
@@ -67,6 +71,7 @@ BackgroundParsingTask::BackgroundParsingTask(
6771
}
6872

6973
void BackgroundParsingTask::Run() {
74+
TimedHistogramScope timer(timer_);
7075
DisallowHeapAllocation no_allocation;
7176
DisallowHandleAllocation no_handles;
7277
DisallowHandleDereference no_deref;

src/parsing/background-parsing-task.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace internal {
1919

2020
class Parser;
2121
class ScriptData;
22+
class TimedHistogram;
2223

2324
// Internal representation of v8::ScriptCompiler::StreamedSource. Contains all
2425
// data which needs to be transmitted between threads for background parsing,
@@ -64,6 +65,7 @@ class BackgroundParsingTask : public ScriptCompiler::ScriptStreamingTask {
6465
int stack_size_;
6566
ScriptData* script_data_;
6667
AccountingAllocator* allocator_;
68+
TimedHistogram* timer_;
6769
};
6870

6971
} // namespace internal

0 commit comments

Comments
 (0)