Commit df421e87 authored by Adithya Srinivasan's avatar Adithya Srinivasan Committed by Commit Bot

Add RCS to V8PerIsolateData and cmdline switch

- Adds an instance of RCS to V8PerIsolateData
- Logs RCS table in RenderThread::Shutdown (behind a flag)

Bug: 724542
Change-Id: I496c76c4e79ba5011b90b512c2bd02cd5b6056a2
Reviewed-on: https://chromium-review.googlesource.com/517562
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#476337}
parent 3c26208e
...@@ -333,6 +333,10 @@ const char kDisable2dCanvasClipAntialiasing[] = "disable-2d-canvas-clip-aa"; ...@@ -333,6 +333,10 @@ const char kDisable2dCanvasClipAntialiasing[] = "disable-2d-canvas-clip-aa";
const char kDisableAcceleratedJpegDecoding[] = const char kDisableAcceleratedJpegDecoding[] =
"disable-accelerated-jpeg-decoding"; "disable-accelerated-jpeg-decoding";
// Logs Runtime Call Stats for Blink. --single-process also needs to be
// used along with this for the stats to be logged.
const char kDumpBlinkRuntimeCallStats[] = "dump-blink-runtime-call-stats";
// Enables LCD text. // Enables LCD text.
const char kEnableLCDText[] = "enable-lcd-text"; const char kEnableLCDText[] = "enable-lcd-text";
......
...@@ -106,6 +106,7 @@ CONTENT_EXPORT extern const char kDisableZeroCopy[]; ...@@ -106,6 +106,7 @@ CONTENT_EXPORT extern const char kDisableZeroCopy[];
CONTENT_EXPORT extern const char kDisableZeroCopyDxgiVideo[]; CONTENT_EXPORT extern const char kDisableZeroCopyDxgiVideo[];
CONTENT_EXPORT extern const char kDomAutomationController[]; CONTENT_EXPORT extern const char kDomAutomationController[];
extern const char kDisable2dCanvasClipAntialiasing[]; extern const char kDisable2dCanvasClipAntialiasing[];
CONTENT_EXPORT extern const char kDumpBlinkRuntimeCallStats[];
CONTENT_EXPORT extern const char kEnableAggressiveDOMStorageFlushing[]; CONTENT_EXPORT extern const char kEnableAggressiveDOMStorageFlushing[];
CONTENT_EXPORT extern const char kEnablePreferCompositingToLCDText[]; CONTENT_EXPORT extern const char kEnablePreferCompositingToLCDText[];
CONTENT_EXPORT extern const char kEnableBlinkFeatures[]; CONTENT_EXPORT extern const char kEnableBlinkFeatures[];
......
...@@ -932,6 +932,10 @@ void RenderThreadImpl::Shutdown() { ...@@ -932,6 +932,10 @@ void RenderThreadImpl::Shutdown() {
// evaluation and debugging. // evaluation and debugging.
blink::MainThreadIsolate()->DumpAndResetStats(); blink::MainThreadIsolate()->DumpAndResetStats();
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDumpBlinkRuntimeCallStats))
blink::LogRuntimeCallStats();
// In a single-process mode, we cannot call _exit(0) in Shutdown() because // In a single-process mode, we cannot call _exit(0) in Shutdown() because
// it will exit the process before the browser side is ready to exit. // it will exit the process before the browser side is ready to exit.
if (!base::CommandLine::ForCurrentProcess()->HasSwitch( if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <inttypes.h> #include <inttypes.h>
#include <algorithm> #include <algorithm>
#include "platform/bindings/V8PerIsolateData.h"
#include "platform/wtf/text/StringBuilder.h" #include "platform/wtf/text/StringBuilder.h"
namespace blink { namespace blink {
...@@ -43,6 +44,11 @@ RuntimeCallStats::RuntimeCallStats() { ...@@ -43,6 +44,11 @@ RuntimeCallStats::RuntimeCallStats() {
} }
} }
// static
RuntimeCallStats* RuntimeCallStats::From(v8::Isolate* isolate) {
return V8PerIsolateData::From(isolate)->GetRuntimeCallStats();
}
void RuntimeCallStats::Reset() { void RuntimeCallStats::Reset() {
for (int i = 0; i < number_of_counters_; i++) { for (int i = 0; i < number_of_counters_; i++) {
counters_[i].Reset(); counters_[i].Reset();
...@@ -55,7 +61,7 @@ String RuntimeCallStats::ToString() const { ...@@ -55,7 +61,7 @@ String RuntimeCallStats::ToString() const {
builder.Append("Name Count Time (ms)\n\n"); builder.Append("Name Count Time (ms)\n\n");
for (int i = 0; i < number_of_counters_; i++) { for (int i = 0; i < number_of_counters_; i++) {
const RuntimeCallCounter* counter = &counters_[i]; const RuntimeCallCounter* counter = &counters_[i];
builder.Append(String::Format("%-32s %8" PRIu64 "%8.3f\n", builder.Append(String::Format("%-32s %8" PRIu64 " %9.3f\n",
counter->GetName(), counter->GetCount(), counter->GetName(), counter->GetCount(),
counter->GetTime().InMillisecondsF())); counter->GetTime().InMillisecondsF()));
} }
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// This file contains the Blink version of RuntimeCallStats which is implemented
// by V8 in //v8/src/counters.h
#ifndef RuntimeCallStats_h #ifndef RuntimeCallStats_h
#define RuntimeCallStats_h #define RuntimeCallStats_h
...@@ -9,6 +12,7 @@ ...@@ -9,6 +12,7 @@
#include "platform/wtf/Allocator.h" #include "platform/wtf/Allocator.h"
#include "platform/wtf/Time.h" #include "platform/wtf/Time.h"
#include "platform/wtf/text/WTFString.h" #include "platform/wtf/text/WTFString.h"
#include "v8/include/v8.h"
namespace blink { namespace blink {
...@@ -90,6 +94,8 @@ class PLATFORM_EXPORT RuntimeCallTimer { ...@@ -90,6 +94,8 @@ class PLATFORM_EXPORT RuntimeCallTimer {
class PLATFORM_EXPORT RuntimeCallStats { class PLATFORM_EXPORT RuntimeCallStats {
public: public:
RuntimeCallStats(); RuntimeCallStats();
// Get RuntimeCallStats object associated with the given isolate.
static RuntimeCallStats* From(v8::Isolate*);
// Counters // Counters
#define FOR_EACH_COUNTER(V) \ #define FOR_EACH_COUNTER(V) \
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "gin/public/isolate_holder.h" #include "gin/public/isolate_holder.h"
#include "gin/public/v8_idle_task_runner.h" #include "gin/public/v8_idle_task_runner.h"
#include "platform/PlatformExport.h" #include "platform/PlatformExport.h"
#include "platform/bindings/RuntimeCallStats.h"
#include "platform/bindings/ScopedPersistent.h" #include "platform/bindings/ScopedPersistent.h"
#include "platform/bindings/ScriptState.h" #include "platform/bindings/ScriptState.h"
#include "platform/bindings/ScriptWrappableVisitor.h" #include "platform/bindings/ScriptWrappableVisitor.h"
...@@ -120,6 +121,8 @@ class PLATFORM_EXPORT V8PerIsolateData { ...@@ -120,6 +121,8 @@ class PLATFORM_EXPORT V8PerIsolateData {
StringCache* GetStringCache() { return string_cache_.get(); } StringCache* GetStringCache() { return string_cache_.get(); }
RuntimeCallStats* GetRuntimeCallStats() { return &runtime_call_stats_; }
bool IsHandlingRecursionLevelError() const { bool IsHandlingRecursionLevelError() const {
return is_handling_recursion_level_error_; return is_handling_recursion_level_error_;
} }
...@@ -267,6 +270,8 @@ class PLATFORM_EXPORT V8PerIsolateData { ...@@ -267,6 +270,8 @@ class PLATFORM_EXPORT V8PerIsolateData {
Persistent<ActiveScriptWrappableSet> active_script_wrappables_; Persistent<ActiveScriptWrappableSet> active_script_wrappables_;
std::unique_ptr<ScriptWrappableVisitor> script_wrappable_visitor_; std::unique_ptr<ScriptWrappableVisitor> script_wrappable_visitor_;
RuntimeCallStats runtime_call_stats_;
}; };
} // namespace blink } // namespace blink
......
...@@ -141,4 +141,10 @@ void SetRAILModeOnWorkerThreadIsolates(v8::RAILMode rail_mode) { ...@@ -141,4 +141,10 @@ void SetRAILModeOnWorkerThreadIsolates(v8::RAILMode rail_mode) {
WorkerBackingThread::SetRAILModeOnWorkerThreadIsolates(rail_mode); WorkerBackingThread::SetRAILModeOnWorkerThreadIsolates(rail_mode);
} }
void LogRuntimeCallStats() {
LOG(INFO)
<< "\n"
<< RuntimeCallStats::From(MainThreadIsolate())->ToString().Utf8().data();
}
} // namespace blink } // namespace blink
...@@ -75,6 +75,9 @@ BLINK_EXPORT void MemoryPressureNotificationToWorkerThreadIsolates( ...@@ -75,6 +75,9 @@ BLINK_EXPORT void MemoryPressureNotificationToWorkerThreadIsolates(
// Set the RAIL performance mode on all worker thread isolates. // Set the RAIL performance mode on all worker thread isolates.
BLINK_EXPORT void SetRAILModeOnWorkerThreadIsolates(v8::RAILMode); BLINK_EXPORT void SetRAILModeOnWorkerThreadIsolates(v8::RAILMode);
// Logs Runtime Call Stats table for Blink.
BLINK_EXPORT void LogRuntimeCallStats();
} // namespace blink } // namespace blink
#endif #endif
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