Why is it reported that opening YouTube in Google Chrome improves the processing speed of a homemade program by about 5%?



A seemingly mysterious phenomenon was reported on a forum for the programming language

FreeBASIC : 'Watching YouTube somehow made my own program run faster.' The surprising cause has been identified.

YouTube increases FreeBASIC performance (solved) - freebasic.net
https://freebasic.net/forum/viewtopic.php?t=27927

Provoni, a FreeBASIC forum user, reported that while opening YouTube in Google Chrome, his FreeBASIC program's multithreaded performance improved by about 5%. He noted that the same effect was not observed in Microsoft Edge, and only occurred when playing YouTube in Chrome.



Initially, speculation within the forum suggested that the increased CPU load caused by video playback might have caused Windows to disable its power-saving features, increasing the clock frequency. However, it was later concluded that the actual cause was the resolution of the Windows system timer.



The important thing here is the Sleep function , which temporarily stops program execution. The Sleep function is a command that suspends processing for a specified number of milliseconds and puts the program into a waiting state. For example, if you write 'Sleep(1)', the program will wait for 1 millisecond. This is a basic function used to adjust the timing of game rendering or to allow the CPU to rest so it doesn't occupy it unnecessarily.

Operating systems such as Windows manage time in small increments to allow multiple programs to run simultaneously. Typically, the smallest unit of time, or the resolution of the system timer, is set to a relatively coarse interval of approximately 15.6 milliseconds by default.

Even if a program issues a command to 'wait 1 millisecond (Sleep(1))', the resolution of the OS system timer is approximately 15.6 milliseconds, so the program will actually wait for more than 15 milliseconds until the next timing comes. This results in a significant loss of time throughout the program.



On the other hand, some browsers, such as Chrome and Firefox, forcibly change the resolution of the OS's system timer to a high-precision setting of 1 millisecond in order to play videos and music smoothly.

When Provoni opened YouTube, the browser behind the scenes increased the resolution of the OS's system timer, which resulted in the program's overall speed improving, as well as the accuracy of the waits it contained.

in Software, Posted by log1i_yk