Patchwork [2,of,3] dirstate: fix debug.dirstate.delaywrite to use the new "now" after sleeping

login
register
mail settings
Submitter Mads Kiilerich
Date Oct. 18, 2016, 3:19 p.m.
Message ID <cde3cae17cba67f80b9f.1476803986@madski>
Download mbox | patch
Permalink /patch/17170/
State Accepted
Headers show

Comments

Mads Kiilerich - Oct. 18, 2016, 3:19 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1476802355 -7200
#      Tue Oct 18 16:52:35 2016 +0200
# Node ID cde3cae17cba67f80b9f1b41e5cc5fe3b87cd06f
# Parent  6d4322a34c2a543665d702fd10f38f1af6001715
dirstate: fix debug.dirstate.delaywrite to use the new "now" after sleeping

It seems like the a regression has sneaked into debug.dirstate.delaywrite in
6c6b48aca328. It would sleep until no files were modified "now" any more, but
when writing the dirstate it would use the old "now" and still mark files as
'unset' instead of recording the timestamp that would make the file show up as
clean instead of unknown.

Instead of getting a new "now" from the file system, we trust the computed end
time as the new "now" and thus cause the actual modification time to be
writiten to the dirstate.

debug.dirstate.delaywrite is undocumented and only used in
test-largefiles-update.t . All tests seems to work fine for me without
debug.dirstate.delaywrite . Perhaps because it not really worked as intended
without the fix in this patch, and code and tests thus have evolved to do fine
without it? It could thus perhaps make sense to drop usage of this setting in
the tests. That could speed the test up a bit.

This functionality (or something very similar) can however apparently be very
convenient in setups where checking dirty-ness is expensive - such as when
using large files and have slow file filesystems or are CPU constrained. Now it
works and we can try it. (But ideally, for the largefile use case, it should
probably only delay lfdirstate writes - not ordinary dirstate.)
Augie Fackler - Oct. 20, 2016, 2:07 p.m.
On Tue, Oct 18, 2016 at 05:19:46PM +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1476802355 -7200
> #      Tue Oct 18 16:52:35 2016 +0200
> # Node ID cde3cae17cba67f80b9f1b41e5cc5fe3b87cd06f
> # Parent  6d4322a34c2a543665d702fd10f38f1af6001715
> dirstate: fix debug.dirstate.delaywrite to use the new "now" after sleeping

Given this has the magic word regression, I've queued this patch for stable. Thanks!

(Please resend the other two after 4.0 drops)

>
> It seems like the a regression has sneaked into debug.dirstate.delaywrite in
> 6c6b48aca328. It would sleep until no files were modified "now" any more, but
> when writing the dirstate it would use the old "now" and still mark files as
> 'unset' instead of recording the timestamp that would make the file show up as
> clean instead of unknown.
>
> Instead of getting a new "now" from the file system, we trust the computed end
> time as the new "now" and thus cause the actual modification time to be
> writiten to the dirstate.
>
> debug.dirstate.delaywrite is undocumented and only used in
> test-largefiles-update.t . All tests seems to work fine for me without
> debug.dirstate.delaywrite . Perhaps because it not really worked as intended
> without the fix in this patch, and code and tests thus have evolved to do fine
> without it? It could thus perhaps make sense to drop usage of this setting in
> the tests. That could speed the test up a bit.
>
> This functionality (or something very similar) can however apparently be very
> convenient in setups where checking dirty-ness is expensive - such as when
> using large files and have slow file filesystems or are CPU constrained. Now it
> works and we can try it. (But ideally, for the largefile use case, it should
> probably only delay lfdirstate writes - not ordinary dirstate.)
>
> diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
> --- a/mercurial/dirstate.py
> +++ b/mercurial/dirstate.py
> @@ -757,6 +757,7 @@ class dirstate(object):
>                      start = int(clock) - (int(clock) % delaywrite)
>                      end = start + delaywrite
>                      time.sleep(end - clock)
> +                    now = end # trust our estimate that the end is near now
>                      break
>
>          st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -757,6 +757,7 @@  class dirstate(object):
                     start = int(clock) - (int(clock) % delaywrite)
                     end = start + delaywrite
                     time.sleep(end - clock)
+                    now = end # trust our estimate that the end is near now
                     break
 
         st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))