Commit c48cf114 authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

cppgc: Update cppgc scope names

Update scope names to match the new scope naming scheme we settled on.
This CL also:
1) Adds high-level scopes for atomic mark/sweep/compact and incremental
   mark/sweep.
2) Remove scopes that will now become redundant (i.e. SweepAndCompact,
   UnifiedMarkingStep, etc.)

The new scopes are no longer aligned with the existing telemetry code
(gc_metric.html) in blink.

Bug: chromium:1056170
Change-Id: I510269e24172f411b2a98c0a0a250a6e9fe58841
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2563882
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71480}
parent 79896eeb
......@@ -214,11 +214,6 @@ bool CppHeap::AdvanceTracing(double deadline_in_ms) {
is_in_final_pause_
? v8::base::TimeDelta::Max()
: v8::base::TimeDelta::FromMillisecondsD(deadline_in_ms);
cppgc::internal::StatsCollector::EnabledScope stats_scope(
AsBase(),
is_in_final_pause_
? cppgc::internal::StatsCollector::kAtomicPauseMarkTransitiveClosure
: cppgc::internal::StatsCollector::kUnifiedMarkingStep);
// TODO(chromium:1056170): Replace when unified heap transitions to
// bytes-based deadline.
marking_done_ = marker_->AdvanceMarkingWithMaxDuration(deadline);
......@@ -229,6 +224,8 @@ bool CppHeap::AdvanceTracing(double deadline_in_ms) {
bool CppHeap::IsTracingDone() { return marking_done_; }
void CppHeap::EnterFinalPause(EmbedderStackState stack_state) {
cppgc::internal::StatsCollector::EnabledScope stats_scope(
AsBase(), cppgc::internal::StatsCollector::kAtomicMark);
is_in_final_pause_ = true;
marker_->EnterAtomicPause(stack_state);
if (compactor_.CancelIfShouldNotCompact(
......@@ -242,37 +239,34 @@ void CppHeap::TraceEpilogue(TraceSummary* trace_summary) {
CHECK(is_in_final_pause_);
CHECK(marking_done_);
{
cppgc::internal::StatsCollector::EnabledScope stats_scope(
AsBase(), cppgc::internal::StatsCollector::kAtomicMark);
cppgc::internal::ObjectAllocator::NoAllocationScope no_allocation_scope_(
object_allocator_);
marker_->LeaveAtomicPause();
is_in_final_pause_ = false;
}
{
cppgc::internal::StatsCollector::EnabledScope stats(
AsBase(), cppgc::internal::StatsCollector::kAtomicPauseSweepAndCompact);
{
cppgc::internal::ObjectAllocator::NoAllocationScope no_allocation_scope_(
object_allocator_);
prefinalizer_handler()->InvokePreFinalizers();
}
marker_.reset();
// TODO(chromium:1056170): replace build flag with dedicated flag.
cppgc::internal::ObjectAllocator::NoAllocationScope no_allocation_scope_(
object_allocator_);
prefinalizer_handler()->InvokePreFinalizers();
}
marker_.reset();
// TODO(chromium:1056170): replace build flag with dedicated flag.
#if DEBUG
UnifiedHeapMarkingVerifier verifier(*this);
verifier.Run(cppgc::Heap::StackState::kNoHeapPointers);
UnifiedHeapMarkingVerifier verifier(*this);
verifier.Run(cppgc::Heap::StackState::kNoHeapPointers);
#endif
{
NoGCScope no_gc(*this);
cppgc::internal::Sweeper::SweepingConfig::CompactableSpaceHandling
compactable_space_handling = compactor_.CompactSpacesIfEnabled();
const cppgc::internal::Sweeper::SweepingConfig sweeping_config{
cppgc::internal::Sweeper::SweepingConfig::SweepingType::
kIncrementalAndConcurrent,
compactable_space_handling};
sweeper().Start(sweeping_config);
}
{
NoGCScope no_gc(*this);
cppgc::internal::Sweeper::SweepingConfig::CompactableSpaceHandling
compactable_space_handling = compactor_.CompactSpacesIfEnabled();
const cppgc::internal::Sweeper::SweepingConfig sweeping_config{
cppgc::internal::Sweeper::SweepingConfig::SweepingType::
kIncrementalAndConcurrent,
compactable_space_handling};
sweeper().Start(sweeping_config);
}
sweeper().NotifyDoneIfNeeded();
}
......
......@@ -484,8 +484,8 @@ bool Compactor::CancelIfShouldNotCompact(
Compactor::CompactableSpaceHandling Compactor::CompactSpacesIfEnabled() {
if (!is_enabled_) return CompactableSpaceHandling::kSweep;
StatsCollector::DisabledScope stats_scope(
*heap_.heap(), StatsCollector::kAtomicPauseCompaction);
StatsCollector::DisabledScope stats_scope(*heap_.heap(),
StatsCollector::kAtomicCompact);
MovableReferences movable_references(*heap_.heap());
......
......@@ -73,7 +73,7 @@ ConcurrentMarkingTask::ConcurrentMarkingTask(
void ConcurrentMarkingTask::Run(JobDelegate* job_delegate) {
StatsCollector::EnabledConcurrentScope stats_scope(
concurrent_marker_.heap(), StatsCollector::kConcurrentMarkingStep);
concurrent_marker_.heap(), StatsCollector::kConcurrentMark);
if (!HasWorkForConcurrentMarking(concurrent_marker_.marking_worklists()))
return;
......@@ -151,7 +151,7 @@ void ConcurrentMarkingTask::ProcessWorklists(
{
StatsCollector::DisabledConcurrentScope stats_scope(
concurrent_marker_.heap(),
StatsCollector::kConcurrentMarkInvokeEphemeronCallbacks);
StatsCollector::kConcurrentMarkProcessEphemerons);
if (!DrainWorklistWithYielding(
job_delegate, concurrent_marking_state,
concurrent_marker_.incremental_marking_schedule(),
......
......@@ -164,28 +164,22 @@ void Heap::FinalizeGarbageCollection(Config::StackState stack_state) {
marker_->FinishMarking(stack_state);
}
{
StatsCollector::EnabledScope stats(
*this, StatsCollector::kAtomicPauseSweepAndCompact);
{
// Pre finalizers are forbidden from allocating objects.
ObjectAllocator::NoAllocationScope no_allocation_scope_(
object_allocator_);
prefinalizer_handler_->InvokePreFinalizers();
}
marker_.reset();
// TODO(chromium:1056170): replace build flag with dedicated flag.
// Pre finalizers are forbidden from allocating objects.
ObjectAllocator::NoAllocationScope no_allocation_scope_(object_allocator_);
prefinalizer_handler_->InvokePreFinalizers();
}
marker_.reset();
// TODO(chromium:1056170): replace build flag with dedicated flag.
#if DEBUG
MarkingVerifier verifier(*this);
verifier.Run(stack_state);
MarkingVerifier verifier(*this);
verifier.Run(stack_state);
#endif
NoGCScope no_gc(*this);
const Sweeper::SweepingConfig sweeping_config{
config_.sweeping_type,
Sweeper::SweepingConfig::CompactableSpaceHandling::kSweep};
sweeper_.Start(sweeping_config);
}
NoGCScope no_gc(*this);
const Sweeper::SweepingConfig sweeping_config{
config_.sweeping_type,
Sweeper::SweepingConfig::CompactableSpaceHandling::kSweep};
sweeper_.Start(sweeping_config);
sweeper_.NotifyDoneIfNeeded();
}
......@@ -196,8 +190,7 @@ void Heap::DisableHeapGrowingForTesting() { growing_.DisableForTesting(); }
void Heap::FinalizeIncrementalGarbageCollectionIfNeeded(
Config::StackState stack_state) {
StatsCollector::EnabledScope stats_scope(
*this, StatsCollector::kIncrementalMarkingFinalize);
*this, StatsCollector::kMarkIncrementalFinalize);
FinalizeGarbageCollection(stack_state);
}
......
This diff is collapsed.
......@@ -22,7 +22,7 @@ void MutatorMarkingState::FlushNotFullyConstructedObjects() {
void MutatorMarkingState::FlushDiscoveredEphemeronPairs() {
StatsCollector::EnabledScope stats_scope(
heap_, StatsCollector::kMarkFlushEphemeronPairs);
heap_, StatsCollector::kMarkFlushEphemerons);
discovered_ephemeron_pairs_worklist_.Publish();
if (!discovered_ephemeron_pairs_worklist_.IsGlobalEmpty()) {
ephemeron_pairs_for_processing_worklist_.Merge(
......
......@@ -136,7 +136,7 @@ void* ObjectAllocator::OutOfLineAllocateImpl(NormalPageSpace* space,
// this allocation or we finish sweeping all pages of this heap.
// {
// StatsCollector::EnabledScope stats_scope(
// *space->raw_heap()->heap(), StatsCollector::kLazySweepOnAllocation);
// *space->raw_heap()->heap(), StatsCollector::kSweepOnAllocation);
// // TODO(chromium:1056170): Add lazy sweep.
// }
......
......@@ -49,7 +49,7 @@ void PreFinalizerHandler::RegisterPrefinalizer(PreFinalizer pre_finalizer) {
void PreFinalizerHandler::InvokePreFinalizers() {
StatsCollector::DisabledScope stats_scope(
heap_, StatsCollector::kInvokePreFinalizers);
heap_, StatsCollector::kSweepInvokePreFinalizers);
DCHECK(CurrentThreadIsCreationThread());
LivenessBroker liveness_broker = LivenessBrokerFactory::Create();
......
......@@ -19,42 +19,40 @@
namespace cppgc {
namespace internal {
#define CPPGC_FOR_ALL_SCOPES(V) \
V(AtomicPauseCompaction) \
V(AtomicPauseMarkEpilogue) \
V(AtomicPauseMarkPrologue) \
V(AtomicPauseMarkRoots) \
V(AtomicPauseMarkTransitiveClosure) \
V(AtomicPauseSweepAndCompact) \
V(CompleteSweep) \
V(IncrementalMarkingFinalize) \
V(IncrementalMarkingStartMarking) \
V(IncrementalMarkingStep) \
V(IncrementalMarkingWithDeadline) \
V(InvokePreFinalizers) \
V(LazySweepInIdle) \
V(LazySweepOnAllocation) \
V(MarkBailOutObjects) \
V(MarkInvokeEphemeronCallbacks) \
V(MarkFlushEphemeronPairs) \
V(MarkProcessWorklists) \
V(MarkProcessMarkingWorklist) \
V(MarkProcessWriteBarrierWorklist) \
V(MarkProcessNotFullyconstructeddWorklist) \
V(MarkNotFullyConstructedObjects) \
V(MarkWeakProcessing) \
V(UnifiedMarkingStep) \
V(VisitCrossThreadPersistents) \
V(VisitPersistentRoots) \
V(VisitPersistents) \
V(VisitRoots) \
V(VisitStackRoots) \
V(VisitRememberedSets)
#define CPPGC_FOR_ALL_CONCURRENT_SCOPES(V) \
V(ConcurrentMarkInvokeEphemeronCallbacks) \
V(ConcurrentMarkingStep) \
V(ConcurrentSweepingStep)
#define CPPGC_FOR_ALL_SCOPES(V) \
V(AtomicMark) \
V(AtomicSweep) \
V(AtomicCompact) \
V(IncrementalMark) \
V(IncrementalSweep) \
V(MarkIncrementalStart) \
V(MarkIncrementalFinalize) \
V(MarkAtomicPrologue) \
V(MarkAtomicEpilogue) \
V(MarkTransitiveClosure) \
V(MarkTransitiveClosureWithDeadline) \
V(MarkFlushEphemerons) \
V(MarkProcessBailOutObjects) \
V(MarkProcessMarkingWorklist) \
V(MarkProcessWriteBarrierWorklist) \
V(MarkProcessNotFullyconstructedWorklist) \
V(MarkProcessEphemerons) \
V(MarkVisitRoots) \
V(MarkVisitNotFullyConstructedObjects) \
V(MarkVisitPersistents) \
V(MarkVisitCrossThreadPersistents) \
V(MarkVisitStack) \
V(MarkVisitRememberedSets) \
V(WeakInvokeCallbacks) \
V(SweepInvokePreFinalizers) \
V(SweepIdleStep) \
V(SweepOnAllocation) \
V(SweepFinalize)
#define CPPGC_FOR_ALL_CONCURRENT_SCOPES(V) \
V(ConcurrentMarkProcessEphemerons) \
V(ConcurrentMark) \
V(ConcurrentSweep)
// Sink for various time and memory statistics.
class V8_EXPORT_PRIVATE StatsCollector final {
......
......@@ -397,7 +397,7 @@ class ConcurrentSweepTask final : public cppgc::JobTask,
void Run(cppgc::JobDelegate* delegate) final {
StatsCollector::EnabledConcurrentScope stats_scope(
heap_, StatsCollector::kConcurrentSweepingStep);
heap_, StatsCollector::kConcurrentSweep);
for (SpaceState& state : *states_) {
while (auto page = state.unswept_pages.Pop()) {
......@@ -502,6 +502,8 @@ class Sweeper::SweeperImpl final {
~SweeperImpl() { CancelSweepers(); }
void Start(SweepingConfig config) {
StatsCollector::EnabledScope stats_scope(*heap_->heap(),
StatsCollector::kAtomicSweep);
is_in_progress_ = true;
#if DEBUG
// Verify bitmap for all spaces regardless of |compactable_space_handling|.
......@@ -524,8 +526,10 @@ class Sweeper::SweeperImpl final {
if (!is_in_progress_) return;
{
StatsCollector::EnabledScope stats_scope(*heap_->heap(),
StatsCollector::kCompleteSweep);
StatsCollector::EnabledScope stats_scope(
*heap_->heap(), StatsCollector::kIncrementalSweep);
StatsCollector::EnabledScope inner_scope(*heap_->heap(),
StatsCollector::kSweepFinalize);
if (concurrent_sweeper_handle_ && concurrent_sweeper_handle_->IsValid() &&
concurrent_sweeper_handle_->UpdatePriorityEnabled()) {
concurrent_sweeper_handle_->UpdatePriority(
......@@ -594,24 +598,29 @@ class Sweeper::SweeperImpl final {
void Run(double deadline_in_seconds) override {
if (handle_.IsCanceled() || !sweeper_->is_in_progress_) return;
MutatorThreadSweeper sweeper(&sweeper_->space_states_,
sweeper_->platform_);
bool sweep_complete;
{
StatsCollector::EnabledScope stats_scope(
*sweeper_->heap_->heap(), StatsCollector::kLazySweepInIdle,
"idleDeltaInSeconds",
(deadline_in_seconds -
sweeper_->platform_->MonotonicallyIncreasingTime()));
sweep_complete = sweeper.SweepWithDeadline(deadline_in_seconds);
}
if (sweep_complete) {
sweeper_->FinalizeSweep();
sweeper_->NotifyDone();
} else {
sweeper_->ScheduleIncrementalSweeping();
*sweeper_->heap_->heap(), StatsCollector::kIncrementalSweep);
MutatorThreadSweeper sweeper(&sweeper_->space_states_,
sweeper_->platform_);
{
StatsCollector::EnabledScope stats_scope(
*sweeper_->heap_->heap(), StatsCollector::kSweepIdleStep,
"idleDeltaInSeconds",
(deadline_in_seconds -
sweeper_->platform_->MonotonicallyIncreasingTime()));
sweep_complete = sweeper.SweepWithDeadline(deadline_in_seconds);
}
if (sweep_complete) {
sweeper_->FinalizeSweep();
} else {
sweeper_->ScheduleIncrementalSweeping();
}
}
if (sweep_complete) sweeper_->NotifyDone();
}
Handle GetHandle() const { return handle_; }
......
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