Patchwork [7,of,7] dirstate: make delaywrite sleep until the next multiple of n seconds

login
register
mail settings
Submitter Matt Mackall
Date Dec. 17, 2015, 2:59 a.m.
Message ID <db6aab9cc751e1b752bf.1450321183@ruin.waste.org>
Download mbox | patch
Permalink /patch/12093/
State Accepted
Commit 425dc70037f7937a61b355bbc564877edd301ac3
Headers show

Comments

Matt Mackall - Dec. 17, 2015, 2:59 a.m.
# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 1450321106 21600
#      Wed Dec 16 20:58:26 2015 -0600
# Node ID db6aab9cc751e1b752bf329ac8b3a9c64cf1eef9
# Parent  1aa6cdd42ae70bb2be9718b99316ca13b0d1443d
dirstate: make delaywrite sleep until the next multiple of n seconds

Rather than sleep for 2 seconds, we sleep until the next even-numbered
second, which has the same effect, but makes tests faster. This
removes test-largefiles-update as the long pole of the test suite.
Martin von Zweigbergk - Dec. 17, 2015, 6:16 a.m.
Thanks! Pushed to the clowncopter.

Patch

diff -r 1aa6cdd42ae7 -r db6aab9cc751 mercurial/dirstate.py
--- a/mercurial/dirstate.py	Wed Dec 16 20:49:18 2015 -0600
+++ b/mercurial/dirstate.py	Wed Dec 16 20:58:26 2015 -0600
@@ -712,7 +712,12 @@ 
             for f, e in self._map.iteritems():
                 if e[0] == 'n' and e[3] == now:
                     import time # to avoid useless import
-                    time.sleep(delaywrite)
+                    # rather than sleep n seconds, sleep until the next
+                    # multiple of n seconds
+                    clock = time.time()
+                    start = int(clock) - (int(clock) % delaywrite)
+                    end = start + delaywrite
+                    time.sleep(end - clock)
                     break
 
         st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))