tests/common-pattern.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Sat, 13 Apr 2024 23:40:28 +0200
changeset 51592 24844407fa0d
parent 51475 e3ed64dfd8ff
permissions -rw-r--r--
perf: clear vfs audit_cache before each run When generating a stream clone, we spend a large amount of time auditing path. Before this changes, the first run was warming the vfs cache for the other runs, leading to a large runtime difference and a "faulty" reported timing for the operation. We now clear this important cache between run to get a more realistic timing. Below are some example of median time change when clearing these cases. The maximum time for a run did not changed significantly. ### data-env-vars.name = mozilla-central-2018-08-01-zstd-sparse-revlog # benchmark.name = hg.perf.exchange.stream.generate # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default # benchmark.variants.version = latest no-clearing: 17.289905 cache-clearing: 21.587965 (+24.86%, +4.30) ## data-env-vars.name = mozilla-central-2024-03-22-zstd-sparse-revlog no-clearing: 32.670748 cache-clearing: 40.467095 (+23.86%, +7.80) ## data-env-vars.name = mozilla-try-2019-02-18-zstd-sparse-revlog no-clearing: 37.838858 cache-clearing: 46.072749 (+21.76%, +8.23) ## data-env-vars.name = mozilla-unified-2024-03-22-zstd-sparse-revlog no-clearing: 32.969395 cache-clearing: 39.646209 (+20.25%, +6.68) In addition, this significantly reduce the timing difference between the performance command, from the perf extensions and a `real `hg bundle` call producing a stream bundle. Some significant differences remain especially on the "mozilla-try" repositories, but they are now smaller. Note that some of that difference will actually not be attributable to the stream generation (like maybe phases or branch map computation). Below are some benchmarks done on a currently draft changeset fixing some unrelated slowness in `hg bundle` (34a78972af409d1ff37c29e60f6ca811ad1a457d) ### data-env-vars.name = mozilla-central-2018-08-01-zstd-sparse-revlog # bin-env-vars.hg.flavor = default # bin-env-vars.hg.py-re2-module = default hg.perf.exchange.stream.generate: 21.587965 hg.command.bundle: 24.301799 (+12.57%, +2.71) ## data-env-vars.name = mozilla-central-2024-03-22-zstd-sparse-revlog hg.perf.exchange.stream.generate: 40.467095 hg.command.bundle: 44.831317 (+10.78%, +4.36) ## data-env-vars.name = mozilla-unified-2024-03-22-zstd-sparse-revlog hg.perf.exchange.stream.generate: 39.646209 hg.command.bundle: 45.395258 (+14.50%, +5.75) ## data-env-vars.name = mozilla-try-2019-02-18-zstd-sparse-revlog hg.perf.exchange.stream.generate: 46.072749 hg.command.bundle: 55.882608 (+21.29%, +9.81) ## data-env-vars.name = mozilla-try-2023-03-22-zlib-general-delta hg.perf.exchange.stream.generate: 334.716708 hg.command.bundle: 377.856767 (+12.89%, +43.14) ## data-env-vars.name = mozilla-try-2023-03-22-zstd-sparse-revlog hg.perf.exchange.stream.generate: 302.972301 hg.command.bundle: 326.098755 (+7.63%, +23.13)

# common patterns in test at can safely be replaced

import os

substitutions = [
    # list of possible compressions
    (br'(zstd,)?zlib,none,bzip2', br'$USUAL_COMPRESSIONS$'),
    (br'=(zstd,)?zlib', br'=$BUNDLE2_COMPRESSIONS$'),
    # capabilities sent through http
    (
        br'bundlecaps=HG20%2Cbundle2%3DHG20%250A'
        br'bookmarks%250A'
        br'changegroup%253D01%252C02%252C03%250A'
        br'checkheads%253Drelated%250A'
        br'digests%253Dmd5%252Csha1%252Csha512%250A'
        br'error%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250A'
        br'hgtagsfnodes%250A'
        br'listkeys%250A'
        br'phases%253Dheads%250A'
        br'pushkey%250A'
        br'remote-changegroup%253Dhttp%252Chttps%250A'
        br'stream%253Dv2',
        # (the replacement patterns)
        br'$USUAL_BUNDLE_CAPS$',
    ),
    (
        br'bundlecaps=HG20%2Cbundle2%3DHG20%250A'
        br'bookmarks%250A'
        br'changegroup%253D01%252C02%252C03%250A'
        br'checkheads%3Drelated%0A'
        br'digests%253Dmd5%252Csha1%252Csha512%250A'
        br'error%253Dabort%252Cunsupportedcontent%252Cpushraced%252Cpushkey%250A'
        br'hgtagsfnodes%250A'
        br'listkeys%250A'
        br'phases%253Dheads%250A'
        br'pushkey%250A'
        br'remote-changegroup%253Dhttp%252Chttps',
        # (the replacement patterns)
        br'$USUAL_BUNDLE_CAPS_SERVER$',
    ),
    # bundle2 capabilities sent through ssh
    (
        br'bundle2=HG20%0A'
        br'bookmarks%0A'
        br'changegroup%3D01%2C02%2C03%0A'
        br'checkheads%3Drelated%0A'
        br'digests%3Dmd5%2Csha1%2Csha512%0A'
        br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A'
        br'hgtagsfnodes%0A'
        br'listkeys%0A'
        br'phases%3Dheads%0A'
        br'pushkey%0A'
        br'remote-changegroup%3Dhttp%2Chttps%0A'
        br'stream%3Dv2',
        # (replacement patterns)
        br'$USUAL_BUNDLE2_CAPS$',
    ),
    # bundle2 capabilities advertised by the server
    (
        br'bundle2=HG20%0A'
        br'bookmarks%0A'
        br'changegroup%3D01%2C02%2C03%0A'
        br'checkheads%3Drelated%0A'
        br'digests%3Dmd5%2Csha1%2Csha512%0A'
        br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A'
        br'hgtagsfnodes%0A'
        br'listkeys%0A'
        br'phases%3Dheads%0A'
        br'pushkey%0A'
        br'remote-changegroup%3Dhttp%2Chttps',
        # (replacement patterns)
        br'$USUAL_BUNDLE2_CAPS_SERVER$',
    ),
    (
        br'bundle2=HG20%0A'
        br'bookmarks%0A'
        br'changegroup%3D01%2C02%2C03%0A'
        br'digests%3Dmd5%2Csha1%2Csha512%0A'
        br'error%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0A'
        br'hgtagsfnodes%0A'
        br'listkeys%0A'
        br'pushkey%0A'
        br'remote-changegroup%3Dhttp%2Chttps%0A'
        br'stream%3Dv2',
        # (replacement patterns)
        br'$USUAL_BUNDLE2_CAPS_NO_PHASES$',
    ),
    # HTTP access log dates
    (
        br' - - \[\d\d/.../2\d\d\d \d\d:\d\d:\d\d] "(GET|PUT|POST)',
        lambda m: br' - - [$LOGDATE$] "' + m.group(1),
    ),
    # HTTP error log dates
    (
        br' - - \[\d\d/.../2\d\d\d \d\d:\d\d:\d\d] (HG error:|Exception)',
        lambda m: br' - - [$ERRDATE$] ' + m.group(1),
    ),
    # HTTP header dates- RFC 1123
    (
        br'([Dd]ate): [A-Za-z]{3}, \d\d [A-Za-z]{3} \d{4} \d\d:\d\d:\d\d GMT',
        lambda m: br'%s: $HTTP_DATE$' % m.group(1),
    ),
    # LFS expiration value
    (
        br'"expires_at": "\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ"',
        br'"expires_at": "$ISO_8601_DATE_TIME$"',
    ),
    # Windows has an extra '/' in the following lines that get globbed away:
    #   pushing to file:/*/$TESTTMP/r2 (glob)
    #   comparing with file:/*/$TESTTMP/r2 (glob)
    #   sub/maybelarge.dat: largefile 34..9c not available from
    #       file:/*/$TESTTMP/largefiles-repo (glob)
    (
        br'(.*file:/)/?(/\$TESTTMP.*)',
        lambda m: m.group(1) + b'*' + m.group(2) + b' (glob)',
    ),
    # `discovery debug output
    (
        br'\b(\d+) total queries in \d.\d\d\d\ds\b',
        lambda m: (br'%s total queries in *.????s (glob)' % m.group(1)),
    ),
    (
        br'\belapsed time:  \d+.\d{6} seconds\b',
        br'elapsed time:  *.?????? seconds (glob)',
    ),
]

# Various platform error strings, keyed on a common replacement string
_errors = {
    br'$ENOENT$': (
        # IOError in Python does not have the same error message
        # than in Rust, and automatic conversion is not possible
        # because of module member privacy.
        br'No such file or directory \(os error 2\)',
        # strerror()
        br'No such file or directory',
        # FormatMessage(ERROR_FILE_NOT_FOUND)
        br'The system cannot find the file specified',
    ),
    br'$EACCES$': (
        br'Permission denied \(os error 13\)',
        # strerror
        br'Permission denied',
    ),
    br'$ENOTDIR$': (
        # strerror()
        br'Not a directory',
        # FormatMessage(ERROR_PATH_NOT_FOUND)
        br'The system cannot find the path specified',
    ),
    br'$ECONNRESET$': (
        # strerror()
        br'Connection reset by peer',
        # FormatMessage(WSAECONNRESET)
        br'An existing connection was forcibly closed by the remote host',
    ),
    br'$EADDRINUSE$': (
        # strerror()
        br'Address already in use',
        # FormatMessage(WSAEADDRINUSE)
        br'Only one usage of each socket address'
        br' \(protocol/network address/port\) is normally permitted',
    ),
    br'$EADDRNOTAVAIL$': (
        # strerror()
        br'Cannot assign requested address',
        br'Can\'t assign requested address',
        # FormatMessage(WSAEADDRNOTAVAIL)
        br'The requested address is not valid in its context',
    ),
}

for replace, msgs in _errors.items():
    substitutions.extend((m, replace) for m in msgs)

# Output lines on Windows that can be autocorrected for '\' vs '/' path
# differences.
_winpathfixes = [
    # cloning subrepo s\ss from $TESTTMP/t/s/ss
    # cloning subrepo foo\bar from http://localhost:$HGPORT/foo/bar
    br'(?m)^cloning subrepo \S+\\.*',
    # pulling from $TESTTMP\issue1852a
    br'(?m)^pulling from \$TESTTMP\\.*',
    # pushing to $TESTTMP\a
    br'(?m)^pushing to \$TESTTMP\\.*',
    # pushing subrepo s\ss to $TESTTMP/t/s/ss
    br'(?m)^pushing subrepo \S+\\\S+ to.*',
    # moving d1\d11\a1 to d3/d11/a1
    br'(?m)^moving \S+\\.*',
    # d1\a: not recording move - dummy does not exist
    br'\S+\\\S+: not recording move .+',
    # reverting s\a
    br'(?m)^reverting (?!subrepo ).*\\.*',
    # saved backup bundle to
    #     $TESTTMP\test\.hg\strip-backup/443431ffac4f-2fc5398a-backup.hg
    br'(?m)^saved backup bundle to \$TESTTMP.*\.hg',
    # no changes made to subrepo s\ss since last push to ../tcc/s/ss
    br'(?m)^no changes made to subrepo \S+\\\S+ since.*',
    # changeset 5:9cc5aa7204f0: stuff/maybelarge.dat references missing
    #     $TESTTMP\largefiles-repo-hg\.hg\largefiles\76..38
    br'(?m)^changeset .* references (corrupted|missing) \$TESTTMP\\.*',
    # stuff/maybelarge.dat: largefile 76..38 not available from
    #     file:/*/$TESTTMP\largefiles-repo (glob)
    br'.*: largefile \S+ not available from file:/\*/.+',
]

if os.name == 'nt':
    substitutions.extend(
        [
            (s, lambda match: match.group().replace(b'\\', b'/'))
            for s in _winpathfixes
        ]
    )