Commit a9327e93 authored by Samuel Groß's avatar Samuel Groß Committed by V8 LUCI CQ

[sandbox] Schedule GC when EPT utilization reaches certain thresholds

During ExternalPointerTable::Grow, if we cross one of a handful of
predefined utilization thresholds, we now request a (major) GC to free
up entries that are no longer used in the table.

Bug: v8:10391
Change-Id: Id2d262f0f1d4dc37aec1e4978a8be2d223fb2b2b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3890971
Commit-Queue: Samuel Groß <saelo@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83155}
parent 277d37e0
...@@ -309,6 +309,18 @@ uint32_t ExternalPointerTable::Grow(Isolate* isolate) { ...@@ -309,6 +309,18 @@ uint32_t ExternalPointerTable::Grow(Isolate* isolate) {
set_capacity(new_capacity); set_capacity(new_capacity);
// Schedule GC when the table's utilization crosses one of these thresholds.
constexpr double kGCThresholds[] = {0.5, 0.75, 0.9, 0.95, 0.99};
constexpr double kMaxCapacity = static_cast<double>(kMaxExternalPointers);
double old_utilization = static_cast<double>(old_capacity) / kMaxCapacity;
double new_utilization = static_cast<double>(new_capacity) / kMaxCapacity;
for (double threshold : kGCThresholds) {
if (old_utilization < threshold && new_utilization >= threshold) {
isolate->heap()->ReportExternalMemoryPressure();
break;
}
}
// Build freelist bottom to top, which might be more cache friendly. // Build freelist bottom to top, which might be more cache friendly.
uint32_t start = std::max<uint32_t>(old_capacity, 1); // Skip entry zero uint32_t start = std::max<uint32_t>(old_capacity, 1); // Skip entry zero
uint32_t last = new_capacity - 1; uint32_t last = new_capacity - 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment