mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 15:01:28 +12:00
PPU: Try to reduce wait for other threads
This commit is contained in:
parent
b4fc43d787
commit
bdceb24fd9
1 changed files with 25 additions and 8 deletions
|
@ -3443,29 +3443,46 @@ namespace
|
||||||
};
|
};
|
||||||
|
|
||||||
struct jit_module_manager
|
struct jit_module_manager
|
||||||
|
{
|
||||||
|
struct bucket_t
|
||||||
{
|
{
|
||||||
shared_mutex mutex;
|
shared_mutex mutex;
|
||||||
std::unordered_map<std::string, jit_module> map;
|
std::unordered_map<std::string, jit_module> map;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::array<bucket_t, 30> buckets;
|
||||||
|
|
||||||
|
bucket_t& get_bucket(std::string_view sv)
|
||||||
|
{
|
||||||
|
return buckets[std::hash<std::string_view>()(sv) % std::size(buckets)];
|
||||||
|
}
|
||||||
|
|
||||||
jit_module& get(const std::string& name)
|
jit_module& get(const std::string& name)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mutex);
|
bucket_t& bucket = get_bucket(name);
|
||||||
return map.emplace(name, jit_module{}).first->second;
|
std::lock_guard lock(bucket.mutex);
|
||||||
|
return bucket.map.emplace(name, jit_module{}).first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(const std::string& name) noexcept
|
void remove(const std::string& name) noexcept
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mutex);
|
bucket_t& bucket = get_bucket(name);
|
||||||
|
|
||||||
const auto found = map.find(name);
|
jit_module to_destroy{};
|
||||||
|
|
||||||
if (found == map.end()) [[unlikely]]
|
std::lock_guard lock(bucket.mutex);
|
||||||
|
const auto found = bucket.map.find(name);
|
||||||
|
|
||||||
|
if (found == bucket.map.end()) [[unlikely]]
|
||||||
{
|
{
|
||||||
ppu_log.error("Failed to remove module %s", name);
|
ppu_log.error("Failed to remove module %s", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
map.erase(found);
|
to_destroy.funcs = std::move(found->second.funcs);
|
||||||
|
to_destroy.pjit = std::move(found->second.pjit);
|
||||||
|
|
||||||
|
bucket.map.erase(found);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue