mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 12:12:50 +01:00
Print PPU Syscall Usage Stats
* Every 10 seconds * On normal exit
This commit is contained in:
parent
d94b875187
commit
3105b21909
@ -1374,8 +1374,8 @@ extern void ppu_initialize(const ppu_module& info)
|
||||
{
|
||||
if (auto sc = ppu_get_syscall(index))
|
||||
{
|
||||
link_table.emplace(fmt::format("%s", ppu_syscall_code(index)), reinterpret_cast<u64>(sc));
|
||||
link_table.emplace(fmt::format("syscall_%u", index), reinterpret_cast<u64>(sc));
|
||||
link_table.emplace(fmt::format("%s", ppu_syscall_code(index)), reinterpret_cast<u64>(ppu_execute_syscall));
|
||||
link_table.emplace(fmt::format("syscall_%u", index), reinterpret_cast<u64>(ppu_execute_syscall));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -985,10 +985,66 @@ extern void ppu_initialize_syscalls()
|
||||
g_ppu_syscall_table = s_ppu_syscall_table;
|
||||
}
|
||||
|
||||
class ppu_syscall_usage
|
||||
{
|
||||
// Internal buffer
|
||||
std::string m_stats;
|
||||
|
||||
public:
|
||||
// Public info collection buffers
|
||||
atomic_t<u64> stat[1024]{};
|
||||
|
||||
void print_stats() noexcept
|
||||
{
|
||||
std::multimap<u64, u64, std::greater<u64>> usage;
|
||||
|
||||
for (u32 i = 0; i < 1024; i++)
|
||||
{
|
||||
if (u64 v = stat[i])
|
||||
{
|
||||
// Only add syscalls with non-zero usage counter
|
||||
usage.emplace(v, i);
|
||||
}
|
||||
}
|
||||
|
||||
m_stats.clear();
|
||||
|
||||
for (auto&& pair : usage)
|
||||
{
|
||||
fmt::append(m_stats, u8"\n\t⁂ %s [%u]", ppu_get_syscall_name(pair.second), pair.first);
|
||||
}
|
||||
|
||||
ppu_log.notice("PPU Syscall Usage Stats: %s", m_stats);
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
while (thread_ctrl::state() != thread_state::aborting)
|
||||
{
|
||||
std::this_thread::sleep_for(10s);
|
||||
print_stats();
|
||||
}
|
||||
}
|
||||
|
||||
~ppu_syscall_usage()
|
||||
{
|
||||
print_stats();
|
||||
}
|
||||
|
||||
static constexpr auto thread_name = "PPU Syscall Usage Thread"sv;
|
||||
};
|
||||
|
||||
extern void ppu_execute_syscall(ppu_thread& ppu, u64 code)
|
||||
{
|
||||
if (g_cfg.core.ppu_decoder == ppu_decoder_type::llvm)
|
||||
{
|
||||
code = ppu.gpr[11];
|
||||
}
|
||||
|
||||
if (code < g_ppu_syscall_table.size())
|
||||
{
|
||||
g_fxo->get<named_thread<ppu_syscall_usage>>()->stat[code]++;
|
||||
|
||||
if (auto func = g_ppu_syscall_table[code])
|
||||
{
|
||||
func(ppu);
|
||||
|
Loading…
Reference in New Issue
Block a user