diff --git a/common.gypi b/common.gypi index bc690955d3da..b4161293343c 100644 --- a/common.gypi +++ b/common.gypi @@ -42,7 +42,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.57', + 'v8_embedder_string': '-node.58', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/AUTHORS b/deps/v8/AUTHORS index 148600dd569a..7c4dcf466436 100644 --- a/deps/v8/AUTHORS +++ b/deps/v8/AUTHORS @@ -76,6 +76,7 @@ Artem Kobzar Arthur Islamov Asuka Shikina Aurèle Barrière +Austin Burdine Aviv Keller Bala Avulapati Bangfu Tao diff --git a/deps/v8/src/heap/gc-tracer.h b/deps/v8/src/heap/gc-tracer.h index ca2c6b00b531..e93839e26cfa 100644 --- a/deps/v8/src/heap/gc-tracer.h +++ b/deps/v8/src/heap/gc-tracer.h @@ -608,6 +608,7 @@ class V8_EXPORT_PRIVATE GCTracer { FRIEND_TEST(GCTracerTest, BackgroundMajorMCScope); FRIEND_TEST(GCTracerTest, CyclePriorities); FRIEND_TEST(GCTracerTest, EmbedderAllocationThroughput); + FRIEND_TEST(GCTracerTest, HighAllocationRateWithEmbedderAllocation); FRIEND_TEST(GCTracerTest, MultithreadedBackgroundScope); FRIEND_TEST(GCTracerTest, NewSpaceAllocationThroughput); FRIEND_TEST(GCTracerTest, PerGenerationAllocationThroughput); @@ -616,6 +617,7 @@ class V8_EXPORT_PRIVATE GCTracer { FRIEND_TEST(GCTracerTest, IncrementalMarkingDetails); FRIEND_TEST(GCTracerTest, IncrementalScope); FRIEND_TEST(GCTracerTest, IncrementalMarkingSpeed); + FRIEND_TEST(GCTracerTest, LowAllocationRateWithZeroEmbedderAllocation); FRIEND_TEST(GCTracerTest, MutatorUtilization); FRIEND_TEST(GCTracerTest, RecordMarkCompactHistograms); FRIEND_TEST(GCTracerTest, RecordScavengerHistograms); diff --git a/deps/v8/src/heap/heap.cc b/deps/v8/src/heap/heap.cc index 211ca14606ac..9fbee1549769 100644 --- a/deps/v8/src/heap/heap.cc +++ b/deps/v8/src/heap/heap.cc @@ -3668,9 +3668,7 @@ namespace { double ComputeMutatorUtilizationImpl(double mutator_speed, std::optional gc_speed) { - constexpr double kMinMutatorUtilization = 0.0; constexpr double kConservativeGcSpeedInBytesPerMillisecond = 200000; - if (mutator_speed == 0) return kMinMutatorUtilization; if (!gc_speed) gc_speed = kConservativeGcSpeedInBytesPerMillisecond; // Derivation: // mutator_utilization = mutator_time / (mutator_time + gc_time) diff --git a/deps/v8/src/heap/heap.h b/deps/v8/src/heap/heap.h index a628527510b5..c1c955c770ab 100644 --- a/deps/v8/src/heap/heap.h +++ b/deps/v8/src/heap/heap.h @@ -642,7 +642,7 @@ class Heap final { // null. V8_INLINE bool CanSafepoint() const { return deserialization_complete(); } - bool HasLowAllocationRate(); + V8_EXPORT_PRIVATE bool HasLowAllocationRate(); bool HasHighFragmentation(); void ActivateMemoryReducerIfNeeded(); diff --git a/deps/v8/test/unittests/heap/gc-tracer-unittest.cc b/deps/v8/test/unittests/heap/gc-tracer-unittest.cc index 86e0006f38e6..4d5940edc00d 100644 --- a/deps/v8/test/unittests/heap/gc-tracer-unittest.cc +++ b/deps/v8/test/unittests/heap/gc-tracer-unittest.cc @@ -143,6 +143,43 @@ TEST_F(GCTracerTest, PerGenerationAllocationThroughput) { tracer->EmbedderAllocationThroughputInBytesPerMillisecond())); } +TEST_F(GCTracerTest, LowAllocationRateWithZeroEmbedderAllocation) { + if (v8_flags.stress_incremental_marking) return; + Heap* heap = i_isolate()->heap(); + GCTracer* tracer = heap->tracer(); + tracer->ResetForTesting(); + tracer->allocation_time_ = base::TimeTicks(); + + // Two samples 100 ms apart. Young and old generation allocate a little; + // the embedder (CppHeap) allocates nothing at all, as in an embedder that + // never uses cppgc (e.g. Node.js without node:vm). + tracer->SampleAllocation(base::TimeTicks::FromMsTicksForTesting(0), 0, 0, 0); + tracer->SampleAllocation(base::TimeTicks::FromMsTicksForTesting(100), 100, + 100, 0); + + EXPECT_DOUBLE_EQ(0.0, + tracer->EmbedderAllocationThroughputInBytesPerMillisecond()); + EXPECT_TRUE(heap->HasLowAllocationRate()); +} + +TEST_F(GCTracerTest, HighAllocationRateWithEmbedderAllocation) { + if (v8_flags.stress_incremental_marking) return; + Heap* heap = i_isolate()->heap(); + GCTracer* tracer = heap->tracer(); + tracer->ResetForTesting(); + tracer->allocation_time_ = base::TimeTicks(); + + // Same as above, but the embedder allocates heavily: 1 GB over 100 ms is + // ~10^7 B/ms, so the embedder term must still report a high allocation + // rate (mu = 200000 / (10^7 + 200000) < 0.993). + tracer->SampleAllocation(base::TimeTicks::FromMsTicksForTesting(0), 0, 0, 0); + tracer->SampleAllocation(base::TimeTicks::FromMsTicksForTesting(100), 100, + 100, size_t{1} << 30); + + EXPECT_GT(tracer->EmbedderAllocationThroughputInBytesPerMillisecond(), 0.0); + EXPECT_FALSE(heap->HasLowAllocationRate()); +} + TEST_F(GCTracerTest, RegularScope) { if (v8_flags.stress_incremental_marking) return; GCTracer* tracer = i_isolate()->heap()->tracer();