Skip to content

Commit 27b064d

Browse files
committed
MDEV-33488 Windows 11 misdetects mariadbd as LowQoS process, throttles CPU.
The effect is reduced performance, at least on hybrid processor systems. To fix, turn off throttling power explicitly at server startup.
1 parent 53c6c82 commit 27b064d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

sql/winmain.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,25 @@ static const char *get_svc_name(const char *arg)
219219
return arg ? arg : "MySQL";
220220
}
221221

222+
/*
223+
Disable CPU throttling for the process.
224+
225+
Windows 11 heuristics misdetects server as a background process and runs it
226+
on "efficiency" cores, in hybrid architectures such as Alder Lake (12th
227+
generation Intel Core).This results in serious performance degradation.
228+
*/
229+
void disable_cpu_throttling()
230+
{
231+
#ifdef PROCESS_POWER_THROTTLING_EXECUTION_SPEED
232+
PROCESS_POWER_THROTTLING_STATE power_throttling{};
233+
power_throttling.Version= PROCESS_POWER_THROTTLING_CURRENT_VERSION;
234+
power_throttling.ControlMask= PROCESS_POWER_THROTTLING_EXECUTION_SPEED;
235+
power_throttling.StateMask= 0;
236+
SetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling,
237+
&power_throttling, sizeof(power_throttling));
238+
#endif
239+
}
240+
222241
/*
223242
Main function on Windows.
224243
Runs mysqld as normal process, or as a service.
@@ -230,6 +249,7 @@ __declspec(dllexport) int mysqld_win_main(int argc, char **argv)
230249
save_argv= argv;
231250
save_argc= argc;
232251

252+
disable_cpu_throttling();
233253
/*
234254
If no special arguments are given, service name is nor present
235255
run as normal program.

0 commit comments

Comments
 (0)