diff options
author | Ben Becker <ben.becker@10gen.com> | 2013-03-29 15:44:08 -0700 |
---|---|---|
committer | Ben Becker <ben.becker@10gen.com> | 2013-03-29 15:44:28 -0700 |
commit | 6fc598a53ac23f9809f21142211749e9f1214acb (patch) | |
tree | c6cd3c6e99340ed94e459a3a63cd618dcc4074ca /src/mongo/scripting/engine_v8.cpp | |
parent | afb0f9b2434d53642df88376a30ee519c125d99d (diff) | |
download | mongo-6fc598a53ac23f9809f21142211749e9f1214acb.tar.gz |
SERVER-9185: add v8 GC epligoue stats
Diffstat (limited to 'src/mongo/scripting/engine_v8.cpp')
-rw-r--r-- | src/mongo/scripting/engine_v8.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/mongo/scripting/engine_v8.cpp b/src/mongo/scripting/engine_v8.cpp index 7bd3b1f234a..7bb4d8bd12a 100644 --- a/src/mongo/scripting/engine_v8.cpp +++ b/src/mongo/scripting/engine_v8.cpp @@ -296,6 +296,15 @@ namespace mongo { return v8::Boolean::New(false); } + /** + * GC Prologue and Epilogue constants (used to display description constants) + */ + struct GCPrologueState { static const char* name; }; + const char* GCPrologueState::name = "prologue"; + struct GCEpilogueState { static const char* name; }; + const char* GCEpilogueState::name = "epilogue"; + + template <typename _GCState> void gcCallback(v8::GCType type, v8::GCCallbackFlags flags) { const int verbosity = 1; // log level for stat collection if (logLevel < verbosity) @@ -304,12 +313,13 @@ namespace mongo { v8::HeapStatistics stats; v8::V8::GetHeapStatistics(&stats); - LOG(verbosity) << "V8 GC heap stats - " - << " total: " << stats.total_heap_size() - << " exec: " << stats.total_heap_size_executable() - << " used: " << stats.used_heap_size()<< " limit: " - << stats.heap_size_limit() - << endl; + log() << "V8 GC " << _GCState::name + << " heap stats - " + << " total: " << stats.total_heap_size() + << " exec: " << stats.total_heap_size_executable() + << " used: " << stats.used_heap_size()<< " limit: " + << stats.heap_size_limit() + << endl; } V8ScriptEngine::V8ScriptEngine() : @@ -466,7 +476,8 @@ namespace mongo { v8::Context::Scope context_scope(_context); // display heap statistics on MarkAndSweep GC run - v8::V8::AddGCPrologueCallback(gcCallback, v8::kGCTypeMarkSweepCompact); + v8::V8::AddGCPrologueCallback(gcCallback<GCPrologueState>, v8::kGCTypeMarkSweepCompact); + v8::V8::AddGCEpilogueCallback(gcCallback<GCEpilogueState>, v8::kGCTypeMarkSweepCompact); // if the isolate runs out of heap space, raise a flag on the StackGuard instead of // calling abort() |