Commit 2031503a authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Emit trace event for background GC tasks.

The following events in v8.gc category are emitted:
- V8.GC_BACKGROUND_ARRAY_BUFFER_FREE
- V8.GC_BACKGROUND_STORE_BUFFER
- V8.GC_BACKGROUND_UNMAPPER
- V8.GC_MC_BACKGROUND_EVACUATE_COPY
- V8.GC_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS
- V8.GC_MC_BACKGROUND_MARKING
- V8.GC_MC_BACKGROUND_SWEEPING
- V8.GC_MINOR_MC_BACKGROUND_EVACUATE_COPY
- V8.GC_MINOR_MC_BACKGROUND_EVACUATE_UPDATE_POINTERS
- V8.GC_MINOR_MC_BACKGROUND_MARKING
- V8.GC_SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL

Bug: chromium:758183
Change-Id: I04368f75ac740cbc832a864609709e5a46f5baef
Reviewed-on: https://chromium-review.googlesource.com/825203
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50107}
parent 8e851453
......@@ -36,7 +36,7 @@ class ArrayBufferCollector::FreeingTask final : public CancelableTask {
private:
void RunInternal() final {
GCTracer::BackgroundScope scope(
TRACE_BACKGROUND_GC(
heap_->tracer(),
GCTracer::BackgroundScope::BACKGROUND_ARRAY_BUFFER_FREE);
heap_->array_buffer_collector()->FreeAllocations();
......
......@@ -439,8 +439,8 @@ ConcurrentMarking::ConcurrentMarking(Heap* heap, MarkingWorklist* shared,
}
void ConcurrentMarking::Run(int task_id, TaskState* task_state) {
GCTracer::BackgroundScope scope(
heap_->tracer(), GCTracer::BackgroundScope::MC_BACKGROUND_MARKING);
TRACE_BACKGROUND_GC(heap_->tracer(),
GCTracer::BackgroundScope::MC_BACKGROUND_MARKING);
size_t kBytesUntilInterruptCheck = 64 * KB;
int kObjectsUntilInterrupCheck = 1000;
LiveBytesMap* live_bytes = nullptr;
......
......@@ -80,7 +80,22 @@ const char* GCTracer::Scope::Name(ScopeId id) {
break;
}
#undef CASE
return "(unknown)";
UNREACHABLE();
return nullptr;
}
const char* GCTracer::BackgroundScope::Name(ScopeId id) {
#define CASE(scope) \
case BackgroundScope::scope: \
return "V8.GC_" #scope;
switch (id) {
TRACER_BACKGROUND_SCOPES(CASE)
case BackgroundScope::NUMBER_OF_SCOPES:
break;
}
#undef CASE
UNREACHABLE();
return nullptr;
}
GCTracer::Event::Event(Type type, GarbageCollectionReason gc_reason,
......
......@@ -31,6 +31,11 @@ enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects };
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"), \
GCTracer::Scope::Name(gc_tracer_scope_id))
#define TRACE_BACKGROUND_GC(tracer, scope_id) \
GCTracer::BackgroundScope background_scope(tracer, scope_id); \
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"), \
GCTracer::BackgroundScope::Name(scope_id))
// GCTracer collects and prints ONE line after each garbage collector
// invocation IFF --trace_gc is used.
class V8_EXPORT_PRIVATE GCTracer {
......@@ -109,6 +114,8 @@ class V8_EXPORT_PRIVATE GCTracer {
BackgroundScope(GCTracer* tracer, ScopeId scope);
~BackgroundScope();
static const char* Name(ScopeId id);
private:
GCTracer* tracer_;
ScopeId scope_;
......
......@@ -1920,7 +1920,7 @@ class ScavengingTask final : public ItemParallelJob::Task {
barrier_(barrier) {}
void RunInParallel() final {
GCTracer::BackgroundScope scope(
TRACE_BACKGROUND_GC(
heap_->tracer(),
GCTracer::BackgroundScope::SCAVENGER_BACKGROUND_SCAVENGE_PARALLEL);
double scavenging_time = 0.0;
......
......@@ -1853,9 +1853,8 @@ class YoungGenerationMarkingTask : public ItemParallelJob::Task {
}
void RunInParallel() override {
GCTracer::BackgroundScope scope(
collector_->heap()->tracer(),
GCTracer::BackgroundScope::MINOR_MC_BACKGROUND_MARKING);
TRACE_BACKGROUND_GC(collector_->heap()->tracer(),
GCTracer::BackgroundScope::MINOR_MC_BACKGROUND_MARKING);
double marking_time = 0.0;
{
TimedScope scope(&marking_time);
......@@ -3244,8 +3243,7 @@ class PageEvacuationTask : public ItemParallelJob::Task {
tracer_(isolate->heap()->tracer()) {}
void RunInParallel() override {
GCTracer::BackgroundScope scope(tracer_,
evacuator_->GetBackgroundTracingScope());
TRACE_BACKGROUND_GC(tracer_, evacuator_->GetBackgroundTracingScope());
PageEvacuationItem* item = nullptr;
while ((item = GetItem<PageEvacuationItem>()) != nullptr) {
evacuator_->EvacuatePage(item->page());
......@@ -3561,7 +3559,7 @@ class PointersUpdatingTask : public ItemParallelJob::Task {
scope_(scope) {}
void RunInParallel() override {
GCTracer::BackgroundScope scope(tracer_, scope_);
TRACE_BACKGROUND_GC(tracer_, scope_);
UpdatingItem* item = nullptr;
while ((item = GetItem<UpdatingItem>()) != nullptr) {
item->Process();
......
......@@ -320,8 +320,8 @@ class MemoryAllocator::Unmapper::UnmapFreeMemoryTask : public CancelableTask {
private:
void RunInternal() override {
GCTracer::BackgroundScope scope(
tracer_, GCTracer::BackgroundScope::BACKGROUND_UNMAPPER);
TRACE_BACKGROUND_GC(tracer_,
GCTracer::BackgroundScope::BACKGROUND_UNMAPPER);
unmapper_->PerformFreeMemoryOnQueuedChunks<FreeMode::kUncommitPooled>();
unmapper_->pending_unmapping_tasks_semaphore_.Signal();
}
......
......@@ -175,8 +175,8 @@ class StoreBuffer {
private:
void RunInternal() override {
GCTracer::BackgroundScope scope(
tracer_, GCTracer::BackgroundScope::BACKGROUND_STORE_BUFFER);
TRACE_BACKGROUND_GC(tracer_,
GCTracer::BackgroundScope::BACKGROUND_STORE_BUFFER);
store_buffer_->ConcurrentlyProcessStoreBuffer();
}
StoreBuffer* store_buffer_;
......
......@@ -76,8 +76,8 @@ class Sweeper::SweeperTask final : public CancelableTask {
private:
void RunInternal() final {
GCTracer::BackgroundScope scope(
tracer_, GCTracer::BackgroundScope::MC_BACKGROUND_SWEEPING);
TRACE_BACKGROUND_GC(tracer_,
GCTracer::BackgroundScope::MC_BACKGROUND_SWEEPING);
DCHECK_GE(space_to_start_, FIRST_PAGED_SPACE);
DCHECK_LE(space_to_start_, LAST_PAGED_SPACE);
const int offset = space_to_start_ - FIRST_PAGED_SPACE;
......@@ -529,8 +529,8 @@ class Sweeper::IterabilityTask final : public CancelableTask {
private:
void RunInternal() final {
GCTracer::BackgroundScope scope(
tracer_, GCTracer::BackgroundScope::MC_BACKGROUND_SWEEPING);
TRACE_BACKGROUND_GC(tracer_,
GCTracer::BackgroundScope::MC_BACKGROUND_SWEEPING);
for (Page* page : sweeper_->iterability_list_) {
sweeper_->MakeIterable(page);
}
......
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