Mercurial > public > mercurial-scm > hg-stable
changeset 52940:7fc882f7fada
stream-clone-v2: disable buffering when writing the files
Not going through python's buffer while writing chunk is not only faster, but it
reduce the amount of operation that are needed under the GIL, increasing the
benefit from the threads.
### benchmark.name = hg.perf.exchange.stream.consume
# bin-env-vars.hg.flavor = default
# bin-env-vars.hg.py-re2-module = default
# benchmark.variants.memory-target = default
# benchmark.variants.num-writer = default
# benchmark.variants.parallel-processing = yes
# benchmark.variants.progress = no
# benchmark.variants.read-from-memory = yes
# benchmark.variants.version = v2
## data-env-vars.name = mercurial-public-2024-03-22-zstd-sparse-revlog
prev-change: 0.233780 ~~~~~
this-change: 0.217293 (-7.05%, -0.02)
## data-env-vars.name = netbeans-2019-11-07-zstd-sparse-revlog
prev-change: 11.754377 ~~~~~
this-change: 11.222771 (-4.52%, -0.53)
## data-env-vars.name = netbsd-xsrc-all-2024-09-19-zstd-sparse-revlog
prev-change: 4.735520 ~~~~~
this-change: 4.465113 (-5.71%, -0.27)
## data-env-vars.name = netbsd-xsrc-draft-2024-09-19-zstd-sparse-revlog
prev-change: 4.728870 ~~~~~
this-change: 4.667360 (-1.30%, -0.06)
## data-env-vars.name = pypy-2024-03-22-zstd-sparse-revlog
prev-change: 2.783987 ~~~~~
this-change: 2.559670 (-8.06%, -0.22)
## data-env-vars.name = heptapod-public-2024-03-25-zstd-sparse-revlog
prev-change: 6.532561 ~~~~~
this-change: 6.123469 (-6.26%, -0.41)
## data-env-vars.name = mozilla-central-2024-03-22-zstd-sparse-revlog
prev-change: 47.154728 ~~~~~
this-change: 44.781498 (-5.03%, -2.37)
## data-env-vars.name = mozilla-unified-2024-03-22-zstd-sparse-revlog
prev-change: 47.166569 ~~~~~
this-change: 44.396959 (-5.87%, -2.77)
## data-env-vars.name = mozilla-try-2024-03-26-zstd-sparse-revlog
# benchmark.variants.read-from-memory = no
prev-change: 113.696529 ~~~~~
this-change: 108.552706 (-4.52%, -5.14)
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 20 Jan 2025 12:41:20 +0100 |
parents | b6f24a92b399 |
children | 5b8f6e198a6e |
files | mercurial/streamclone.py |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/streamclone.py Sat Nov 30 02:24:22 2024 +0100 +++ b/mercurial/streamclone.py Mon Jan 20 12:41:20 2025 +0100 @@ -1541,9 +1541,16 @@ """write files from parsed data""" for src, name, data in info: vfs = vfsmap[src] - with vfs(name, b'w') as ofp: + # we disable the internal Python buffering because the streamed data + # are assume to have been written with large enough block for it to not + # matters. So we only have more memory copy and GIL holding time to + # gain with the Python buffering. + with vfs(name, b'w', buffering=0) as ofp: for chunk in data: - ofp.write(chunk) + written = ofp.write(chunk) + # write missing pieces if the write was interrupted + while written < len(chunk): + written += ofp.write(chunk[written:]) def consumev3(repo, fp) -> None: