+- +-
Say hello if visiting :) by Gecko
11 Jan 2023, 07:43:05 pm

Seti is down again by Mike
09 Aug 2017, 10:02:44 am

Some considerations regarding OpenCL MultiBeam app tuning from algorithm view by Raistmer
11 Dec 2016, 06:30:56 am

Loading APU to the limit: performance considerations by Mike
05 Nov 2016, 06:49:26 am

Better sleep on Windows - new round by Raistmer
26 Aug 2016, 02:02:31 pm

Author Topic: Sleeping for less than 1ms in Windows - is it possible and how?  (Read 27568 times)

Offline Raistmer

  • Working Code Wizard
  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 14349
Re: Sleeping for less than 1ms in Windows - is it possible and how?
« Reply #15 on: 09 Nov 2013, 07:18:18 am »
Though initial goal looks unreachable I would like to collect here some useful info about windows time slices management.

This utility: http://technet.microsoft.com/en-us/sysinternals/bb897568
gives this result for my dev netbook:

C:\bin>Clockres.exe


ClockRes v2.0 - View the system clock resolution
Copyright (C) 2009 Mark Russinovich
SysInternals - www.sysinternals.com

Maximum timer interval: 15.600 ms
Minimum timer interval: 0.500 ms
Current timer interval: 1.000 ms

It could explain why I did not see any changes when used timeBeginPeriod(1); inside app.
What about yours PCs ? What value they use ?

WinXP AthlonXP, no GPGPU-enabled GPU inside:
Maximum timer interval: 15.625 ms
Minimum timer interval: 1.000 ms
Current timer interval: 15.625 ms
« Last Edit: 09 Nov 2013, 07:33:38 am by Raistmer »

Offline Raistmer

  • Working Code Wizard
  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 14349
Re: Sleeping for less than 1ms in Windows - is it possible and how?
« Reply #16 on: 09 Nov 2013, 07:55:44 am »
Read your own reference from first post a little bit more detailed. That person solved the problem of 100% CPU activity by combining QueryPerformanceCounters() with Sleep(0) and some other little tricks.

And, by the way, if it is possible to reduce the "active" wait time to some fraction of a millisecond, wouldn't that reduce the totals CPU and elapsed time, too ?

Sleep(0) in high-priority thread (and our worker GPU thread have higher priority than worker thread in CPU app) should "return" to higher priority thread, not to idle-priority CPU thread. So, with Sleep(0) we "make call" to OS scheduler, scheduler looks at current situation, sees GPU thread non-blocked, sees CPU thread non-blocked too but with idle priority and decides to run GPU thread again. Maybe I'm wrong though about GPU thread state that will be after calling Sleep(0).

Offline Raistmer

  • Working Code Wizard
  • Volunteer Developer
  • Knight who says 'Ni!'
  • *****
  • Posts: 14349
Re: Sleeping for less than 1ms in Windows - is it possible and how?
« Reply #17 on: 09 Nov 2013, 09:01:07 am »
ooops... more to CPU BOINC apps but should be known:

Quote
Note that the threads part of a process running in the idle process priority class always receive a
single thread quantum (2 clock ticks), ignoring any sort of quantum configuration settings, whether
set by default or set through the registry.
(Windows Internals, 6-th edition, part 1, p. 428)

This means that running ALL BOINC CPU applications as idle-priority class processes we deliberately degrade their performace! Even on dedicated crunchers OS will have to make scheduling decisions much more often than it could do for non-idle priority classes, especially on server OS.

Offline Josef W. Segur

  • Janitor o' the Board
  • Knight who says 'Ni!'
  • *****
  • Posts: 3112
Re: Sleeping for less than 1ms in Windows - is it possible and how?
« Reply #18 on: 10 Nov 2013, 12:16:05 am »
Though initial goal looks unreachable I would like to collect here some useful info about windows time slices management.

This utility: http://technet.microsoft.com/en-us/sysinternals/bb897568
...

Windows 7 SP1 x64, AMD A10-4600M quad core system:

ClockRes v2.0 - View the system clock resolution
Copyright (C) 2009 Mark Russinovich
SysInternals - www.sysinternals.com

Maximum timer interval: 15.600 ms
Minimum timer interval: 0.500 ms
Current timer interval: 15.600 ms



Windows 2000 SP4, Pentium-M single core system:

ClockRes v2.0 - View the system clock resolution
Copyright (C) 2009 Mark Russinovich
SysInternals - www.sysinternals.com

Maximum timer interval: 10.014 ms
Minimum timer interval: 1.003 ms
Current timer interval: 10.014 ms

                                                   Joe

Offline mr.mac52

  • Squire
  • *
  • Posts: 16
Re: Sleeping for less than 1ms in Windows - is it possible and how?
« Reply #19 on: 10 Nov 2013, 11:06:00 am »
Windows 7 SP1 x64 Core 2 Quad Q9300 @2.5GHz

ClockRes v2.0 - View the system clock resolution
Copyright (C) 2009 Mark Russinovich
SysInternals - www.sysinternals.com

Maximum timer interval: 15.600 ms
Minimum timer interval: 0.500 ms
Current timer interval: 1.000 ms

Windows 7 SP1 x64 Core i7-4770K @3.5GHz

ClockRes v2.0 - View the system clock resolution
Copyright (C) 2009 Mark Russinovich
SysInternals - www.sysinternals.com

Maximum timer interval: 15.600 ms
Minimum timer interval: 0.500 ms
Current timer interval: 1.000 ms

Offline arkayn

  • Janitor o' the Board
  • Knight who says 'Ni!'
  • *****
  • Posts: 1230
  • Aaaarrrrgggghhhh
    • My Little Place On The Internet
Re: Sleeping for less than 1ms in Windows - is it possible and how?
« Reply #20 on: 10 Nov 2013, 12:10:21 pm »
FX-4100 Windows 7 SP1 x64

ClockRes v2.0 - View the system clock resolution
Copyright (C) 2009 Mark Russinovich
SysInternals - www.sysinternals.com

Maximum timer interval: 15.600 ms
Minimum timer interval: 0.500 ms
Current timer interval: 1.000 ms

 

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?
Members
Total Members: 97
Latest: ToeBee
New This Month: 0
New This Week: 0
New Today: 0
Stats
Total Posts: 59559
Total Topics: 1672
Most Online Today: 20
Most Online Ever: 983
(20 Jan 2020, 03:17:55 pm)
Users Online
Members: 0
Guests: 105
Total: 105
Powered by EzPortal