mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-24 23:36:00 +03:00
[PR #3798] buffer_cache: Begin memory tracker rework #3723
Labels
No labels
Bloodborne
bug
contributor wanted
documentation
enhancement
frontend
good first issue
help wanted
linux
pull-request
question
release
verification progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shadPS4#3723
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/shadps4-emu/shadPS4/pull/3798
Author: @raphaelthegreat
Created: 11/14/2025
Status: 🔄 Open
Base:
main← Head:new-tracker📝 Commits (1)
94e4543buffer_cache: Begin memory tracker rework📊 Changes
10 files changed (+428 additions, -877 deletions)
View changed files
📝
CMakeLists.txt(+0 -2)➖
src/common/bit_array.h(+0 -406)➖
src/common/range_lock.h(+0 -101)📝
src/video_core/buffer_cache/buffer_cache.cpp(+2 -8)📝
src/video_core/buffer_cache/buffer_cache.h(+0 -3)📝
src/video_core/buffer_cache/memory_tracker.h(+66 -107)📝
src/video_core/buffer_cache/region_definitions.h(+57 -11)📝
src/video_core/buffer_cache/region_manager.h(+187 -133)📝
src/video_core/page_manager.cpp(+111 -97)📝
src/video_core/page_manager.h(+5 -9)📄 Description
This is split from buffer-cleanup branch to test it separately
Current memory tracker was a rewrite from https://github.com/shadps4-emu/shadPS4/pull/3070. The main advantage of that rework was batching memory protection actions for the whole region instead of just the modified areas. However the introduction of the bitset also restricted locking flexibility; a single lock for the entire region was required.
This rework aims to solve the second issue, that of lock granularity, while retaining the benefits. It is a mix of older and newer code, by taking the faster and more readable approaches from either case. Locking is now per-page; each word also has a lock bitmask that is set/cleared to acquire/release the locks. For uncontested case, acquiring a lock is a bitwise or and a cmpxchg instruction. Locks for up to 64 pages can also be acquired immediately for said case, so iterating larger memory regions remains fast. When the lock is contested, waitable atomics are used which (at least in libstdc++) will perform a spinloop and then sleep, behaving in similar fashion to an adaptive mutex.
Readbacks are still unimplemented because the new locking makes the old invalidate method annoying to reimplement. WIll be added again before this is done
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.