buffer cache: grow stream reserves toward incoming requests

This commit is contained in:
nmzik
2026-09-09 14:32:07 +04:00
parent ba18551d6e
commit 57844a07e2
2 changed files with 76 additions and 27 deletions
+4 -2
View File
@@ -340,10 +340,12 @@ BufferCache::OverlapResult BufferCache::ResolveOverlaps(uint64_t vaddr, uint64_t
end = std::max(end, buffer_end);
if (!has_stream_leap && (stream_score += buffer.StreamScore()) > StreamLeapThreshold) {
has_stream_leap = true;
if (expands_right) {
// Fix the shadPS4 bug that reserves space opposite to the incoming stream's growth.
// The old buffer extending left of the request predicts growth to the right, and vice versa.
if (expands_left) {
end += std::min(StreamLeapSize, PageTable::kAddressSpaceSize - end);
}
if (expands_left) {
if (expands_right) {
const auto minimum = CACHING_PAGESIZE * 2;
if (begin > minimum) {
begin -= std::min(StreamLeapSize, begin - minimum);