Skip to content

Commit 2d0d210

Browse files
author
mstarzinger@chromium.org
committed
Add histograms to track fraction of heap spaces and percentage of generated crankshaft code.
BUG=None R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/27023003 Patch from Ross McIlroy <rmcilroy@chromium.org>. git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17198 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
1 parent 83c63cf commit 2d0d210

4 files changed

Lines changed: 59 additions & 0 deletions

File tree

src/codegen.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm,
116116
false, is_crankshafted);
117117
isolate->counters()->total_compiled_code_size()->Increment(
118118
code->instruction_size());
119+
isolate->heap()->IncrementCodeGeneratedBytes(is_crankshafted,
120+
code->instruction_size());
119121
code->set_prologue_offset(info->prologue_offset());
120122
return code;
121123
}

src/heap.cc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ Heap::Heap()
141141
mark_sweeps_since_idle_round_started_(0),
142142
gc_count_at_last_idle_gc_(0),
143143
scavenges_since_last_idle_round_(kIdleScavengeThreshold),
144+
full_codegen_bytes_generated_(0),
145+
crankshaft_codegen_bytes_generated_(0),
144146
gcs_since_last_deopt_(0),
145147
#ifdef VERIFY_HEAP
146148
no_weak_object_verification_scope_depth_(0),
@@ -508,10 +510,31 @@ void Heap::GarbageCollectionEpilogue() {
508510
isolate_->counters()->number_of_symbols()->Set(
509511
string_table()->NumberOfElements());
510512

513+
if (full_codegen_bytes_generated_ + crankshaft_codegen_bytes_generated_ > 0) {
514+
isolate_->counters()->codegen_fraction_crankshaft()->AddSample(
515+
static_cast<int>((crankshaft_codegen_bytes_generated_ * 100.0) /
516+
(crankshaft_codegen_bytes_generated_
517+
+ full_codegen_bytes_generated_)));
518+
}
519+
511520
if (CommittedMemory() > 0) {
512521
isolate_->counters()->external_fragmentation_total()->AddSample(
513522
static_cast<int>(100 - (SizeOfObjects() * 100.0) / CommittedMemory()));
514523

524+
isolate_->counters()->heap_fraction_new_space()->
525+
AddSample(static_cast<int>(
526+
(new_space()->CommittedMemory() * 100.0) / CommittedMemory()));
527+
isolate_->counters()->heap_fraction_old_pointer_space()->AddSample(
528+
static_cast<int>(
529+
(old_pointer_space()->CommittedMemory() * 100.0) /
530+
CommittedMemory()));
531+
isolate_->counters()->heap_fraction_old_data_space()->AddSample(
532+
static_cast<int>(
533+
(old_data_space()->CommittedMemory() * 100.0) /
534+
CommittedMemory()));
535+
isolate_->counters()->heap_fraction_code_space()->
536+
AddSample(static_cast<int>(
537+
(code_space()->CommittedMemory() * 100.0) / CommittedMemory()));
515538
isolate_->counters()->heap_fraction_map_space()->AddSample(
516539
static_cast<int>(
517540
(map_space()->CommittedMemory() * 100.0) / CommittedMemory()));
@@ -522,6 +545,9 @@ void Heap::GarbageCollectionEpilogue() {
522545
AddSample(static_cast<int>(
523546
(property_cell_space()->CommittedMemory() * 100.0) /
524547
CommittedMemory()));
548+
isolate_->counters()->heap_fraction_lo_space()->
549+
AddSample(static_cast<int>(
550+
(lo_space()->CommittedMemory() * 100.0) / CommittedMemory()));
525551

526552
isolate_->counters()->heap_sample_total_committed()->AddSample(
527553
static_cast<int>(CommittedMemory() / KB));
@@ -535,6 +561,8 @@ void Heap::GarbageCollectionEpilogue() {
535561
heap_sample_property_cell_space_committed()->
536562
AddSample(static_cast<int>(
537563
property_cell_space()->CommittedMemory() / KB));
564+
isolate_->counters()->heap_sample_code_space_committed()->AddSample(
565+
static_cast<int>(code_space()->CommittedMemory() / KB));
538566
}
539567

540568
#define UPDATE_COUNTERS_FOR_SPACE(space) \

src/heap.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,14 @@ class Heap {
16761676
total_regexp_code_generated_ += size;
16771677
}
16781678

1679+
void IncrementCodeGeneratedBytes(bool is_crankshafted, int size) {
1680+
if (is_crankshafted) {
1681+
crankshaft_codegen_bytes_generated_ += size;
1682+
} else {
1683+
full_codegen_bytes_generated_ += size;
1684+
}
1685+
}
1686+
16791687
// Returns maximum GC pause.
16801688
double get_max_gc_pause() { return max_gc_pause_; }
16811689

@@ -2371,6 +2379,10 @@ class Heap {
23712379
unsigned int gc_count_at_last_idle_gc_;
23722380
int scavenges_since_last_idle_round_;
23732381

2382+
// These two counters are monotomically increasing and never reset.
2383+
size_t full_codegen_bytes_generated_;
2384+
size_t crankshaft_codegen_bytes_generated_;
2385+
23742386
// If the --deopt_every_n_garbage_collections flag is set to a positive value,
23752387
// this variable holds the number of garbage collections since the last
23762388
// deoptimization triggered by garbage collection.

src/v8-counters.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ namespace internal {
5151
HT(compile_lazy, V8.CompileLazy)
5252

5353
#define HISTOGRAM_PERCENTAGE_LIST(HP) \
54+
/* Heap fragmentation. */ \
5455
HP(external_fragmentation_total, \
5556
V8.MemoryExternalFragmentationTotal) \
5657
HP(external_fragmentation_old_pointer_space, \
@@ -67,12 +68,26 @@ namespace internal {
6768
V8.MemoryExternalFragmentationPropertyCellSpace) \
6869
HP(external_fragmentation_lo_space, \
6970
V8.MemoryExternalFragmentationLoSpace) \
71+
/* Percentages of heap committed to each space. */ \
72+
HP(heap_fraction_new_space, \
73+
V8.MemoryHeapFractionNewSpace) \
74+
HP(heap_fraction_old_pointer_space, \
75+
V8.MemoryHeapFractionOldPointerSpace) \
76+
HP(heap_fraction_old_data_space, \
77+
V8.MemoryHeapFractionOldDataSpace) \
78+
HP(heap_fraction_code_space, \
79+
V8.MemoryHeapFractionCodeSpace) \
7080
HP(heap_fraction_map_space, \
7181
V8.MemoryHeapFractionMapSpace) \
7282
HP(heap_fraction_cell_space, \
7383
V8.MemoryHeapFractionCellSpace) \
7484
HP(heap_fraction_property_cell_space, \
7585
V8.MemoryHeapFractionPropertyCellSpace) \
86+
HP(heap_fraction_lo_space, \
87+
V8.MemoryHeapFractionLoSpace) \
88+
/* Percentage of crankshafted codegen. */ \
89+
HP(codegen_fraction_crankshaft, \
90+
V8.CodegenFractionCrankshaft) \
7691

7792

7893
#define HISTOGRAM_MEMORY_LIST(HM) \
@@ -84,6 +99,8 @@ namespace internal {
8499
V8.MemoryHeapSampleCellSpaceCommitted) \
85100
HM(heap_sample_property_cell_space_committed, \
86101
V8.MemoryHeapSamplePropertyCellSpaceCommitted) \
102+
HM(heap_sample_code_space_committed, \
103+
V8.MemoryHeapSampleCodeSpaceCommitted) \
87104

88105

89106
// WARNING: STATS_COUNTER_LIST_* is a very large macro that is causing MSVC

0 commit comments

Comments
 (0)