]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix high CPU usage in profiling on MS-Windows.
authorEli Zaretskii <eliz@gnu.org>
Mon, 1 Oct 2012 21:09:30 +0000 (23:09 +0200)
committerEli Zaretskii <eliz@gnu.org>
Mon, 1 Oct 2012 21:09:30 +0000 (23:09 +0200)
 src/w32proc.c (timer_loop): Fix code that waits for timer
 expiration, to avoid high CPU usage.

src/ChangeLog
src/w32proc.c

index ee7543a28304361919b537b30172612d4b1c9701..7061038fdec1ffa25a68b7b6cf82b6f5f435337a 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-01  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32proc.c (timer_loop): Fix code that waits for timer
+       expiration, to avoid high CPU usage.
+
 2012-10-01  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * fns.c (check_hash_table, get_key_arg, maybe_resize_hash_table)
index 4c20ca1337984be3a22caa0c055030f860bf8799..58e6117a7e8842f89967ce1bac0aea5399d2afef 100644 (file)
@@ -333,11 +333,11 @@ timer_loop (LPVOID arg)
          Sleep (sleep_time * 1000 / CLOCKS_PER_SEC);
          /* Always sleep past the expiration time, to make sure we
             never call the handler _before_ the expiration time,
-            always slightly after it.  Sleep(0) relinquishes the rest
-            of the scheduled slot, so that we let other threads
-            work.  */
+            always slightly after it.  Sleep(5) makes sure we don't
+            hog the CPU by calling 'clock' with high frequency, and
+            also let other threads work.  */
          while (clock () < expire)
-           Sleep (0);
+           Sleep (5);
        }
 
       if (itimer->expire == 0)