[TEST] Adjustments on memory reclamations

This commit is contained in:
CamilleLaVey
2026-07-29 00:37:37 -04:00
parent cfe1c8b16c
commit bbee229d07
2 changed files with 4 additions and 11 deletions
+2 -4
View File
@@ -61,9 +61,7 @@ u64 BufferCache<P>::ReclaimMemory(u64 target_bytes, bool allow_download) {
return 0;
}
in_reclaim = true;
const size_t sentenced_before = sentenced_buffers.Size();
sentenced_buffers.Reclaim(runtime.CompletedSyncPoint());
const bool drained = sentenced_buffers.Size() != sentenced_before;
u64 freed = 0;
const auto clean_up = [&](BufferId buffer_id) {
if (freed >= target_bytes) {
@@ -88,7 +86,7 @@ u64 BufferCache<P>::ReclaimMemory(u64 target_bytes, bool allow_download) {
sentenced_buffers.Reclaim(runtime.CompletedSyncPoint());
in_reclaim = false;
usage_refresh_countdown = 0;
reclaim_stalled = freed == 0 && !drained;
reclaim_stalled = freed == 0;
return freed;
}
@@ -103,7 +101,7 @@ void BufferCache<P>::EnsureHeadroom(bool allow_download) {
return;
}
const u64 target = (limit / 100) * RECLAIM_TARGET_PERCENT;
ReclaimMemory(usage - target, allow_download);
ReclaimMemory((std::min)(usage - target, total_used_memory), allow_download);
}
template <class P>
+2 -7
View File
@@ -172,15 +172,10 @@ u64 TextureCache<P>::ReclaimMemory(u64 target_bytes, bool allow_download) {
}
in_reclaim = true;
const u64 drain_point = runtime.CompletedSyncPoint();
const size_t sentenced_before = sentenced_images.Size() + sentenced_image_view.Size() +
sentenced_framebuffers.Size();
TickEvictionDownloads(drain_point);
sentenced_images.Reclaim(drain_point);
sentenced_image_view.Reclaim(drain_point);
sentenced_framebuffers.Reclaim(drain_point);
const bool drained = sentenced_images.Size() + sentenced_image_view.Size() +
sentenced_framebuffers.Size() !=
sentenced_before;
u64 freed = 0;
const auto evict = [&](ImageId image_id) {
if (freed >= target_bytes) {
@@ -225,7 +220,7 @@ u64 TextureCache<P>::ReclaimMemory(u64 target_bytes, bool allow_download) {
sentenced_framebuffers.Reclaim(exit_point);
in_reclaim = false;
usage_refresh_countdown = 0;
reclaim_stalled = freed == 0 && !drained;
reclaim_stalled = freed == 0;
return freed;
}
@@ -240,7 +235,7 @@ void TextureCache<P>::EnsureHeadroom(bool allow_download) {
return;
}
const u64 target = (limit / 100) * RECLAIM_TARGET_PERCENT;
ReclaimMemory(usage - target, allow_download);
ReclaimMemory((std::min)(usage - target, total_used_memory), allow_download);
}
template <class P>