comparison mercurial/streamclone.py @ 52928: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 34fa51c25112
children 5b8f6e198a6e
comparison
equal deleted inserted replaced
52927:b6f24a92b399 52928:7fc882f7fada
1539 1539
1540 def _write_files(vfsmap, info: Iterable[FileInfoT]): 1540 def _write_files(vfsmap, info: Iterable[FileInfoT]):
1541 """write files from parsed data""" 1541 """write files from parsed data"""
1542 for src, name, data in info: 1542 for src, name, data in info:
1543 vfs = vfsmap[src] 1543 vfs = vfsmap[src]
1544 with vfs(name, b'w') as ofp: 1544 # we disable the internal Python buffering because the streamed data
1545 # are assume to have been written with large enough block for it to not
1546 # matters. So we only have more memory copy and GIL holding time to
1547 # gain with the Python buffering.
1548 with vfs(name, b'w', buffering=0) as ofp:
1545 for chunk in data: 1549 for chunk in data:
1546 ofp.write(chunk) 1550 written = ofp.write(chunk)
1551 # write missing pieces if the write was interrupted
1552 while written < len(chunk):
1553 written += ofp.write(chunk[written:])
1547 1554
1548 1555
1549 def consumev3(repo, fp) -> None: 1556 def consumev3(repo, fp) -> None:
1550 """Apply the contents from a version 3 streaming clone. 1557 """Apply the contents from a version 3 streaming clone.
1551 1558