Skip to content

Commit 5299228

Browse files
committed
allow for up to 64MB overshoot on load
1 parent 6442207 commit 5299228

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

bindings/cpp/tests/runtime_test.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,21 +454,27 @@ CATCH_TEST_CASE("RangeSearchFunctional", "[runtime]") {
454454
}
455455

456456
CATCH_TEST_CASE("MemoryUsageOnLoad", "[runtime][memory]") {
457+
auto threshold = [](size_t size_on_disk) {
458+
// On load, the allocator allocates blocks of 64 MB
459+
constexpr std::uint64_t ALIGN = 64ull * 1024 * 1024; // 64 MB
460+
return size_t((size_on_disk + ALIGN - 1) / ALIGN * ALIGN);
461+
};
462+
457463
CATCH_SECTION("SmallIndex") {
458464
auto stats = run_save_and_load_test(10);
459465
CATCH_REQUIRE(stats.file_size < 20 * 1024 * 1024);
460-
CATCH_REQUIRE(stats.rss_increase < 1.2 * stats.file_size);
466+
CATCH_REQUIRE(stats.rss_increase < threshold(stats.file_size));
461467
}
462468

463469
CATCH_SECTION("MediumIndex") {
464470
auto stats = run_save_and_load_test(50);
465471
CATCH_REQUIRE(stats.file_size < 100 * 1024 * 1024);
466-
CATCH_REQUIRE(stats.rss_increase < 1.2 * stats.file_size);
472+
CATCH_REQUIRE(stats.rss_increase < threshold(stats.file_size));
467473
}
468474

469475
CATCH_SECTION("LargeIndex") {
470476
auto stats = run_save_and_load_test(200);
471477
CATCH_REQUIRE(stats.file_size < 400 * 1024 * 1024);
472-
CATCH_REQUIRE(stats.rss_increase < 1.2 * stats.file_size);
478+
CATCH_REQUIRE(stats.rss_increase < threshold(stats.file_size));
473479
}
474480
}

0 commit comments

Comments
 (0)