Bugzilla – Bug 8525
Use Windows Vista low priority I/O for scanner
Last modified: 2010-12-04 12:26:25 UTC
Windows Vista includes a low priority I/O feature that would further reduce the impact of the scanner process on music playback, etc. (beyond what the current CPU priority options achieves). See the PROCESS_MODE_BACKGROUND_BEGIN constant in SetPriorityClass (http://msdn.microsoft.com/en-us/library/ms686219(VS.85).aspx). I've attached an patch that changes changes Slim::Utils:Misc to set Very Low priority I/O for Below Normal and Low CPU priorities and Normal I/O priority for higher CPU priorities. This works for me, as I have SqueezeCentre set to High and the scanner set to Low. The patch has several problems but it does illustrate low priority I/O working: - it sets low priority I/O for SqueezeCentre too (if SqueezeCentre is set to Below Normal or Low). This is a bad idea, but then again who would set SS to anything below Normal? - it doesn't cater for those who want lower CPU priority for the scanner but normal I/O priority. - perhaps it should be a separate pref. for just the scanner. - I doesn't check that it's running on Vista or above (I don't know what happens if you use PROCESS_MODE_BACKGROUND_BEGIN/PROCESS_MODE_BACKGROUND_BEGIN_END on 2000/XP/2003). - It should check whether PROCESS_MODE_BACKGROUND_BEGIN/PROCESS_MODE_BACKGROUND_BEGIN_END has been set already before setting it again ("The function fails if the process is already in background processing mode"). - I couldn't get a logical OR working, so I've repeated the API call again and again (I don't know Perl!). For the record, in testing I found that Vista 'boxes in' processes (and their children) run by Scheduled Tasks to Low and Very Low I/O priority (using PROCESS_MODE_BACKGROUND_BEGIN always sets Very Low; Low seems to be only ever set or be settable by Scheduled Tasks). See: http://technet.microsoft.com/en-us/magazine/cc162494.aspx http://blogs.technet.com/askperf/archive/2008/02/07/ws2008-memory-management-dynamic-kernel-addressing-memory-priorities-and-i-o-handling.aspx Useful to know when you're running SqueezeCentre via a scheduled task and you can't work out why the API call won't set Normal I/O priority...
Created attachment 3468 [details] Sets low priority IO for use on Vista
Process Explorer (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx) can show the I/O priority of processes.
We'll keep and eye on this and come back to it if there's more interest or votes or comments. Feel free to stir up support on the forums!
Created attachment 4449 [details] Updated patch for v7.3 Uses the same method as the previous patch.
Some performance statistics... On a computer with: - AMD 2.4 GHz X2 CPU - 2 GB RAM - 500 GB 7200 RPM HDD - Dedicated to SqueezeCentre - Peforming no tasks other SqueeCentre/scanner With a database of: - 12,083 FLAC tracks - 869 albums - 377 artists - 26 genres Took ~ 26 minutes with the scanner process at Idle CPU priority / normal I/O priority (i.e. without the attached patch) and ~ 30 minutes at Idle CPU priority / Very Low I/O priority. Obviously if there were other processes performing significant I/O which had I/O priorities higher than Very Low, the scanning process would take longer (which is what is desired). However, it does show the magnitude of the slow-down due to just the lower I/O priority.
Opps - comment 5 refers to a wipe/rescan.
And it's a 2.0 GHz CPU (but that shouldn't matter much to the relative times).
Moving 7.4 bugs to 8.0.
Created attachment 6494 [details] Updated for v7.4
Created attachment 6744 [details] For 7.4 but updated to check for Vista+ and only set very low I/O priority when CPU priority is low I've updated the patch to: - check that it's running on Windows Vista or above (only these OSs support I/O priority) - only set VERY LOW I/O priority when CPU priority is LOW. The latter change corresponds to what Windows Task Scheduler does - it uses LOW I/O priority with BELOW NORMAL CPU priority for tasks. Therefore, using VERY LOW I/O priority with to LOW CPU priority is a reasonable match. Setting I/O priority to LOW isn't possible using the published API, otherwise we could do this for when CPU priority is BELOW_NORMAL. I think this is a safe default setting - if one sets scanner CPU priority to LOW, it's safe to assume the user is trying to avoid the scanner having an affect on streaming or other tasks on the server. My tests indicate only a slight slowdown in scanning speed on an unloaded server (see previous comments). This is currently not a separate preference (e.g. a checkbox for "Use very low priority I/O for the scanner". Is this desired in order to get this patch added to Squeezebox Server? Thanks.
Is there any interest in getting this added to Squeezebox Server? Would it need a separate preference to enable this? Or is it okay for it to be combined with the scanner CPU priority? If it needs a separate preference, I could take a look to see if I can add one (not done that before but can try). Thanks.