Skip to content

Commit

Permalink
[heap] Fix remaining test failures with MemoryBalancer
Browse files Browse the repository at this point in the history
There were a few test failures left when running with MemoryBalancer,
that were actually not caused by bugs in MemoryBalancer but broke
tests because of slightly different behavior.

* major_allocation_duration can be 0 with back-to-back GCs and
  the CHECK therefore needed to be adjusted.
* Many Wasm API tests were timing out because the test was trying
  to drain the task queue but MemoryBalancer was scheduling its
  heartbeat task. The test-specific task runner simply schedules
  delayed tasks immediately which causes this. For now we simply
  disable those tests with --memory-balancer enabled.

Bug: v8:13842
Change-Id: I4cba6755432fabb701c88b2ea6d4d0637a786490
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4827603
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#89904}
  • Loading branch information
Dominik Inführ authored and V8 LUCI CQ committed Sep 11, 2023
1 parent 88fd903 commit 2856d48
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/heap/gc-tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ void GCTracer::NotifyMemoryBalancer() {
const base::TimeDelta major_allocation_duration =
(current_.end_atomic_pause_time - previous_mark_compact_end_time_) -
blocked_time_taken;
CHECK_GT(major_allocation_duration, base::TimeDelta());
CHECK_GE(major_allocation_duration, base::TimeDelta());

heap_->mb_->UpdateGCSpeed(major_gc_bytes, major_gc_duration);

Expand Down
3 changes: 2 additions & 1 deletion src/heap/memory-balancer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ void MemoryBalancer::RecomputeLimits(size_t embedder_allocation_limit,
}

void MemoryBalancer::RefreshLimit() {
DCHECK(major_allocation_rate_ && major_gc_speed_);
CHECK(major_allocation_rate_.has_value());
CHECK(major_gc_speed_.has_value());
const size_t computed_limit =
live_memory_after_gc_ +
sqrt(live_memory_after_gc_ * (major_allocation_rate_.value().rate()) /
Expand Down
4 changes: 2 additions & 2 deletions test/cctest/cctest.status
Original file line number Diff line number Diff line change
Expand Up @@ -1056,8 +1056,8 @@
# and these tests don't make sense.
# TODO(14108): Remove once we remove '--no-liftoff' from the 'turboshaft'
# variant.
'test-streaming-compilation/AsyncTestIncrementalCaching': [FAIL],
'test-streaming-compilation/SingleThreadedTestIncrementalCaching': [FAIL],
'test-streaming-compilation/AsyncTestIncrementalCaching': [SKIP],
'test-streaming-compilation/SingleThreadedTestIncrementalCaching': [SKIP],

# Revectorization is not supported yet in Turboshaft.
# TODO(14108): Remove once supported.
Expand Down
2 changes: 1 addition & 1 deletion test/cctest/heap/test-heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6405,7 +6405,7 @@ HEAP_TEST(Regress670675) {
}
size_t array_length = 128 * KB;
size_t n = heap->OldGenerationSpaceAvailable() / array_length;
for (size_t i = 0; i < n + 40; i++) {
for (size_t i = 0; i < n + 60; i++) {
{
HandleScope inner_scope(isolate);
isolate->factory()->NewFixedArray(static_cast<int>(array_length),
Expand Down
4 changes: 2 additions & 2 deletions test/cctest/heap/test-incremental-marking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ TEST_WITH_PLATFORM(IncrementalMarkingUsingTasks, MockPlatform) {
marking->Start(GarbageCollector::MARK_COMPACTOR,
i::GarbageCollectionReason::kTesting);
}
CHECK(platform.PendingTask());
while (platform.PendingTask()) {
CHECK(marking->IsMajorMarking());
while (marking->IsMajorMarking()) {
platform.PerformTask();
}
CHECK(marking->IsStopped());
Expand Down
2 changes: 1 addition & 1 deletion test/cctest/test-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4332,9 +4332,9 @@ TEST(TwoPassPhantomCallbacksTriggeredByStringAlloc) {
CHECK_EQ(metadata.instance_counter, 1);

v8::base::ScopedVector<uint8_t> source(200000);
v8::HandleScope handle_scope(isolate);
// Creating a few large strings suffices to trigger GC.
while (metadata.instance_counter == 1) {
v8::HandleScope handle_scope(isolate);
USE(v8::String::NewFromOneByte(isolate, source.begin(),
v8::NewStringType::kNormal,
static_cast<int>(source.size())));
Expand Down
6 changes: 5 additions & 1 deletion test/cctest/wasm/test-streaming-compilation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,13 @@ class StreamTester {

#define STREAM_TEST(name) \
void RunStream_##name(MockPlatform*, v8::Isolate*); \
TEST_WITH_PLATFORM(Async##name, MockPlatform) { RUN_STREAM(name); } \
TEST_WITH_PLATFORM(Async##name, MockPlatform) { \
if (i::v8_flags.memory_balancer) return; \
RUN_STREAM(name); \
} \
\
TEST_WITH_PLATFORM(SingleThreaded##name, MockPlatform) { \
if (i::v8_flags.memory_balancer) return; \
i::FlagScope<bool> single_threaded_scope(&i::v8_flags.single_threaded, \
true); \
RUN_STREAM(name); \
Expand Down
1 change: 1 addition & 0 deletions test/cctest/wasm/test-wasm-metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ class MetricsRecorder : public v8::metrics::Recorder {
};

COMPILE_TEST(TestEventMetrics) {
if (v8_flags.memory_balancer) return;
FlagScope<bool> no_wasm_dynamic_tiering(&v8_flags.wasm_dynamic_tiering,
false);
std::shared_ptr<MetricsRecorder> recorder =
Expand Down

0 comments on commit 2856d48

Please sign in to comment.