Skip to content

Commit

Permalink
Add historgram for number of GC needed to collect a detached context.
Browse files Browse the repository at this point in the history
BUG=

Review URL: https://codereview.chromium.org/934773002

Cr-Commit-Position: refs/heads/master@{#26690}
  • Loading branch information
ulan authored and Commit bot committed Feb 17, 2015
1 parent cc1458a commit 66ca91b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ class AggregatedHistogramTimerScope {

#define HISTOGRAM_RANGE_LIST(HR) \
/* Generic range histograms */ \
HR(detached_context_age_in_gc, V8.DetachedContextAgeInGC, 0, 20, 21) \
HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \
HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \
HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, \
Expand Down
5 changes: 4 additions & 1 deletion src/flag-definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,11 @@ DEFINE_BOOL(trace_incremental_marking, false,
"trace progress of the incremental marking")
DEFINE_BOOL(track_gc_object_stats, false,
"track object counts and memory usage")
DEFINE_BOOL(track_detached_contexts, false,
DEFINE_BOOL(track_detached_contexts, true,
"track native contexts that are expected to be garbage collected")
DEFINE_BOOL(trace_detached_contexts, false,
"trace native contexts that are expected to be garbage collected")
DEFINE_IMPLICATION(trace_detached_contexts, track_detached_contexts)
#ifdef VERIFY_HEAP
DEFINE_BOOL(verify_heap, false, "verify heap pointers before and after GC")
#endif
Expand Down
24 changes: 14 additions & 10 deletions src/isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2598,21 +2598,25 @@ void Isolate::CheckDetachedContextsAfterGC() {
detached_contexts->set(new_length, Smi::FromInt(mark_sweeps + 1));
detached_contexts->set(new_length + 1, cell);
new_length += 2;
} else {
counters()->detached_context_age_in_gc()->AddSample(mark_sweeps);
}
}
PrintF("%d detached contexts are collected out of %d\n", length - new_length,
length);
for (int i = 0; i < new_length; i += 2) {
int mark_sweeps = Smi::cast(detached_contexts->get(i))->value();
WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1));
if (mark_sweeps > 3) {
PrintF("detached context 0x%p\n survived %d GCs (leak?)\n",
static_cast<void*>(cell->value()), mark_sweeps);
if (FLAG_trace_detached_contexts) {
PrintF("%d detached contexts are collected out of %d\n",
length - new_length, length);
for (int i = 0; i < new_length; i += 2) {
int mark_sweeps = Smi::cast(detached_contexts->get(i))->value();
WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1));
if (mark_sweeps > 3) {
PrintF("detached context 0x%p\n survived %d GCs (leak?)\n",
static_cast<void*>(cell->value()), mark_sweeps);
}
}
}
if (length == new_length) {
if (new_length == 0) {
heap()->set_detached_contexts(heap()->empty_fixed_array());
} else {
} else if (new_length < length) {
heap()->RightTrimFixedArray<Heap::FROM_GC>(*detached_contexts,
length - new_length);
}
Expand Down

0 comments on commit 66ca91b

Please sign in to comment.