hgweb.cgi
author Gregory Szorc <gregory.szorc@gmail.com>
Mon, 13 Nov 2017 21:54:46 -0800
changeset 35119 764e3ad1cf54
parent 26421 4b0fc75f9403
child 43691 47ef023d0165
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:
202
e875a0cf7f3a Call python via env in hgweb.cgi
mpm@selenic.com
parents: 159
diff changeset
     1
#!/usr/bin/env python
159
f9d8620ef469 Add example CGI script
mpm@selenic.com
parents:
diff changeset
     2
#
11000
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
     3
# An example hgweb CGI script, edit as necessary
26421
4b0fc75f9403 urls: bulk-change primary website URLs
Matt Mackall <mpm@selenic.com>
parents: 15475
diff changeset
     4
# See also https://mercurial-scm.org/wiki/PublishingRepositories
159
f9d8620ef469 Add example CGI script
mpm@selenic.com
parents:
diff changeset
     5
11000
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
     6
# Path to repo or hgweb config to serve (see 'hg help hgweb')
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
     7
config = "/path/to/repo/or/config"
5244
79279b5583c6 cgi: sys.path.insert should be before importing mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5197
diff changeset
     8
15475
85cba926cb59 hgweb: add hint about finding library path with debuginstall
Matt Mackall <mpm@selenic.com>
parents: 11503
diff changeset
     9
# Uncomment and adjust if Mercurial is not installed system-wide
85cba926cb59 hgweb: add hint about finding library path with debuginstall
Matt Mackall <mpm@selenic.com>
parents: 11503
diff changeset
    10
# (consult "installed modules" path from 'hg debuginstall'):
11000
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
    11
#import sys; sys.path.insert(0, "/path/to/python/lib")
5197
55860a45bbf2 Enable demandimport only in scripts, not in importable modules (issue605)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3868
diff changeset
    12
6080
4baad19c4801 hgweb: disable cgitb by default
Maxim Dounin <mdounin@mdounin.ru>
parents: 5995
diff changeset
    13
# Uncomment to send python tracebacks to the browser if an error occurs:
11000
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
    14
#import cgitb; cgitb.enable()
391
5f65a108a559 hgweb: pull cgitb into CGI script example, where it can easily be disabled
mpm@selenic.com
parents: 202
diff changeset
    15
11000
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
    16
from mercurial import demandimport; demandimport.enable()
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
    17
from mercurial.hgweb import hgweb, wsgicgi
338167735124 hgweb: simplify hgweb.cgi, add help pointer
Matt Mackall <mpm@selenic.com>
parents: 6142
diff changeset
    18
application = hgweb(config)
6141
90e5c82a3859 Backed out changeset b913d3aacddc (see issue971/msg5317)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5995
diff changeset
    19
wsgicgi.launch(application)