Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: CAFxX on April 17, 2011, 09:59:24 AM



Title: [PULL] Low I/O and CPU priority during process initialization
Post by: CAFxX on April 17, 2011, 09:59:24 AM
https://github.com/bitcoin/bitcoin/pull/161 (https://github.com/bitcoin/bitcoin/pull/161)

If starting in GUI mode or with the -nicestart option run the disk-intensive initialization with low priority. As soon as initialization is over, switch back to normal priority. This should help especially if starting bitcoin at system startup.
Windows-only for now.


Title: Re: [PULL] Low I/O and CPU priority during process initialization
Post by: CAFxX on April 18, 2011, 11:10:38 AM
This is a short quote from the MSDN (http://msdn.microsoft.com/en-us/library/ms686219%28v=vs.85%29.aspx):
Quote
The *_PRIORITY_CLASS values affect the CPU scheduling priority of the process. For processes that perform background work such as file I/O, network I/O, or data processing, it is not sufficient to adjust the CPU scheduling priority; even an idle CPU priority process can easily interfere with system responsiveness when it uses the disk and memory. Processes that perform background work should use the PROCESS_MODE_BACKGROUND_BEGIN and PROCESS_MODE_BACKGROUND_END values to adjust their resource scheduling priorities; processes that interact with the user should not use PROCESS_MODE_BACKGROUND_BEGIN.

If a process is in background processing mode, the new threads it creates will also be in background processing mode. When a thread is in background processing mode, it should minimize sharing resources such as critical sections, heaps, and handles with other threads in the process, otherwise priority inversions can occur. If there are threads executing at high priority, a thread in background processing mode may not be scheduled promptly, but it will never be starved.


Title: Re: [PULL] Low I/O and CPU priority during process initialization
Post by: CAFxX on April 18, 2011, 11:48:11 AM
For processes that perform background work such as file I/O, network I/O, or data processing, it is not sufficient to adjust the CPU scheduling priority; even an idle CPU priority process can easily interfere with system responsiveness when it uses the disk and memory. Processes that perform background work should use the PROCESS_MODE_BACKGROUND_BEGIN and PROCESS_MODE_BACKGROUND_END values to adjust their resource scheduling priorities
In the long run, probably, also all worker threads that are not GUI-related should be made to use this background processing mode. I have no idea how to do the same thing on other OSes.


Title: Re: [PULL] Low I/O and CPU priority during process initialization
Post by: CAFxX on April 19, 2011, 08:59:32 AM
For processes that perform background work such as file I/O, network I/O, or data processing, it is not sufficient to adjust the CPU scheduling priority; even an idle CPU priority process can easily interfere with system responsiveness when it uses the disk and memory. Processes that perform background work should use the PROCESS_MODE_BACKGROUND_BEGIN and PROCESS_MODE_BACKGROUND_END values to adjust their resource scheduling priorities
In the long run, probably, also all worker threads that are not GUI-related should be made to use this background processing mode. I have no idea how to do the same thing on other OSes.
I went ahead and implemented this in a second, separate pull request (https://github.com/bitcoin/bitcoin/pull/168). As usual, Windows-only for now.


Title: Re: [PULL] Low I/O and CPU priority during process initialization
Post by: CAFxX on April 20, 2011, 02:12:54 PM
*bump*