Commit a5fc4e08 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[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/797038Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49724}
parent 5d433b2d
...@@ -1631,6 +1631,8 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForBackgroundCompile( ...@@ -1631,6 +1631,8 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForBackgroundCompile(
CompilationJob* outer_function_job, CompilationJob* outer_function_job,
CompilationJobList* inner_function_jobs) { CompilationJobList* inner_function_jobs) {
Isolate* isolate = script->GetIsolate(); Isolate* isolate = script->GetIsolate();
ScriptCompileTimerScope compile_timer(
isolate, ScriptCompiler::kNoCacheBecauseStreamingSource);
PostponeInterruptsScope postpone(isolate); PostponeInterruptsScope postpone(isolate);
// TODO(titzer): increment the counters in caller. // TODO(titzer): increment the counters in caller.
...@@ -1655,6 +1657,8 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForBackgroundCompile( ...@@ -1655,6 +1657,8 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForBackgroundCompile(
Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForStreamedScript( Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForStreamedScript(
Handle<Script> script, ParseInfo* parse_info, int source_length) { Handle<Script> script, ParseInfo* parse_info, int source_length) {
Isolate* isolate = script->GetIsolate(); Isolate* isolate = script->GetIsolate();
ScriptCompileTimerScope compile_timer(
isolate, ScriptCompiler::kNoCacheBecauseStreamingSource);
// TODO(titzer): increment the counters in caller. // TODO(titzer): increment the counters in caller.
isolate->counters()->total_load_size()->Increment(source_length); isolate->counters()->total_load_size()->Increment(source_length);
isolate->counters()->total_compile_size()->Increment(source_length); isolate->counters()->total_compile_size()->Increment(source_length);
......
...@@ -128,11 +128,6 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic { ...@@ -128,11 +128,6 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
static Handle<SharedFunctionInfo> GetSharedFunctionInfoForStreamedScript( static Handle<SharedFunctionInfo> GetSharedFunctionInfoForStreamedScript(
Handle<Script> script, ParseInfo* info, int source_length); Handle<Script> script, ParseInfo* info, int source_length);
// Create a shared function info object (the code may be lazily compiled).
static Handle<SharedFunctionInfo> GetSharedFunctionInfo(FunctionLiteral* node,
Handle<Script> script,
Isolate* isolate);
// Create a shared function info object for a Script that has already been // Create a shared function info object for a Script that has already been
// compiled on a background thread. // compiled on a background thread.
static Handle<SharedFunctionInfo> GetSharedFunctionInfoForBackgroundCompile( static Handle<SharedFunctionInfo> GetSharedFunctionInfoForBackgroundCompile(
...@@ -140,6 +135,12 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic { ...@@ -140,6 +135,12 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
CompilationJob* outer_function_job, CompilationJob* outer_function_job,
CompilationJobList* inner_function_jobs); CompilationJobList* inner_function_jobs);
// Create a shared function info object for the given function literal
// node (the code may be lazily compiled).
static Handle<SharedFunctionInfo> GetSharedFunctionInfo(FunctionLiteral* node,
Handle<Script> script,
Isolate* isolate);
// =========================================================================== // ===========================================================================
// The following family of methods provides support for OSR. Code generated // The following family of methods provides support for OSR. Code generated
// for entry via OSR might not be suitable for normal entry, hence will be // for entry via OSR might not be suitable for normal entry, hence will be
......
...@@ -1152,7 +1152,9 @@ class RuntimeCallTimerScope { ...@@ -1152,7 +1152,9 @@ class RuntimeCallTimerScope {
V8.CompileScriptMicroSeconds.NoCache.ScriptTooSmall, 1000000, \ V8.CompileScriptMicroSeconds.NoCache.ScriptTooSmall, 1000000, \
MICROSECOND) \ MICROSECOND) \
HT(compile_script_no_cache_because_cache_too_cold, \ HT(compile_script_no_cache_because_cache_too_cold, \
V8.CompileScriptMicroSeconds.NoCache.CacheTooCold, 1000000, MICROSECOND) V8.CompileScriptMicroSeconds.NoCache.CacheTooCold, 1000000, MICROSECOND) \
HT(compile_script_on_background, \
V8.CompileScriptMicroSeconds.BackgroundThread, 1000000, MICROSECOND)
#define AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) \ #define AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) \
AHT(compile_lazy, V8.CompileLazyMicroSeconds) AHT(compile_lazy, V8.CompileLazyMicroSeconds)
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "src/parsing/background-parsing-task.h" #include "src/parsing/background-parsing-task.h"
#include "src/counters.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/parsing/parser.h" #include "src/parsing/parser.h"
#include "src/parsing/scanner-character-streams.h" #include "src/parsing/scanner-character-streams.h"
...@@ -20,7 +21,10 @@ void StreamedSource::Release() { ...@@ -20,7 +21,10 @@ void StreamedSource::Release() {
BackgroundParsingTask::BackgroundParsingTask( BackgroundParsingTask::BackgroundParsingTask(
StreamedSource* source, ScriptCompiler::CompileOptions options, StreamedSource* source, ScriptCompiler::CompileOptions options,
int stack_size, Isolate* isolate) int stack_size, Isolate* isolate)
: source_(source), stack_size_(stack_size), script_data_(nullptr) { : source_(source),
stack_size_(stack_size),
script_data_(nullptr),
timer_(isolate->counters()->compile_script_on_background()) {
// We don't set the context to the CompilationInfo yet, because the background // We don't set the context to the CompilationInfo yet, because the background
// thread cannot do anything with it anyway. We set it just before compilation // thread cannot do anything with it anyway. We set it just before compilation
// on the foreground thread. // on the foreground thread.
...@@ -67,6 +71,7 @@ BackgroundParsingTask::BackgroundParsingTask( ...@@ -67,6 +71,7 @@ BackgroundParsingTask::BackgroundParsingTask(
} }
void BackgroundParsingTask::Run() { void BackgroundParsingTask::Run() {
TimedHistogramScope timer(timer_);
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
DisallowHandleAllocation no_handles; DisallowHandleAllocation no_handles;
DisallowHandleDereference no_deref; DisallowHandleDereference no_deref;
......
...@@ -19,6 +19,7 @@ namespace internal { ...@@ -19,6 +19,7 @@ namespace internal {
class Parser; class Parser;
class ScriptData; class ScriptData;
class TimedHistogram;
// Internal representation of v8::ScriptCompiler::StreamedSource. Contains all // Internal representation of v8::ScriptCompiler::StreamedSource. Contains all
// data which needs to be transmitted between threads for background parsing, // data which needs to be transmitted between threads for background parsing,
...@@ -64,6 +65,7 @@ class BackgroundParsingTask : public ScriptCompiler::ScriptStreamingTask { ...@@ -64,6 +65,7 @@ class BackgroundParsingTask : public ScriptCompiler::ScriptStreamingTask {
int stack_size_; int stack_size_;
ScriptData* script_data_; ScriptData* script_data_;
AccountingAllocator* allocator_; AccountingAllocator* allocator_;
TimedHistogram* timer_;
}; };
} // namespace internal } // namespace internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment