comparison contrib/perf.py @ 50458:714b63a707b7

perf: introduce a `perf::stream-locked-section` command This command benchmark the initial part of a stream clone, where the repository is locked.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 28 Apr 2023 16:28:43 +0200
parents ec3631290eb7
children b10c786b0145
comparison
equal deleted inserted replaced
50457:392e2f31444a 50458:714b63a707b7
1898 1898
1899 timer(d) 1899 timer(d)
1900 fm.end() 1900 fm.end()
1901 1901
1902 1902
1903 @command(
1904 b'perf::stream-locked-section',
1905 [
1906 (
1907 b'',
1908 b'stream-version',
1909 b'latest',
1910 b'stream version to us ("v1", "v2" or "latest", (the default))',
1911 ),
1912 ]
1913 + formatteropts,
1914 )
1915 def perf_stream_clone_scan(ui, repo, stream_version, **opts):
1916 """benchmark the initial, repo-locked, section of a stream-clone"""
1917 import mercurial.streamclone
1918
1919 generatev1 = mercurial.streamclone.generatev1
1920 generatev2 = mercurial.streamclone.generatev2
1921
1922 opts = _byteskwargs(opts)
1923 timer, fm = gettimer(ui, opts)
1924
1925 # deletion of the generator may trigger some cleanup that we do not want to
1926 # measure
1927 result_holder = [None]
1928
1929 def setupone():
1930 result_holder[0] = None
1931
1932 def runone_v1():
1933 # the lock is held for the duration the initialisation
1934 result_holder[0] = generatev1(repo)
1935
1936 def runone_v2():
1937 # the lock is held for the duration the initialisation
1938 result_holder[0] = generatev2(repo, None, None, True)
1939
1940 if stream_version == b'latest':
1941 runone = runone_v2
1942 elif stream_version == b'v2':
1943 runone = runone_v2
1944 elif stream_version == b'v1':
1945 runone = runone_v1
1946 else:
1947 msg = b'unknown stream version: "%s"' % stream_version
1948 raise error.Abort(msg)
1949
1950 timer(runone, setup=setupone, title=b"load")
1951 fm.end()
1952
1953
1903 @command(b'perf::parents|perfparents', formatteropts) 1954 @command(b'perf::parents|perfparents', formatteropts)
1904 def perfparents(ui, repo, **opts): 1955 def perfparents(ui, repo, **opts):
1905 """benchmark the time necessary to fetch one changeset's parents. 1956 """benchmark the time necessary to fetch one changeset's parents.
1906 1957
1907 The fetch is done using the `node identifier`, traversing all object layers 1958 The fetch is done using the `node identifier`, traversing all object layers