[PATCH V2] fsmonitor: match watchman and filesystem encoding

Olivier Trempe oliviertrempe at gmail.com
Thu Apr 6 14:42:06 EDT 2017


On Wed, Apr 5, 2017 at 4:43 PM, Siddharth Agarwal <sid at less-broken.com>
wrote:

> On 4/5/17 13:30, Olivier Trempe wrote:
>
>> Absolutely. This will be fixed in V3.
>> I also realize the "import sys" statement was removed 3 months ago. I
>> missed it when rebasing... This will also be fixed in V3.
>>
>
> Thanks.
>
> In general, do you think you could add a test for the behavior where
> fsmonitor currently fails? I assume any non-ASCII filenames will cause
> issues.


I just spent some time trying to write a test, but it is a real pain to
make it work on Windows. It's already a feat to run mercurial tests on
Windows. Then adding fsmonitor to this just adds another level of pain. I
won't spend more time writing the test...


>
>> >>
>> >> +
>> >> +    return decoded.encode(_fsencoding, 'replace')
>> >> +
>> >>   def overridewalk(orig, self, match, subrepos, unknown, ignored,
>> full=True):
>> >>       '''Replacement for dirstate.walk, hooking into Watchman.
>> >>   @@ -303,6 +323,8 @@
>> >>       # for name case changes.
>> >>       for entry in result['files']:
>> >>           fname = entry['name']
>> >> +        if _fixencoding:
>> >> +            fname = _watchmantofsencoding(fname)
>> >
>> >
>> > This is a critical path IIRC, so I'm a little concerned about
>> performance here -- both on Mac/Linux where _fixencoding will (always?) be
>> false and on Windows where it will (always?) be true.
>> >
>> > Any chance you you could measure the before and after with (say) 10,000
>> files in the result set? Thanks!
>> >
>>
>> There is a little overhead at module import:
>> python -m timeit "import hgext.fsmonitor"
>> Windows before patch: 1000000 loops, best of 3: 0.563 usec per loop
>> Windows after patch: 1000000 loops, best of 3: 0.583 usec per loop
>> Linx before patch: 1000000 loops, best of 3: 0.628 usec per loop
>> Linux after patch: 1000000 loops, best of 3: 0.579 usec per loop
>>
>> 10000 calls to _watchmantofsencoding:
>> python -m timeit -s "from hgext.fsmonitor import _watchmantofsencoding,
>> _fixencoding" "fname = '/path/to/file'" "for i in range(10000):" "    if
>> _fixencoding: fname = _watchmantofsencoding(fname)"
>> Windows (_fixencoding is True): 100 loops, best of 3: 19.5 msec per loop
>> Linux (_fixencoding is False): 100 loops, best of 3: 3.08 msec per loop
>>
>> Do you want me to include these results in the commit message?
>>
>
> Yes, that would be great! Thanks.
>
>
>
>> >
>> >>           if switch_slashes:
>> >>               fname = fname.replace('\\', '/')
>> >>           if normalize:
>> >
>> >
>> >
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170406/9298aece/attachment.html>


More information about the Mercurial-devel mailing list