122#define DEFINE_SCOPE(scope) scope,
127 FIRST_INCREMENTAL_SCOPE = MC_INCREMENTAL,
128 LAST_INCREMENTAL_SCOPE = MC_INCREMENTAL_SWEEPING,
129 FIRST_SCOPE = MC_INCREMENTAL,
130 NUMBER_OF_INCREMENTAL_SCOPES =
131 LAST_INCREMENTAL_SCOPE - FIRST_INCREMENTAL_SCOPE + 1,
132 FIRST_TOP_MC_SCOPE = MC_CLEAR,
133 LAST_TOP_MC_SCOPE = MC_SWEEP,
134 FIRST_BACKGROUND_SCOPE = BACKGROUND_YOUNG_ARRAY_BUFFER_SWEEP,
135 LAST_BACKGROUND_SCOPE =
136 SCAVENGER_BACKGROUND_TRACED_HANDLES_COMPUTE_WEAKNESS_PARALLEL
144 static constexpr bool NeedsYoungEpoch(
ScopeId id);
145 static constexpr int IncrementalOffset(
ScopeId id);
152#ifdef V8_RUNTIME_CALL_STATS
155 std::optional<WorkerThreadRuntimeCallStatsScope> runtime_call_stats_scope_;
164 INCREMENTAL_MARK_COMPACTOR = 2,
166 INCREMENTAL_MINOR_MARK_SWEEPER = 4,
171 V8_INLINE static constexpr bool IsYoungGenerationEvent(
Type type);
204 bool reduce_memory =
false;
207 size_t start_object_size = 0;
210 size_t end_object_size = 0;
213 size_t start_memory_size = 0;
216 size_t end_memory_size = 0;
220 size_t start_holes_size = 0;
224 size_t end_holes_size = 0;
227 size_t young_object_size = 0;
230 size_t survived_young_object_size = 0;
233 size_t incremental_marking_bytes = 0;
236 size_t concurrency_estimate = 1;
277 base::TimeDelta::FromSeconds(5);
278 static constexpr double kConservativeSpeedInBytesPerMillisecond = 128 *
KB;
280#ifdef V8_RUNTIME_CALL_STATS
286 GarbageCollectionReason::kUnknown);
299 const char* collector_reason);
305 const char* collector_reason, MarkingType marking);
306 void StopYoungCycleIfFinished();
307 void StopFullCycleIfFinished();
309 void UpdateMemoryBalancerGCSpeed();
312 void StartAtomicPause();
313 void StopAtomicPause();
323 void NotifyFullSweepingCompletedAndStopCycleIfFinished();
324 void NotifyYoungSweepingCompletedAndStopCycleIfFinished();
327 void NotifyYoungSweepingCompleted();
329 void NotifyFullCppGCCompleted();
330 void NotifyYoungCppGCRunning();
331 void NotifyYoungCppGCCompleted();
334 bool IsInObservablePause()
const;
335 bool IsInAtomicPause()
const;
342 bool IsSweepingInProgress()
const;
346 void SampleAllocation(
base::TimeTicks current,
size_t new_space_counter_bytes,
347 size_t old_generation_counter_bytes,
348 size_t embedder_counter_bytes);
350 void AddCompactionEvent(
double duration,
size_t live_bytes_compacted);
352 void AddSurvivalRatio(
double survival_ratio);
354 void SampleConcurrencyEsimate(
size_t concurrency);
357 void AddIncrementalMarkingStep(
double duration,
size_t bytes);
360 void AddIncrementalSweepingStep(
double duration);
364 double IncrementalMarkingSpeedInBytesPerMillisecond()
const;
368 std::optional<double> EmbedderSpeedInBytesPerMillisecond()
const;
376 std::optional<double> YoungGenerationSpeedInBytesPerMillisecond(
381 std::optional<double> CompactionSpeedInBytesPerMillisecond()
const;
385 std::optional<double> MarkCompactSpeedInBytesPerMillisecond()
const;
390 std::optional<double> FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()
395 std::optional<double> OldGenerationSpeedInBytesPerMillisecond();
399 double NewSpaceAllocationThroughputInBytesPerMillisecond()
const;
404 double OldGenerationAllocationThroughputInBytesPerMillisecond()
const;
409 double EmbedderAllocationThroughputInBytesPerMillisecond()
const;
414 double AllocationThroughputInBytesPerMillisecond()
const;
419 double AverageSurvivalRatio()
const;
422 bool SurvivalEventsRecorded()
const;
425 void ResetSurvivalEvents();
427 void NotifyIncrementalMarkingStart();
431 void NotifyMarkingStart();
434 uint16_t CodeFlushingIncrease()
const;
438 double AverageMarkCompactMutatorUtilization()
const;
439 double CurrentMarkCompactMutatorUtilization()
const;
443 void RecordGCPhasesHistograms(RecordGCPhasesInfo::Mode mode);
445 void RecordGCSizeCounters()
const;
447 void RecordEmbedderMarkingSpeed(
size_t bytes,
base::TimeDelta duration);
451 std::optional<base::TimeDelta> AverageTimeToIncrementalMarkingTask()
const;
454#ifdef V8_RUNTIME_CALL_STATS
460 void UpdateCurrentEventPriority(Priority
priority);
481 void ResetForTesting();
482 void RecordIncrementalMarkingSpeed(
size_t bytes,
base::TimeDelta duration);
489 void RecordGCSumCounters();
493 void PrintNVP()
const;
503 void FetchBackgroundCounters();
505 void ReportFullCycleToRecorder();
506 void ReportIncrementalMarkingStepToRecorder(
double v8_duration);
507 void ReportIncrementalSweepingStepToRecorder(
double v8_duration);
508 void ReportYoungCycleToRecorder();
521 std::optional<
base::TimeTicks> start_of_observable_pause_;
528 double recorded_major_incremental_marking_speed_ = 0.0;
530 std::optional<
base::TimeDelta> average_time_to_incremental_marking_task_;
534 std::optional<
base::TimeTicks> last_marking_start_time_for_code_flushing_;
535 uint16_t code_flushing_increase_s_ = 0;
542 base::TimeTicks allocation_time_;
543 size_t new_space_allocation_counter_bytes_ = 0;
544 size_t old_generation_allocation_counter_bytes_ = 0;
545 size_t embedder_allocation_counter_bytes_ = 0;
547 std::optional<
double> combined_mark_compact_speed_cache_;
550 double average_mutator_duration_ = 0.0;
551 double average_mark_compact_duration_ = 0.0;
552 double current_mark_compact_mutator_utilization_ = 1.0;
556 base::TimeTicks previous_mark_compact_end_time_;
557 base::TimeDelta total_duration_since_last_mark_compact_;
565 static constexpr
base::TimeDelta kSmoothedAllocationSpeedDecayRate =
566 v8::
base::TimeDelta::FromMilliseconds(100);
569 kSmoothedAllocationSpeedDecayRate};
571 kSmoothedAllocationSpeedDecayRate};
573 kSmoothedAllocationSpeedDecayRate};
583 bool notified_full_sweeping_completed_ =
false;
584 bool notified_full_cppgc_completed_ =
false;
585 bool full_cppgc_completed_during_minor_gc_ =
false;
587 bool notified_young_sweeping_completed_ =
false;
590 bool notified_young_cppgc_completed_ =
false;
593 bool notified_young_cppgc_running_ =
false;
598 bool young_gc_while_full_gc_ =
false;
608#if defined(V8_USE_PERFETTO)
609 perfetto::ThreadTrack parent_track_;
621 FRIEND_TEST(GCTracerTest, PerGenerationAllocationThroughputWithProvidedTime);