# HG changeset patch # User Pierre-Yves David # Date 1682692123 -7200 # Node ID 714b63a707b741a7898dcc6a84b5e604dd627aa8 # Parent 392e2f31444a43eec9924f4c6f0ae8da9d5a74d0 perf: introduce a `perf::stream-locked-section` command This command benchmark the initial part of a stream clone, where the repository is locked. diff -r 392e2f31444a -r 714b63a707b7 contrib/perf.py --- a/contrib/perf.py Wed May 03 18:17:32 2023 -0300 +++ b/contrib/perf.py Fri Apr 28 16:28:43 2023 +0200 @@ -1900,6 +1900,57 @@ fm.end() +@command( + b'perf::stream-locked-section', + [ + ( + b'', + b'stream-version', + b'latest', + b'stream version to us ("v1", "v2" or "latest", (the default))', + ), + ] + + formatteropts, +) +def perf_stream_clone_scan(ui, repo, stream_version, **opts): + """benchmark the initial, repo-locked, section of a stream-clone""" + import mercurial.streamclone + + generatev1 = mercurial.streamclone.generatev1 + generatev2 = mercurial.streamclone.generatev2 + + opts = _byteskwargs(opts) + timer, fm = gettimer(ui, opts) + + # deletion of the generator may trigger some cleanup that we do not want to + # measure + result_holder = [None] + + def setupone(): + result_holder[0] = None + + def runone_v1(): + # the lock is held for the duration the initialisation + result_holder[0] = generatev1(repo) + + def runone_v2(): + # the lock is held for the duration the initialisation + result_holder[0] = generatev2(repo, None, None, True) + + if stream_version == b'latest': + runone = runone_v2 + elif stream_version == b'v2': + runone = runone_v2 + elif stream_version == b'v1': + runone = runone_v1 + else: + msg = b'unknown stream version: "%s"' % stream_version + raise error.Abort(msg) + + timer(runone, setup=setupone, title=b"load") + fm.end() + + @command(b'perf::parents|perfparents', formatteropts) def perfparents(ui, repo, **opts): """benchmark the time necessary to fetch one changeset's parents. diff -r 392e2f31444a -r 714b63a707b7 tests/test-contrib-perf.t --- a/tests/test-contrib-perf.t Wed May 03 18:17:32 2023 -0300 +++ b/tests/test-contrib-perf.t Fri Apr 28 16:28:43 2023 +0200 @@ -188,6 +188,8 @@ perf::startup (no help text available) perf::status benchmark the performance of a single status call + perf::stream-locked-section + benchmark the initial, repo-locked, section of a stream-clone perf::tags (no help text available) perf::templating test the rendering time of a given template