##// END OF EJS Templates
localrepo: also fastpath access to working copy parents when possible...
localrepo: also fastpath access to working copy parents when possible If the filter level guarantee that the working copy parents will be visible, we allow fast path access to them. With this change multiple commands can now run without triggering filtering. After using the quick access mechanism introduced, the whole series results in pretty good performance gain: ``` All benchmarks: before after ratio [8e095512] [36b2f659] - 711±0.8ms 60.7±0.2ms 0.09 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 712±0.8ms 61.6±0.2ms 0.09 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 690±1ms 93.5±0.3ms 0.14 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 688±1ms 93.8±0.3ms 0.14 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 714±1ms 60.7±0.8ms 0.09 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 713±1ms 60.9±0.3ms 0.09 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 689±1ms 93.7±0.2ms 0.14 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 687±2ms 92.8±0.2ms 0.14 simple_command.read.diff.empty.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 799±2ms 98.1±0.6ms 0.12 simple_command.read.export.bare.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 800±0.8ms 100.0±0.4ms 0.12 simple_command.read.export.bare.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 711±0.9ms 111±0.2ms 0.16 simple_command.read.export.bare.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 711±1ms 112±0.3ms 0.16 simple_command.read.export.bare.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 760±1ms 59.8±0.1ms 0.08 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 763±2ms 62.2±0.3ms 0.08 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 689±1ms 93.1±0.3ms 0.14 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 688±1ms 94.3±0.3ms 0.14 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 1) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 763±1ms 60.1±0.2ms 0.08 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 763±1ms 62.1±0.4ms 0.08 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py2.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] - 689±0.8ms 93.2±0.2ms 0.14 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYc-HGWITHRUSTEXTcpython] - 687±0.9ms 94.1±0.3ms 0.14 simple_command.read.status.wc_clean.default.time_bench('mercurial-filtered-2019-11-22', 'zstd', 'default', True, True, True, True, True, 2) [citrea/virtualenv-py3.7-pyyaml-HGMODULEPOLICYrust+c-HGWITHRUSTEXTcpython] ``` Differential Revision: https://phab.mercurial-scm.org/D7492

File last commit:

r44531:806d14ef default
r44563:85c4cd73 default
Show More
watchmanclient.py
129 lines | 3.8 KiB | text/x-python | PythonLexer
Martijn Pieters
fsmonitor: new experimental extension...
r28433 # watchmanclient.py - Watchman client for the fsmonitor extension
#
# Copyright 2013-2016 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
import getpass
Gregory Szorc
fsmonitor: normalize exception types to bytes...
r43716 from mercurial import (
encoding,
util,
)
from mercurial.utils import (
procutil,
stringutil,
)
Martijn Pieters
fsmonitor: new experimental extension...
r28433
from . import pywatchman
Augie Fackler
formatting: blacken the codebase...
r43346
Martijn Pieters
fsmonitor: new experimental extension...
r28433 class Unavailable(Exception):
def __init__(self, msg, warn=True, invalidate=False):
self.msg = msg
self.warn = warn
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if self.msg == b'timed out waiting for response':
Martijn Pieters
fsmonitor: new experimental extension...
r28433 self.warn = False
self.invalidate = invalidate
Gregory Szorc
fsmonitor: normalize exception types to bytes...
r43716 def __bytes__(self):
Martijn Pieters
fsmonitor: new experimental extension...
r28433 if self.warn:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return b'warning: Watchman unavailable: %s' % self.msg
Martijn Pieters
fsmonitor: new experimental extension...
r28433 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return b'Watchman unavailable: %s' % self.msg
Martijn Pieters
fsmonitor: new experimental extension...
r28433
Gregory Szorc
fsmonitor: normalize exception types to bytes...
r43716 __str__ = encoding.strmethod(__bytes__)
Augie Fackler
formatting: blacken the codebase...
r43346
Martijn Pieters
fsmonitor: new experimental extension...
r28433 class WatchmanNoRoot(Unavailable):
def __init__(self, root, msg):
self.root = root
super(WatchmanNoRoot, self).__init__(msg)
Augie Fackler
formatting: blacken the codebase...
r43346
Martijn Pieters
fsmonitor: new experimental extension...
r28433 class client(object):
Augie Fackler
fsmonitor: refactor watchmanclient.client to accept ui and repo path...
r42877 def __init__(self, ui, root, timeout=1.0):
Martijn Pieters
fsmonitor: new experimental extension...
r28433 err = None
if not self._user:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 err = b"couldn't get user"
Martijn Pieters
fsmonitor: new experimental extension...
r28433 warn = True
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if self._user in ui.configlist(b'fsmonitor', b'blacklistusers'):
err = b'user %s in blacklist' % self._user
Martijn Pieters
fsmonitor: new experimental extension...
r28433 warn = False
if err:
raise Unavailable(err, warn)
self._timeout = timeout
self._watchmanclient = None
Augie Fackler
fsmonitor: refactor watchmanclient.client to accept ui and repo path...
r42877 self._root = root
self._ui = ui
Martijn Pieters
fsmonitor: new experimental extension...
r28433 self._firsttime = True
def settimeout(self, timeout):
self._timeout = timeout
if self._watchmanclient is not None:
self._watchmanclient.setTimeout(timeout)
def getcurrentclock(self):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 result = self.command(b'clock')
Martin von Zweigbergk
py3: delete b'' prefix from safehasattr arguments...
r43385 if not util.safehasattr(result, 'clock'):
Augie Fackler
formatting: blacken the codebase...
r43346 raise Unavailable(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'clock result is missing clock value', invalidate=True
Augie Fackler
formatting: blacken the codebase...
r43346 )
Martijn Pieters
fsmonitor: new experimental extension...
r28433 return result.clock
def clearconnection(self):
self._watchmanclient = None
def available(self):
return self._watchmanclient is not None or self._firsttime
@util.propertycache
def _user(self):
try:
return getpass.getuser()
except KeyError:
# couldn't figure out our user
return None
def _command(self, *args):
watchmanargs = (args[0], self._root) + args[1:]
try:
if self._watchmanclient is None:
self._firsttime = False
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 watchman_exe = self._ui.configpath(
b'fsmonitor', b'watchman_exe'
)
Martijn Pieters
fsmonitor: new experimental extension...
r28433 self._watchmanclient = pywatchman.client(
timeout=self._timeout,
Boris Feld
watchman: add the possibility to set the exact watchman binary location...
r42134 useImmutableBser=True,
Gregory Szorc
fsmonitor: refresh pywatchman with upstream...
r43703 binpath=procutil.tonativestr(watchman_exe),
Augie Fackler
formatting: blacken the codebase...
r43346 )
Martijn Pieters
fsmonitor: new experimental extension...
r28433 return self._watchmanclient.query(*watchmanargs)
except pywatchman.CommandError as ex:
Gregory Szorc
fsmonitor: properly handle str ex.msg...
r44531 if 'unable to resolve root' in ex.msg:
Gregory Szorc
fsmonitor: normalize exception types to bytes...
r43716 raise WatchmanNoRoot(
self._root, stringutil.forcebytestr(ex.msg)
)
Gregory Szorc
fsmonitor: properly handle str ex.msg...
r44531 raise Unavailable(stringutil.forcebytestr(ex.msg))
Martijn Pieters
fsmonitor: new experimental extension...
r28433 except pywatchman.WatchmanError as ex:
Gregory Szorc
fsmonitor: normalize exception types to bytes...
r43716 raise Unavailable(stringutil.forcebytestr(ex))
Martijn Pieters
fsmonitor: new experimental extension...
r28433
def command(self, *args):
try:
try:
return self._command(*args)
except WatchmanNoRoot:
# this 'watch' command can also raise a WatchmanNoRoot if
# watchman refuses to accept this root
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 self._command(b'watch')
Martijn Pieters
fsmonitor: new experimental extension...
r28433 return self._command(*args)
except Unavailable:
# this is in an outer scope to catch Unavailable form any of the
# above _command calls
self._watchmanclient = None
raise