hg
author Gregory Szorc <gregory.szorc@gmail.com>
Mon, 13 Nov 2017 21:54:46 -0800
changeset 35119 764e3ad1cf54
parent 34533 163fa0aea71e
child 39592 5e78c100a215
permissions -rwxr-xr-x
bundle2: inline struct operations Before, we were calling struct.unpack() (via an alias) on every loop iteration. I'm not sure what Python does under the hood, but it would have to look at the struct format and determine what to do. This commit establishes a struct.Struct instance and reuses it for struct reading. We can see the impact from running `hg perfbundleread` on a Firefox bundle: ! read(8k) ! wall 0.679730 comb 0.680000 user 0.140000 sys 0.540000 (best of 15) ! read(16k) ! wall 0.577228 comb 0.570000 user 0.080000 sys 0.490000 (best of 17) ! read(32k) ! wall 0.516060 comb 0.520000 user 0.040000 sys 0.480000 (best of 20) ! read(128k) ! wall 0.496378 comb 0.490000 user 0.010000 sys 0.480000 (best of 20) ! bundle2 iterparts() ! wall 3.056811 comb 3.050000 user 2.340000 sys 0.710000 (best of 4) ! wall 2.992605 comb 2.990000 user 2.260000 sys 0.730000 (best of 4) ! bundle2 iterparts() seekable ! wall 4.007676 comb 4.000000 user 3.170000 sys 0.830000 (best of 3) ! wall 3.863810 comb 3.860000 user 3.000000 sys 0.860000 (best of 3) ! bundle2 part seek() ! wall 6.267110 comb 6.250000 user 3.480000 sys 2.770000 (best of 3) ! wall 6.213387 comb 6.200000 user 3.350000 sys 2.850000 (best of 3) ! bundle2 part read(8k) ! wall 3.404164 comb 3.400000 user 2.650000 sys 0.750000 (best of 3) ! wall 3.241099 comb 3.250000 user 2.560000 sys 0.690000 (best of 3) ! bundle2 part read(16k) ! wall 3.197972 comb 3.200000 user 2.490000 sys 0.710000 (best of 4) ! wall 3.003930 comb 3.000000 user 2.270000 sys 0.730000 (best of 4) ! bundle2 part read(32k) ! wall 3.060557 comb 3.060000 user 2.340000 sys 0.720000 (best of 4) ! wall 2.904695 comb 2.900000 user 2.160000 sys 0.740000 (best of 4) ! bundle2 part read(128k) ! wall 2.952209 comb 2.950000 user 2.230000 sys 0.720000 (best of 4) ! wall 2.776140 comb 2.780000 user 2.070000 sys 0.710000 (best of 4) Profiling now says most remaining time is spent in util.chunkbuffer. I already heavily optimized that data structure several releases ago. So we'll likely get little more performance out of bundle2 reading while still retaining util.chunkbuffer(). Differential Revision: https://phab.mercurial-scm.org/D1393
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     1
#!/usr/bin/env python
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     2
#
1698
ad4a2eefe4d7 Update copyright notice
Matt Mackall <mpm@selenic.com>
parents: 515
diff changeset
     3
# mercurial - scalable distributed SCM
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     4
#
4635
63b9d2deed48 Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3877
diff changeset
     5
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     6
#
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 7672
diff changeset
     7
# This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 8225
diff changeset
     8
# GNU General Public License version 2 or any later version.
33896
1900381b6a6e hg: update top-level script to use modern import conventions
Augie Fackler <raf@durin42.com>
parents: 32424
diff changeset
     9
from __future__ import absolute_import
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    10
12661
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 10263
diff changeset
    11
import os
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 10263
diff changeset
    12
import sys
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 10263
diff changeset
    13
21812
73e4a02e6d23 hg: add support for HGUNICODEPEDANTRY environment variable
Augie Fackler <raf@durin42.com>
parents: 14233
diff changeset
    14
if os.environ.get('HGUNICODEPEDANTRY', False):
29172
2ea9c9aa6e60 hg: limit HGUNICODEPEDANTRY to py2
timeless <timeless@mozdev.org>
parents: 21812
diff changeset
    15
    try:
2ea9c9aa6e60 hg: limit HGUNICODEPEDANTRY to py2
timeless <timeless@mozdev.org>
parents: 21812
diff changeset
    16
        reload(sys)
2ea9c9aa6e60 hg: limit HGUNICODEPEDANTRY to py2
timeless <timeless@mozdev.org>
parents: 21812
diff changeset
    17
        sys.setdefaultencoding("undefined")
2ea9c9aa6e60 hg: limit HGUNICODEPEDANTRY to py2
timeless <timeless@mozdev.org>
parents: 21812
diff changeset
    18
    except NameError:
2ea9c9aa6e60 hg: limit HGUNICODEPEDANTRY to py2
timeless <timeless@mozdev.org>
parents: 21812
diff changeset
    19
        pass
21812
73e4a02e6d23 hg: add support for HGUNICODEPEDANTRY environment variable
Augie Fackler <raf@durin42.com>
parents: 14233
diff changeset
    20
12661
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 10263
diff changeset
    21
libdir = '@LIBDIR@'
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 10263
diff changeset
    22
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 10263
diff changeset
    23
if libdir != '@' 'LIBDIR' '@':
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 10263
diff changeset
    24
    if not os.path.isabs(libdir):
12805
cae1c187abd4 setup/hg: handle hg being a symlink when appending relative libdir to sys.path
L. David Baron <dbaron@dbaron.org>
parents: 12661
diff changeset
    25
        libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
cae1c187abd4 setup/hg: handle hg being a symlink when appending relative libdir to sys.path
L. David Baron <dbaron@dbaron.org>
parents: 12661
diff changeset
    26
                              libdir)
12661
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 10263
diff changeset
    27
        libdir = os.path.abspath(libdir)
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 10263
diff changeset
    28
    sys.path.insert(0, libdir)
10da5a1f25dd setup/hg: always load Mercurial from where it was installed.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 10263
diff changeset
    29
5197
55860a45bbf2 Enable demandimport only in scripts, not in importable modules (issue605)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5178
diff changeset
    30
# enable importing on demand to reduce startup time
7672
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    31
try:
32424
b4810bf95c03 init: turn on demandimport for Python 3.6 and above
Siddharth Agarwal <sid0@fb.com>
parents: 29235
diff changeset
    32
    if sys.version_info[0] < 3 or sys.version_info >= (3, 6):
b4810bf95c03 init: turn on demandimport for Python 3.6 and above
Siddharth Agarwal <sid0@fb.com>
parents: 29235
diff changeset
    33
        import hgdemandimport; hgdemandimport.enable()
7672
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    34
except ImportError:
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    35
    sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    36
                     ' '.join(sys.path))
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    37
    sys.stderr.write("(check your install and PYTHONPATH)\n")
523c7816c33a Give a useful message about PYTHONPATH if startup fails
Matt Mackall <mpm@selenic.com>
parents: 5531
diff changeset
    38
    sys.exit(-1)
5197
55860a45bbf2 Enable demandimport only in scripts, not in importable modules (issue605)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5178
diff changeset
    39
34533
163fa0aea71e dispatch: move initialization of sys.std* files
Yuya Nishihara <yuya@tcha.org>
parents: 33896
diff changeset
    40
from mercurial import dispatch
33896
1900381b6a6e hg: update top-level script to use modern import conventions
Augie Fackler <raf@durin42.com>
parents: 32424
diff changeset
    41
dispatch.run()