mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-11-04 00:49:02 -06:00 
			
		
		
		
	Merge pull request #7812 from FernandoS27/made-straight-from-the-nut
BufferCache: Find direction of the stream buffer increase.
This commit is contained in:
		@@ -1469,19 +1469,27 @@ typename BufferCache<P>::OverlapResult BufferCache<P>::ResolveOverlaps(VAddr cpu
 | 
			
		||||
        overlap_ids.push_back(overlap_id);
 | 
			
		||||
        overlap.Pick();
 | 
			
		||||
        const VAddr overlap_cpu_addr = overlap.CpuAddr();
 | 
			
		||||
        if (overlap_cpu_addr < begin) {
 | 
			
		||||
        const bool expands_left = overlap_cpu_addr < begin;
 | 
			
		||||
        if (expands_left) {
 | 
			
		||||
            cpu_addr = begin = overlap_cpu_addr;
 | 
			
		||||
        }
 | 
			
		||||
        end = std::max(end, overlap_cpu_addr + overlap.SizeBytes());
 | 
			
		||||
 | 
			
		||||
        const VAddr overlap_end = overlap_cpu_addr + overlap.SizeBytes();
 | 
			
		||||
        const bool expands_right = overlap_end > end;
 | 
			
		||||
        if (overlap_end > end) {
 | 
			
		||||
            end = overlap_end;
 | 
			
		||||
        }
 | 
			
		||||
        stream_score += overlap.StreamScore();
 | 
			
		||||
        if (stream_score > STREAM_LEAP_THRESHOLD && !has_stream_leap) {
 | 
			
		||||
            // When this memory region has been joined a bunch of times, we assume it's being used
 | 
			
		||||
            // as a stream buffer. Increase the size to skip constantly recreating buffers.
 | 
			
		||||
            has_stream_leap = true;
 | 
			
		||||
            begin -= PAGE_SIZE * 256;
 | 
			
		||||
            cpu_addr = begin;
 | 
			
		||||
            end += PAGE_SIZE * 256;
 | 
			
		||||
            if (expands_right) {
 | 
			
		||||
                begin -= PAGE_SIZE * 256;
 | 
			
		||||
                cpu_addr = begin;
 | 
			
		||||
            }
 | 
			
		||||
            if (expands_left) {
 | 
			
		||||
                end += PAGE_SIZE * 256;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return OverlapResult{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user