Commit 85962e45 authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

heap: Prepare scopes for epoch-based metrics

Epoch based metrics will rely on "forced" tag (currently we wrongly
account event that should be forced as non-forced) and a unique
epoch id.

Bug: 986235
Change-Id: I3156eecf7e4dcca12a9d2f11ea82b380ded46f5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2351918
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: default avatarAnton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797372}
parent ee9ef9e5
...@@ -90,14 +90,21 @@ void ThreadHeapStatsCollector::DecreaseAllocatedSpace(size_t bytes) { ...@@ -90,14 +90,21 @@ void ThreadHeapStatsCollector::DecreaseAllocatedSpace(size_t bytes) {
}); });
} }
ThreadHeapStatsCollector::Event::Event() {
static std::atomic<size_t> counter{0};
unique_id = counter.fetch_add(1);
}
void ThreadHeapStatsCollector::NotifyMarkingStarted( void ThreadHeapStatsCollector::NotifyMarkingStarted(
BlinkGC::CollectionType collection_type, BlinkGC::CollectionType collection_type,
BlinkGC::GCReason reason) { BlinkGC::GCReason reason,
bool is_forced_gc) {
DCHECK(!is_started_); DCHECK(!is_started_);
DCHECK(current_.marking_time().is_zero()); DCHECK(current_.marking_time().is_zero());
is_started_ = true; is_started_ = true;
current_.reason = reason; current_.reason = reason;
current_.collection_type = collection_type; current_.collection_type = collection_type;
current_.is_forced_gc = is_forced_gc;
} }
void ThreadHeapStatsCollector::NotifyMarkingCompleted(size_t marked_bytes) { void ThreadHeapStatsCollector::NotifyMarkingCompleted(size_t marked_bytes) {
......
...@@ -220,6 +220,8 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector { ...@@ -220,6 +220,8 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector {
// GCs. E.g., |atomic_marking_time()| report the marking time of the atomic // GCs. E.g., |atomic_marking_time()| report the marking time of the atomic
// phase, independent of whether the GC was a stand-alone or unified heap GC. // phase, independent of whether the GC was a stand-alone or unified heap GC.
struct PLATFORM_EXPORT Event { struct PLATFORM_EXPORT Event {
Event();
// Overall time spent in the GC cycle. This includes marking time as well as // Overall time spent in the GC cycle. This includes marking time as well as
// sweeping time. // sweeping time.
base::TimeDelta gc_cycle_time() const; base::TimeDelta gc_cycle_time() const;
...@@ -267,6 +269,7 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector { ...@@ -267,6 +269,7 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector {
double marking_time_in_bytes_per_second() const; double marking_time_in_bytes_per_second() const;
// Marked bytes collected during sweeping. // Marked bytes collected during sweeping.
size_t unique_id = -1;
size_t marked_bytes = 0; size_t marked_bytes = 0;
size_t compaction_freed_bytes = 0; size_t compaction_freed_bytes = 0;
size_t compaction_freed_pages = 0; size_t compaction_freed_pages = 0;
...@@ -280,10 +283,13 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector { ...@@ -280,10 +283,13 @@ class PLATFORM_EXPORT ThreadHeapStatsCollector {
size_t partition_alloc_bytes_before_sweeping = 0; size_t partition_alloc_bytes_before_sweeping = 0;
double live_object_rate = 0; double live_object_rate = 0;
base::TimeDelta gc_nested_in_v8; base::TimeDelta gc_nested_in_v8;
bool is_forced_gc = true;
}; };
// Indicates a new garbage collection cycle. // Indicates a new garbage collection cycle.
void NotifyMarkingStarted(BlinkGC::CollectionType, BlinkGC::GCReason); void NotifyMarkingStarted(BlinkGC::CollectionType,
BlinkGC::GCReason,
bool is_forced_gc);
// Indicates that marking of the current garbage collection cycle is // Indicates that marking of the current garbage collection cycle is
// completed. // completed.
...@@ -437,8 +443,10 @@ template <ThreadHeapStatsCollector::TraceCategory trace_category, ...@@ -437,8 +443,10 @@ template <ThreadHeapStatsCollector::TraceCategory trace_category,
ThreadHeapStatsCollector::ScopeContext scope_category> ThreadHeapStatsCollector::ScopeContext scope_category>
void ThreadHeapStatsCollector::InternalScope<trace_category, void ThreadHeapStatsCollector::InternalScope<trace_category,
scope_category>::StopTrace() { scope_category>::StopTrace() {
TRACE_EVENT_END0(TraceCategory(), TRACE_EVENT_END2(TraceCategory(),
ToString(id_, tracer_->current_.collection_type)); ToString(id_, tracer_->current_.collection_type), "epoch",
tracer_->current_.unique_id, "forced",
tracer_->current_.is_forced_gc);
} }
template <ThreadHeapStatsCollector::TraceCategory trace_category, template <ThreadHeapStatsCollector::TraceCategory trace_category,
......
...@@ -22,7 +22,8 @@ constexpr size_t kNoMarkedBytes = 0; ...@@ -22,7 +22,8 @@ constexpr size_t kNoMarkedBytes = 0;
TEST(ThreadHeapStatsCollectorTest, InitialEmpty) { TEST(ThreadHeapStatsCollectorTest, InitialEmpty) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
for (int i = 0; i < ThreadHeapStatsCollector::kNumScopeIds; i++) { for (int i = 0; i < ThreadHeapStatsCollector::kNumScopeIds; i++) {
EXPECT_EQ(base::TimeDelta(), stats_collector.current().scope_data[i]); EXPECT_EQ(base::TimeDelta(), stats_collector.current().scope_data[i]);
} }
...@@ -33,7 +34,8 @@ TEST(ThreadHeapStatsCollectorTest, InitialEmpty) { ...@@ -33,7 +34,8 @@ TEST(ThreadHeapStatsCollectorTest, InitialEmpty) {
TEST(ThreadHeapStatsCollectorTest, IncreaseScopeTime) { TEST(ThreadHeapStatsCollectorTest, IncreaseScopeTime) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseScopeTime( stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingStep, ThreadHeapStatsCollector::kIncrementalMarkingStep,
base::TimeDelta::FromMilliseconds(1)); base::TimeDelta::FromMilliseconds(1));
...@@ -47,7 +49,8 @@ TEST(ThreadHeapStatsCollectorTest, IncreaseScopeTime) { ...@@ -47,7 +49,8 @@ TEST(ThreadHeapStatsCollectorTest, IncreaseScopeTime) {
TEST(ThreadHeapStatsCollectorTest, StopMovesCurrentToPrevious) { TEST(ThreadHeapStatsCollectorTest, StopMovesCurrentToPrevious) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseScopeTime( stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingStep, ThreadHeapStatsCollector::kIncrementalMarkingStep,
base::TimeDelta::FromMilliseconds(1)); base::TimeDelta::FromMilliseconds(1));
...@@ -61,7 +64,8 @@ TEST(ThreadHeapStatsCollectorTest, StopMovesCurrentToPrevious) { ...@@ -61,7 +64,8 @@ TEST(ThreadHeapStatsCollectorTest, StopMovesCurrentToPrevious) {
TEST(ThreadHeapStatsCollectorTest, StopResetsCurrent) { TEST(ThreadHeapStatsCollectorTest, StopResetsCurrent) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseScopeTime( stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingStep, ThreadHeapStatsCollector::kIncrementalMarkingStep,
base::TimeDelta::FromMilliseconds(1)); base::TimeDelta::FromMilliseconds(1));
...@@ -76,7 +80,8 @@ TEST(ThreadHeapStatsCollectorTest, StartStop) { ...@@ -76,7 +80,8 @@ TEST(ThreadHeapStatsCollectorTest, StartStop) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
EXPECT_FALSE(stats_collector.is_started()); EXPECT_FALSE(stats_collector.is_started());
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
EXPECT_TRUE(stats_collector.is_started()); EXPECT_TRUE(stats_collector.is_started());
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
...@@ -93,7 +98,8 @@ TEST(ThreadHeapStatsCollectorTest, ScopeToString) { ...@@ -93,7 +98,8 @@ TEST(ThreadHeapStatsCollectorTest, ScopeToString) {
TEST(ThreadHeapStatsCollectorTest, UpdateReason) { TEST(ThreadHeapStatsCollectorTest, UpdateReason) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.UpdateReason(BlinkGC::GCReason::kForcedGCForTesting); stats_collector.UpdateReason(BlinkGC::GCReason::kForcedGCForTesting);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
...@@ -104,7 +110,8 @@ TEST(ThreadHeapStatsCollectorTest, UpdateReason) { ...@@ -104,7 +110,8 @@ TEST(ThreadHeapStatsCollectorTest, UpdateReason) {
TEST(ThreadHeapStatsCollectorTest, InitialEstimatedObjectSize) { TEST(ThreadHeapStatsCollectorTest, InitialEstimatedObjectSize) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
EXPECT_EQ(0u, stats_collector.object_size_in_bytes()); EXPECT_EQ(0u, stats_collector.object_size_in_bytes());
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
...@@ -113,7 +120,8 @@ TEST(ThreadHeapStatsCollectorTest, InitialEstimatedObjectSize) { ...@@ -113,7 +120,8 @@ TEST(ThreadHeapStatsCollectorTest, InitialEstimatedObjectSize) {
TEST(ThreadHeapStatsCollectorTest, EstimatedObjectSizeNoMarkedBytes) { TEST(ThreadHeapStatsCollectorTest, EstimatedObjectSizeNoMarkedBytes) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseAllocatedObjectSizeForTesting(512); stats_collector.IncreaseAllocatedObjectSizeForTesting(512);
EXPECT_EQ(512u, stats_collector.object_size_in_bytes()); EXPECT_EQ(512u, stats_collector.object_size_in_bytes());
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
...@@ -123,11 +131,13 @@ TEST(ThreadHeapStatsCollectorTest, EstimatedObjectSizeNoMarkedBytes) { ...@@ -123,11 +131,13 @@ TEST(ThreadHeapStatsCollectorTest, EstimatedObjectSizeNoMarkedBytes) {
TEST(ThreadHeapStatsCollectorTest, EstimatedObjectSizeWithMarkedBytes) { TEST(ThreadHeapStatsCollectorTest, EstimatedObjectSizeWithMarkedBytes) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(128); stats_collector.NotifyMarkingCompleted(128);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.IncreaseAllocatedObjectSizeForTesting(512); stats_collector.IncreaseAllocatedObjectSizeForTesting(512);
EXPECT_EQ(640u, stats_collector.object_size_in_bytes()); EXPECT_EQ(640u, stats_collector.object_size_in_bytes());
...@@ -138,11 +148,13 @@ TEST(ThreadHeapStatsCollectorTest, ...@@ -138,11 +148,13 @@ TEST(ThreadHeapStatsCollectorTest,
EstimatedObjectSizeDoNotCountCurrentlyMarkedBytes) { EstimatedObjectSizeDoNotCountCurrentlyMarkedBytes) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(128); stats_collector.NotifyMarkingCompleted(128);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(128); stats_collector.NotifyMarkingCompleted(128);
// Currently marked bytes should not account to the estimated object size. // Currently marked bytes should not account to the estimated object size.
stats_collector.IncreaseAllocatedObjectSizeForTesting(512); stats_collector.IncreaseAllocatedObjectSizeForTesting(512);
...@@ -155,7 +167,8 @@ TEST(ThreadHeapStatsCollectorTest, PreInitializedEstimatedMarkingTime) { ...@@ -155,7 +167,8 @@ TEST(ThreadHeapStatsCollectorTest, PreInitializedEstimatedMarkingTime) {
// garbage collection triggers. // garbage collection triggers.
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
} }
...@@ -163,14 +176,16 @@ TEST(ThreadHeapStatsCollectorTest, PreInitializedEstimatedMarkingTime) { ...@@ -163,14 +176,16 @@ TEST(ThreadHeapStatsCollectorTest, PreInitializedEstimatedMarkingTime) {
TEST(ThreadHeapStatsCollectorTest, EstimatedMarkingTime1) { TEST(ThreadHeapStatsCollectorTest, EstimatedMarkingTime1) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseScopeTime( stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kAtomicPauseMarkTransitiveClosure, ThreadHeapStatsCollector::kAtomicPauseMarkTransitiveClosure,
base::TimeDelta::FromSeconds(1)); base::TimeDelta::FromSeconds(1));
stats_collector.NotifyMarkingCompleted(1024); stats_collector.NotifyMarkingCompleted(1024);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
} }
...@@ -178,14 +193,16 @@ TEST(ThreadHeapStatsCollectorTest, EstimatedMarkingTime1) { ...@@ -178,14 +193,16 @@ TEST(ThreadHeapStatsCollectorTest, EstimatedMarkingTime1) {
TEST(ThreadHeapStatsCollectorTest, EstimatedMarkingTime2) { TEST(ThreadHeapStatsCollectorTest, EstimatedMarkingTime2) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseScopeTime( stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kAtomicPauseMarkTransitiveClosure, ThreadHeapStatsCollector::kAtomicPauseMarkTransitiveClosure,
base::TimeDelta::FromSeconds(1)); base::TimeDelta::FromSeconds(1));
stats_collector.NotifyMarkingCompleted(1024); stats_collector.NotifyMarkingCompleted(1024);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseAllocatedObjectSizeForTesting(512); stats_collector.IncreaseAllocatedObjectSizeForTesting(512);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
...@@ -194,7 +211,8 @@ TEST(ThreadHeapStatsCollectorTest, EstimatedMarkingTime2) { ...@@ -194,7 +211,8 @@ TEST(ThreadHeapStatsCollectorTest, EstimatedMarkingTime2) {
TEST(ThreadHeapStatsCollectorTest, SubMilliSecondMarkingTime) { TEST(ThreadHeapStatsCollectorTest, SubMilliSecondMarkingTime) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseScopeTime( stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingStartMarking, ThreadHeapStatsCollector::kIncrementalMarkingStartMarking,
base::TimeDelta::FromMillisecondsD(.5)); base::TimeDelta::FromMillisecondsD(.5));
...@@ -206,7 +224,8 @@ TEST(ThreadHeapStatsCollectorTest, AllocatedSpaceInBytesInitialZero) { ...@@ -206,7 +224,8 @@ TEST(ThreadHeapStatsCollectorTest, AllocatedSpaceInBytesInitialZero) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
EXPECT_EQ(0u, stats_collector.allocated_space_bytes()); EXPECT_EQ(0u, stats_collector.allocated_space_bytes());
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
EXPECT_EQ(0u, stats_collector.allocated_space_bytes()); EXPECT_EQ(0u, stats_collector.allocated_space_bytes());
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
EXPECT_EQ(0u, stats_collector.allocated_space_bytes()); EXPECT_EQ(0u, stats_collector.allocated_space_bytes());
...@@ -234,7 +253,8 @@ TEST(ThreadHeapStatsCollectorTest, AllocatedSpaceInBytesDecrease) { ...@@ -234,7 +253,8 @@ TEST(ThreadHeapStatsCollectorTest, AllocatedSpaceInBytesDecrease) {
TEST(ThreadHeapStatsCollectorTest, EventPrevGCMarkedObjectSize) { TEST(ThreadHeapStatsCollectorTest, EventPrevGCMarkedObjectSize) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(1024); stats_collector.NotifyMarkingCompleted(1024);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
EXPECT_EQ(1024u, stats_collector.previous().marked_bytes); EXPECT_EQ(1024u, stats_collector.previous().marked_bytes);
...@@ -244,7 +264,8 @@ TEST(ThreadHeapStatsCollectorTest, ...@@ -244,7 +264,8 @@ TEST(ThreadHeapStatsCollectorTest,
EventMarkingTimeFromIncrementalStandAloneGC) { EventMarkingTimeFromIncrementalStandAloneGC) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseScopeTime( stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingStartMarking, ThreadHeapStatsCollector::kIncrementalMarkingStartMarking,
base::TimeDelta::FromMilliseconds(7)); base::TimeDelta::FromMilliseconds(7));
...@@ -263,7 +284,8 @@ TEST(ThreadHeapStatsCollectorTest, ...@@ -263,7 +284,8 @@ TEST(ThreadHeapStatsCollectorTest,
TEST(ThreadHeapStatsCollectorTest, EventMarkingTimeFromIncrementalUnifiedGC) { TEST(ThreadHeapStatsCollectorTest, EventMarkingTimeFromIncrementalUnifiedGC) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseScopeTime( stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingStartMarking, ThreadHeapStatsCollector::kIncrementalMarkingStartMarking,
base::TimeDelta::FromMilliseconds(7)); base::TimeDelta::FromMilliseconds(7));
...@@ -291,7 +313,8 @@ TEST(ThreadHeapStatsCollectorTest, EventMarkingTimeFromIncrementalUnifiedGC) { ...@@ -291,7 +313,8 @@ TEST(ThreadHeapStatsCollectorTest, EventMarkingTimeFromIncrementalUnifiedGC) {
TEST(ThreadHeapStatsCollectorTest, EventMarkingTime) { TEST(ThreadHeapStatsCollectorTest, EventMarkingTime) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseScopeTime( stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kIncrementalMarkingStep, ThreadHeapStatsCollector::kIncrementalMarkingStep,
base::TimeDelta::FromMilliseconds(2)); base::TimeDelta::FromMilliseconds(2));
...@@ -307,7 +330,8 @@ TEST(ThreadHeapStatsCollectorTest, EventMarkingTime) { ...@@ -307,7 +330,8 @@ TEST(ThreadHeapStatsCollectorTest, EventMarkingTime) {
TEST(ThreadHeapStatsCollectorTest, EventAtomicMarkingTime) { TEST(ThreadHeapStatsCollectorTest, EventAtomicMarkingTime) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseScopeTime( stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kAtomicPauseMarkPrologue, ThreadHeapStatsCollector::kAtomicPauseMarkPrologue,
base::TimeDelta::FromMilliseconds(5)); base::TimeDelta::FromMilliseconds(5));
...@@ -326,7 +350,8 @@ TEST(ThreadHeapStatsCollectorTest, EventAtomicMarkingTime) { ...@@ -326,7 +350,8 @@ TEST(ThreadHeapStatsCollectorTest, EventAtomicMarkingTime) {
TEST(ThreadHeapStatsCollectorTest, EventAtomicPause) { TEST(ThreadHeapStatsCollectorTest, EventAtomicPause) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseScopeTime( stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kAtomicPauseMarkTransitiveClosure, ThreadHeapStatsCollector::kAtomicPauseMarkTransitiveClosure,
base::TimeDelta::FromMilliseconds(17)); base::TimeDelta::FromMilliseconds(17));
...@@ -342,7 +367,8 @@ TEST(ThreadHeapStatsCollectorTest, EventAtomicPause) { ...@@ -342,7 +367,8 @@ TEST(ThreadHeapStatsCollectorTest, EventAtomicPause) {
TEST(ThreadHeapStatsCollectorTest, EventMarkingTimePerByteInS) { TEST(ThreadHeapStatsCollectorTest, EventMarkingTimePerByteInS) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseScopeTime( stats_collector.IncreaseScopeTime(
ThreadHeapStatsCollector::kAtomicPauseMarkTransitiveClosure, ThreadHeapStatsCollector::kAtomicPauseMarkTransitiveClosure,
base::TimeDelta::FromSeconds(1)); base::TimeDelta::FromSeconds(1));
...@@ -355,7 +381,8 @@ TEST(ThreadHeapStatsCollectorTest, EventMarkingTimePerByteInS) { ...@@ -355,7 +381,8 @@ TEST(ThreadHeapStatsCollectorTest, EventMarkingTimePerByteInS) {
TEST(ThreadHeapStatsCollectorTest, EventSweepingTime) { TEST(ThreadHeapStatsCollectorTest, EventSweepingTime) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.IncreaseScopeTime(ThreadHeapStatsCollector::kLazySweepInIdle, stats_collector.IncreaseScopeTime(ThreadHeapStatsCollector::kLazySweepInIdle,
base::TimeDelta::FromMilliseconds(1)); base::TimeDelta::FromMilliseconds(1));
...@@ -376,7 +403,8 @@ TEST(ThreadHeapStatsCollectorTest, EventSweepingTime) { ...@@ -376,7 +403,8 @@ TEST(ThreadHeapStatsCollectorTest, EventSweepingTime) {
TEST(ThreadHeapStatsCollectorTest, EventCompactionFreedBytes) { TEST(ThreadHeapStatsCollectorTest, EventCompactionFreedBytes) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.IncreaseCompactionFreedSize(512); stats_collector.IncreaseCompactionFreedSize(512);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
...@@ -386,7 +414,8 @@ TEST(ThreadHeapStatsCollectorTest, EventCompactionFreedBytes) { ...@@ -386,7 +414,8 @@ TEST(ThreadHeapStatsCollectorTest, EventCompactionFreedBytes) {
TEST(ThreadHeapStatsCollectorTest, EventCompactionFreedPages) { TEST(ThreadHeapStatsCollectorTest, EventCompactionFreedPages) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.IncreaseCompactionFreedPages(3); stats_collector.IncreaseCompactionFreedPages(3);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
...@@ -396,7 +425,8 @@ TEST(ThreadHeapStatsCollectorTest, EventCompactionFreedPages) { ...@@ -396,7 +425,8 @@ TEST(ThreadHeapStatsCollectorTest, EventCompactionFreedPages) {
TEST(ThreadHeapStatsCollectorTest, EventInitialEstimatedLiveObjectRate) { TEST(ThreadHeapStatsCollectorTest, EventInitialEstimatedLiveObjectRate) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(128); stats_collector.NotifyMarkingCompleted(128);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(0.0, stats_collector.previous().live_object_rate); EXPECT_DOUBLE_EQ(0.0, stats_collector.previous().live_object_rate);
...@@ -406,11 +436,13 @@ TEST(ThreadHeapStatsCollectorTest, ...@@ -406,11 +436,13 @@ TEST(ThreadHeapStatsCollectorTest,
EventEstimatedLiveObjectRateSameMarkedBytes) { EventEstimatedLiveObjectRateSameMarkedBytes) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(128); stats_collector.NotifyMarkingCompleted(128);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(128); stats_collector.NotifyMarkingCompleted(128);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(1.0, stats_collector.previous().live_object_rate); EXPECT_DOUBLE_EQ(1.0, stats_collector.previous().live_object_rate);
...@@ -420,11 +452,13 @@ TEST(ThreadHeapStatsCollectorTest, ...@@ -420,11 +452,13 @@ TEST(ThreadHeapStatsCollectorTest,
EventEstimatedLiveObjectRateHalfMarkedBytes) { EventEstimatedLiveObjectRateHalfMarkedBytes) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(256); stats_collector.NotifyMarkingCompleted(256);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(128); stats_collector.NotifyMarkingCompleted(128);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(0.5, stats_collector.previous().live_object_rate); EXPECT_DOUBLE_EQ(0.5, stats_collector.previous().live_object_rate);
...@@ -433,11 +467,13 @@ TEST(ThreadHeapStatsCollectorTest, ...@@ -433,11 +467,13 @@ TEST(ThreadHeapStatsCollectorTest,
TEST(ThreadHeapStatsCollectorTest, EventEstimatedLiveObjectRateNoMarkedBytes) { TEST(ThreadHeapStatsCollectorTest, EventEstimatedLiveObjectRateNoMarkedBytes) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(256); stats_collector.NotifyMarkingCompleted(256);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(0.0, stats_collector.previous().live_object_rate); EXPECT_DOUBLE_EQ(0.0, stats_collector.previous().live_object_rate);
} }
...@@ -446,12 +482,14 @@ TEST(ThreadHeapStatsCollectorTest, ...@@ -446,12 +482,14 @@ TEST(ThreadHeapStatsCollectorTest,
EventEstimatedLiveObjectRateWithAllocatedBytes1) { EventEstimatedLiveObjectRateWithAllocatedBytes1) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(128); stats_collector.NotifyMarkingCompleted(128);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
stats_collector.IncreaseAllocatedObjectSize(128); stats_collector.IncreaseAllocatedObjectSize(128);
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(128); stats_collector.NotifyMarkingCompleted(128);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(.5, stats_collector.previous().live_object_rate); EXPECT_DOUBLE_EQ(.5, stats_collector.previous().live_object_rate);
...@@ -461,12 +499,14 @@ TEST(ThreadHeapStatsCollectorTest, ...@@ -461,12 +499,14 @@ TEST(ThreadHeapStatsCollectorTest,
EventEstimatedLiveObjectRateWithAllocatedBytes2) { EventEstimatedLiveObjectRateWithAllocatedBytes2) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
stats_collector.IncreaseAllocatedObjectSize(128); stats_collector.IncreaseAllocatedObjectSize(128);
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(128); stats_collector.NotifyMarkingCompleted(128);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(1.0, stats_collector.previous().live_object_rate); EXPECT_DOUBLE_EQ(1.0, stats_collector.previous().live_object_rate);
...@@ -476,7 +516,8 @@ TEST(ThreadHeapStatsCollectorTest, ...@@ -476,7 +516,8 @@ TEST(ThreadHeapStatsCollectorTest,
EventEstimatedLiveObjectRateWithAllocatedBytes3) { EventEstimatedLiveObjectRateWithAllocatedBytes3) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(0, stats_collector.previous().live_object_rate); EXPECT_DOUBLE_EQ(0, stats_collector.previous().live_object_rate);
...@@ -486,11 +527,13 @@ TEST(ThreadHeapStatsCollectorTest, ...@@ -486,11 +527,13 @@ TEST(ThreadHeapStatsCollectorTest,
EventEstimatedLiveObjectRateWithAllocatedBytes4) { EventEstimatedLiveObjectRateWithAllocatedBytes4) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(128); stats_collector.NotifyMarkingCompleted(128);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.NotifySweepingCompleted(); stats_collector.NotifySweepingCompleted();
EXPECT_DOUBLE_EQ(0, stats_collector.previous().live_object_rate); EXPECT_DOUBLE_EQ(0, stats_collector.previous().live_object_rate);
...@@ -499,7 +542,8 @@ TEST(ThreadHeapStatsCollectorTest, ...@@ -499,7 +542,8 @@ TEST(ThreadHeapStatsCollectorTest,
TEST(ThreadHeapStatsCollectorTest, EventAllocatedSpaceBeforeSweeping1) { TEST(ThreadHeapStatsCollectorTest, EventAllocatedSpaceBeforeSweeping1) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseAllocatedSpace(1024); stats_collector.IncreaseAllocatedSpace(1024);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.IncreaseAllocatedSpace(2048); stats_collector.IncreaseAllocatedSpace(2048);
...@@ -512,7 +556,8 @@ TEST(ThreadHeapStatsCollectorTest, EventAllocatedSpaceBeforeSweeping1) { ...@@ -512,7 +556,8 @@ TEST(ThreadHeapStatsCollectorTest, EventAllocatedSpaceBeforeSweeping1) {
TEST(ThreadHeapStatsCollectorTest, EventAllocatedSpaceBeforeSweeping2) { TEST(ThreadHeapStatsCollectorTest, EventAllocatedSpaceBeforeSweeping2) {
ThreadHeapStatsCollector stats_collector; ThreadHeapStatsCollector stats_collector;
stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector.NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector.IncreaseAllocatedSpace(1024); stats_collector.IncreaseAllocatedSpace(1024);
stats_collector.NotifyMarkingCompleted(kNoMarkedBytes); stats_collector.NotifyMarkingCompleted(kNoMarkedBytes);
stats_collector.DecreaseAllocatedSpace(1024); stats_collector.DecreaseAllocatedSpace(1024);
...@@ -539,7 +584,8 @@ class MockThreadHeapStatsObserver : public ThreadHeapStatsObserver { ...@@ -539,7 +584,8 @@ class MockThreadHeapStatsObserver : public ThreadHeapStatsObserver {
void FakeGC(ThreadHeapStatsCollector* stats_collector, size_t marked_bytes) { void FakeGC(ThreadHeapStatsCollector* stats_collector, size_t marked_bytes) {
stats_collector->NotifyMarkingStarted(BlinkGC::CollectionType::kMajor, stats_collector->NotifyMarkingStarted(BlinkGC::CollectionType::kMajor,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting,
true /* is_forced_gc */);
stats_collector->NotifyMarkingCompleted(marked_bytes); stats_collector->NotifyMarkingCompleted(marked_bytes);
stats_collector->NotifySweepingCompleted(); stats_collector->NotifySweepingCompleted();
} }
......
...@@ -265,8 +265,8 @@ class TestGCScope : public TestGCCollectGarbageScope { ...@@ -265,8 +265,8 @@ class TestGCScope : public TestGCCollectGarbageScope {
explicit TestGCScope(BlinkGC::StackState state) explicit TestGCScope(BlinkGC::StackState state)
: TestGCCollectGarbageScope(state) { : TestGCCollectGarbageScope(state) {
ThreadState::Current()->Heap().stats_collector()->NotifyMarkingStarted( ThreadState::Current()->Heap().stats_collector()->NotifyMarkingStarted(
BlinkGC::CollectionType::kMajor, BlinkGC::CollectionType::kMajor, BlinkGC::GCReason::kForcedGCForTesting,
BlinkGC::GCReason::kForcedGCForTesting); true /* is_forced_gc */);
ThreadState::Current()->AtomicPauseMarkPrologue( ThreadState::Current()->AtomicPauseMarkPrologue(
BlinkGC::CollectionType::kMajor, state, BlinkGC::kAtomicMarking, BlinkGC::CollectionType::kMajor, state, BlinkGC::kAtomicMarking,
BlinkGC::GCReason::kForcedGCForTesting); BlinkGC::GCReason::kForcedGCForTesting);
......
...@@ -682,8 +682,7 @@ void ThreadState::AtomicPauseMarkPrologue( ...@@ -682,8 +682,7 @@ void ThreadState::AtomicPauseMarkPrologue(
BlinkGC::GCReason reason) { BlinkGC::GCReason reason) {
ThreadHeapStatsCollector::EnabledScope mark_prologue_scope( ThreadHeapStatsCollector::EnabledScope mark_prologue_scope(
Heap().stats_collector(), Heap().stats_collector(),
ThreadHeapStatsCollector::kAtomicPauseMarkPrologue, "epoch", gc_age_, ThreadHeapStatsCollector::kAtomicPauseMarkPrologue);
"forced", IsForcedGC(reason));
EnterAtomicPause(); EnterAtomicPause();
EnterNoAllocationScope(); EnterNoAllocationScope();
EnterGCForbiddenScope(); EnterGCForbiddenScope();
...@@ -768,8 +767,7 @@ void ThreadState::CompleteSweep() { ...@@ -768,8 +767,7 @@ void ThreadState::CompleteSweep() {
ScriptForbiddenScope script_forbidden; ScriptForbiddenScope script_forbidden;
SweepForbiddenScope scope(this); SweepForbiddenScope scope(this);
ThreadHeapStatsCollector::EnabledScope stats_scope( ThreadHeapStatsCollector::EnabledScope stats_scope(
Heap().stats_collector(), ThreadHeapStatsCollector::kCompleteSweep, Heap().stats_collector(), ThreadHeapStatsCollector::kCompleteSweep);
"forced", IsForcedGC(current_gc_data_.reason));
// Boost priority of sweeping job to complete ASAP and avoid taking time on // Boost priority of sweeping job to complete ASAP and avoid taking time on
// the main thread. // the main thread.
if (sweeper_handle_) if (sweeper_handle_)
...@@ -1114,7 +1112,7 @@ void ThreadState::IncrementalMarkingStart(BlinkGC::GCReason reason) { ...@@ -1114,7 +1112,7 @@ void ThreadState::IncrementalMarkingStart(BlinkGC::GCReason reason) {
// Sweeping is performed in driver functions. // Sweeping is performed in driver functions.
DCHECK(!IsSweepingInProgress()); DCHECK(!IsSweepingInProgress());
Heap().stats_collector()->NotifyMarkingStarted( Heap().stats_collector()->NotifyMarkingStarted(
BlinkGC::CollectionType::kMajor, reason); BlinkGC::CollectionType::kMajor, reason, IsForcedGC(reason));
{ {
ThreadHeapStatsCollector::EnabledScope stats_scope( ThreadHeapStatsCollector::EnabledScope stats_scope(
Heap().stats_collector(), Heap().stats_collector(),
...@@ -1294,7 +1292,8 @@ void ThreadState::CollectGarbage(BlinkGC::CollectionType collection_type, ...@@ -1294,7 +1292,8 @@ void ThreadState::CollectGarbage(BlinkGC::CollectionType collection_type,
if (should_do_full_gc) { if (should_do_full_gc) {
CompleteSweep(); CompleteSweep();
SetGCState(kNoGCScheduled); SetGCState(kNoGCScheduled);
Heap().stats_collector()->NotifyMarkingStarted(collection_type, reason); Heap().stats_collector()->NotifyMarkingStarted(collection_type, reason,
IsForcedGC(reason));
RunAtomicPause(collection_type, stack_state, marking_type, sweeping_type, RunAtomicPause(collection_type, stack_state, marking_type, sweeping_type,
reason); reason);
} }
...@@ -1333,8 +1332,8 @@ void ThreadState::AtomicPauseMarkRoots(BlinkGC::StackState stack_state, ...@@ -1333,8 +1332,8 @@ void ThreadState::AtomicPauseMarkRoots(BlinkGC::StackState stack_state,
BlinkGC::MarkingType marking_type, BlinkGC::MarkingType marking_type,
BlinkGC::GCReason reason) { BlinkGC::GCReason reason) {
ThreadHeapStatsCollector::EnabledScope advance_tracing_scope( ThreadHeapStatsCollector::EnabledScope advance_tracing_scope(
Heap().stats_collector(), ThreadHeapStatsCollector::kAtomicPauseMarkRoots, Heap().stats_collector(),
"epoch", gc_age_, "forced", IsForcedGC(current_gc_data_.reason)); ThreadHeapStatsCollector::kAtomicPauseMarkRoots);
MarkPhaseVisitRoots(); MarkPhaseVisitRoots();
MarkPhaseVisitNotFullyConstructedObjects(); MarkPhaseVisitNotFullyConstructedObjects();
} }
...@@ -1342,8 +1341,7 @@ void ThreadState::AtomicPauseMarkRoots(BlinkGC::StackState stack_state, ...@@ -1342,8 +1341,7 @@ void ThreadState::AtomicPauseMarkRoots(BlinkGC::StackState stack_state,
void ThreadState::AtomicPauseMarkTransitiveClosure() { void ThreadState::AtomicPauseMarkTransitiveClosure() {
ThreadHeapStatsCollector::EnabledScope advance_tracing_scope( ThreadHeapStatsCollector::EnabledScope advance_tracing_scope(
Heap().stats_collector(), Heap().stats_collector(),
ThreadHeapStatsCollector::kAtomicPauseMarkTransitiveClosure, "epoch", ThreadHeapStatsCollector::kAtomicPauseMarkTransitiveClosure);
gc_age_, "forced", IsForcedGC(current_gc_data_.reason));
// base::TimeTicks::Now() + base::TimeDelta::Max() == base::TimeTicks::Max() // base::TimeTicks::Now() + base::TimeDelta::Max() == base::TimeTicks::Max()
CHECK(MarkPhaseAdvanceMarking(base::TimeDelta::Max(), CHECK(MarkPhaseAdvanceMarking(base::TimeDelta::Max(),
EphemeronProcessing::kFullProcessing)); EphemeronProcessing::kFullProcessing));
...@@ -1352,8 +1350,7 @@ void ThreadState::AtomicPauseMarkTransitiveClosure() { ...@@ -1352,8 +1350,7 @@ void ThreadState::AtomicPauseMarkTransitiveClosure() {
void ThreadState::AtomicPauseMarkEpilogue(BlinkGC::MarkingType marking_type) { void ThreadState::AtomicPauseMarkEpilogue(BlinkGC::MarkingType marking_type) {
ThreadHeapStatsCollector::EnabledScope stats_scope( ThreadHeapStatsCollector::EnabledScope stats_scope(
Heap().stats_collector(), Heap().stats_collector(),
ThreadHeapStatsCollector::kAtomicPauseMarkEpilogue, "epoch", gc_age_, ThreadHeapStatsCollector::kAtomicPauseMarkEpilogue);
"forced", IsForcedGC(current_gc_data_.reason));
MarkPhaseEpilogue(marking_type); MarkPhaseEpilogue(marking_type);
LeaveGCForbiddenScope(); LeaveGCForbiddenScope();
LeaveNoAllocationScope(); LeaveNoAllocationScope();
...@@ -1367,8 +1364,7 @@ void ThreadState::AtomicPauseSweepAndCompact( ...@@ -1367,8 +1364,7 @@ void ThreadState::AtomicPauseSweepAndCompact(
BlinkGC::SweepingType sweeping_type) { BlinkGC::SweepingType sweeping_type) {
ThreadHeapStatsCollector::EnabledScope stats( ThreadHeapStatsCollector::EnabledScope stats(
Heap().stats_collector(), Heap().stats_collector(),
ThreadHeapStatsCollector::kAtomicPauseSweepAndCompact, "epoch", gc_age_, ThreadHeapStatsCollector::kAtomicPauseSweepAndCompact);
"forced", IsForcedGC(current_gc_data_.reason));
AtomicPauseScope atomic_pause_scope(this); AtomicPauseScope atomic_pause_scope(this);
ScriptForbiddenScope script_forbidden_scope; ScriptForbiddenScope script_forbidden_scope;
......
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