Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions rpcs3/util/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,17 +812,23 @@ static const bool s_tsc_freq_evaluated = []() -> bool
}

#ifdef _WIN32
LARGE_INTEGER freq;
LARGE_INTEGER freq{};
if (!QueryPerformanceFrequency(&freq))
{
return 0;
}

if (freq.QuadPart <= 9'999'999)
if (!freq.QuadPart)
{
return 0;
}

if (freq.QuadPart <= 50'000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is possible for any known TSC. 50KHz cycle counter is way too coarse for a high precision timer.
For reference the archaic RTC already has 32k resolution.
Let's gather data for now though before we decide which values to use for tuning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't about possible motherboards or CPUs or operating system settings, it's the constraint for the function itself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get that, but why 50k then? Why isn't any non-zero value legal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the other explanation, it makes sense to have a lower bound. Let's at least make it a named constexpr like min_supported_tsc_frequency instead of magic constants.

{
// Bad precision
return 0;
}

const ullong timer_freq = freq.QuadPart;
#else

Expand Down Expand Up @@ -890,7 +896,7 @@ static const bool s_tsc_freq_evaluated = []() -> bool
const ullong sec_base = ts0.tv_sec;
#endif

constexpr usz sleep_time_ms = 40;
const usz sleep_time_ms = timer_freq <= 300'000 ? (300'000 * 50) / timer_freq : 50;

for (usz sample = 0; sample < sample_count; sample++)
{
Expand Down
Loading