Commit 7d69193f authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

cppgc: Populate TraceSummary in TraceEpilogue

This was missing in CppHeap which means the used_bytes counter in
EmbedderTracing was reset to 0 after every GC.

Bug: chromium:1056170
Change-Id: Iddb0aa1eff9cc354622653376c6623364e015c5d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2732668
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73167}
parent 975ef0c6
......@@ -384,6 +384,9 @@ void CppHeap::TraceEpilogue(TraceSummary* trace_summary) {
sweeping_config.sweeping_type);
sweeper().Start(sweeping_config);
}
DCHECK_NOT_NULL(trace_summary);
trace_summary->allocated_size = stats_collector_->marked_bytes();
trace_summary->time = stats_collector_->marking_time().InMillisecondsF();
in_atomic_pause_ = false;
sweeper().NotifyDoneIfNeeded();
}
......@@ -431,7 +434,8 @@ void CppHeap::CollectGarbageForTesting(
TracePrologue(TraceFlags::kForced);
EnterFinalPause(stack_state);
AdvanceTracing(std::numeric_limits<double>::infinity());
TraceEpilogue(nullptr);
TraceSummary trace_summary;
TraceEpilogue(&trace_summary);
}
}
......
......@@ -7,7 +7,9 @@
#include <algorithm>
#include <cmath>
#include "src/base/atomicops.h"
#include "src/base/logging.h"
#include "src/base/platform/time.h"
#include "src/heap/cppgc/metric-recorder.h"
namespace cppgc {
......@@ -234,6 +236,28 @@ size_t StatsCollector::allocated_object_size() const {
allocated_bytes_since_end_of_marking_);
}
size_t StatsCollector::marked_bytes() const {
DCHECK_NE(GarbageCollectionState::kMarking, gc_state_);
// During sweeping we refer to the current Event as that already holds the
// correct marking information. In all other phases, the previous event holds
// the most up-to-date marking information.
const Event& event =
gc_state_ == GarbageCollectionState::kSweeping ? current_ : previous_;
return event.marked_bytes;
}
v8::base::TimeDelta StatsCollector::marking_time() const {
DCHECK_NE(GarbageCollectionState::kMarking, gc_state_);
// During sweeping we refer to the current Event as that already holds the
// correct marking information. In all other phases, the previous event holds
// the most up-to-date marking information.
const Event& event =
gc_state_ == GarbageCollectionState::kSweeping ? current_ : previous_;
return event.scope_data[kAtomicMark] + event.scope_data[kIncrementalMark] +
v8::base::TimeDelta::FromMicroseconds(v8::base::Relaxed_Load(
&event.concurrent_scope_data[kConcurrentMark]));
}
void StatsCollector::NotifyAllocatedMemory(int64_t size) {
memory_allocated_bytes_ += size;
ForAllAllocationObservers([size](AllocationObserver* observer) {
......
......@@ -275,6 +275,13 @@ class V8_EXPORT_PRIVATE StatsCollector final {
// bytes and the bytes allocated since last marking.
size_t allocated_object_size() const;
// Returns the most recent marked bytes count. Should not be called during
// marking.
size_t marked_bytes() const;
// Returns the overall duration of the most recent marking phase. Should not
// be called during marking.
v8::base::TimeDelta marking_time() const;
double GetRecentAllocationSpeedInBytesPerMs() const;
const Event& GetPreviousEventForTesting() const { return previous_; }
......
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