25 taskrunner_(
heap->GetForegroundTaskRunner()),
28 js_calls_sample_time_ms_(0.0) {
35 memory_reducer_(memory_reducer) {}
39 Heap*
heap = memory_reducer_->heap();
44 const double time_ms =
heap->MonotonicallyIncreasingTimeInMs();
45 heap->allocator()->new_space_allocator()->FreeLinearAllocationArea();
47 heap->NewSpaceAllocationCounter(),
48 heap->OldGenerationAllocationCounter(),
49 heap->EmbedderAllocationCounter());
50 const bool low_allocation_rate =
heap->HasLowAllocationRate();
51 const bool optimize_for_memory =
heap->ShouldOptimizeForMemoryUsage();
53 heap->isolate()->PrintWithTimestamp(
54 "Memory reducer: %s, %s\n",
55 low_allocation_rate ?
"low alloc" :
"high alloc",
56 optimize_for_memory ?
"background" :
"foreground");
64 heap->CommittedOldGenerationMemory(),
66 low_allocation_rate || optimize_for_memory,
67 heap->incremental_marking()->IsStopped() &&
68 heap->incremental_marking()->CanAndShouldBeStarted(),
71 memory_reducer_->NotifyTimer(event);
80 DCHECK(
heap()->incremental_marking()->IsStopped());
83 heap()->
isolate()->PrintWithTimestamp(
"Memory reducer: started GC #%d\n",
97 "Memory reducer: waiting for %.f ms\n",
104 if (!
v8_flags.incremental_marking)
return;
114 (committed_memory_before > committed_memory +
MB) ||
127 "Memory reducer: finished GC #%d (%s)\n", old_state.
started_gcs(),
133 if (!
v8_flags.incremental_marking)
return;
150 return state.last_gc_time_ms() != 0 &&
157 const Event& event) {
161 switch (state.id()) {
169 static_cast<size_t>(state.committed_memory_at_last_run() *
181 state.last_gc_time_ms());
185 switch (event.
type) {
195 if (state.next_gc_start_ms() <= event.
time_ms) {
203 state.last_gc_time_ms());
214 state.started_gcs() == 1)) {
230 if (
heap()->IsTearingDown())
return;
232 const double kSlackMs = 100;
234 (delay_ms + kSlackMs) / 1000.0);
242 return v8_flags.memory_reducer_gc_count;
247 return v8_flags.memory_reducer_respects_frozen_state &&
248 heap->isolate()->IsFrozen();
void PostDelayedTask(std::unique_ptr< Task > task, double delay_in_seconds, const SourceLocation &location=SourceLocation::Current())
V8_EXPORT_PRIVATE void StartIncrementalMarking(GCFlags gc_flags, GarbageCollectionReason gc_reason, GCCallbackFlags gc_callback_flags=GCCallbackFlags::kNoGCCallbackFlags, GarbageCollector collector=GarbageCollector::MARK_COMPACTOR)
V8_EXPORT_PRIVATE double MonotonicallyIncreasingTimeInMs() const
bool HasHighFragmentation()
size_t CommittedOldGenerationMemory()
Isolate * isolate() const
double next_gc_start_ms() const
static State CreateWait(int started_gcs, double next_gc_time_ms, double last_gc_time_ms)
static State CreateUninitialized()
static State CreateDone(double last_gc_time_ms, size_t committed_memory)
static State CreateRun(int started_gcs)
void RunInternal() override
TimerTask(MemoryReducer *memory_reducer)
static bool IsFrozen(const Heap *heap)
static int MaxNumberOfGCs()
std::shared_ptr< v8::TaskRunner > taskrunner_
static bool WatchdogGC(const State &state, const Event &event)
static const double kCommittedMemoryFactor
void NotifyTimer(const Event &event)
static const size_t kCommittedMemoryDelta
void ScheduleTimer(double delay_ms)
static const int kLongDelayMs
static const int kShortDelayMs
MemoryReducer(Heap *heap)
static State Step(const State &state, const Event &event)
void NotifyMarkCompact(size_t committed_memory_before)
static const int kWatchdogDelayMs
void NotifyPossibleGarbage()
enum v8::internal::@1270::DeoptimizableCodeIterator::@67 state_
LiftoffAssembler::CacheState state
V8_EXPORT_PRIVATE FlagValues v8_flags
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in allocation gc speed threshold for starting incremental marking via a task in percent of available threshold for starting incremental marking immediately in percent of available Use a single schedule for determining a marking schedule between JS and C objects schedules the minor GC task with kUserVisible priority max worker number of concurrent for NumberOfWorkerThreads start background threads that allocate memory concurrent_array_buffer_sweeping use parallel threads to clear weak refs in the atomic pause trace progress of the incremental marking trace object counts and memory usage * MB
@ kGCCallbackFlagCollectAllExternalMemory
#define CHECK_LE(lhs, rhs)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)
bool should_start_incremental_gc
bool next_gc_likely_to_collect_more
bool can_start_incremental_gc