Introduce a spin lock for resources locked at a very high frequency

Constant buffer updates result in a barrage of std::mutex calls that take a lot of time even under no contention (around 5%). Using a custom spinlock in cases like these allows inlining locking code reducing the cost of locks under no contention to almost 0.
This commit is contained in:
Billy Laws
2022-08-31 16:38:04 +01:00
parent d810619203
commit 8471ab754d
6 changed files with 116 additions and 4 deletions

View File

@ -5,6 +5,7 @@
#include <common/linear_allocator.h>
#include <common/segment_table.h>
#include <common/spin_lock.h>
#include "buffer.h"
namespace skyline::gpu {
@ -28,7 +29,7 @@ namespace skyline::gpu {
struct LockedBuffer {
std::shared_ptr<Buffer> buffer;
ContextLock<Buffer> lock;
std::unique_lock<std::recursive_mutex> stateLock;
std::unique_lock<RecursiveSpinLock> stateLock;
LockedBuffer(std::shared_ptr<Buffer> pBuffer, ContextTag tag);