diff mercurial/vfs.py @ 52930:22e264ac7f60

stream-clone-v2: bypass the vfs to write the file on disk Now that all preparation is done in the main thread, we no longer need the vfs to be involved at the writing end. This very significantly speeds things up. ### 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.217293 ~~~~~ this-change: 0.154647 (-28.83%, -0.06) ## data-env-vars.name = netbeans-2019-11-07-zstd-sparse-revlog prev-change: 11.222771 ~~~~~ this-change: 7.843554 (-30.11%, -3.38) ## data-env-vars.name = netbsd-xsrc-all-2024-09-19-zstd-sparse-revlog prev-change: 4.465113 ~~~~~ this-change: 3.040664 (-31.90%, -1.42) ## data-env-vars.name = netbsd-xsrc-draft-2024-09-19-zstd-sparse-revlog prev-change: 4.667360 ~~~~~ this-change: 3.070976 (-34.20%, -1.60) ## data-env-vars.name = pypy-2024-03-22-zstd-sparse-revlog prev-change: 2.559670 ~~~~~ this-change: 1.832118 (-28.42%, -0.73) ## data-env-vars.name = heptapod-public-2024-03-25-zstd-sparse-revlog prev-change: 6.123469 ~~~~~ this-change: 4.478754 (-26.86%, -1.64) ## data-env-vars.name = mozilla-central-2024-03-22-zstd-sparse-revlog prev-change: 44.781498 ~~~~~ this-change: 30.349379 (-32.23%, -14.43) ## data-env-vars.name = mozilla-unified-2024-03-22-zstd-sparse-revlog prev-change: 44.396959 ~~~~~ this-change: 31.179906 (-29.77%, -13.22) ## data-env-vars.name = mozilla-try-2024-03-26-zstd-sparse-revlog # benchmark.variants.read-from-memory = no prev-change: 108.552706 ~~~~~ this-change: 91.454508 (-15.75%, -17.10)
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 29 Jan 2025 02:23:02 +0100
parents 5b8f6e198a6e
children 46603c00a9f2
line wrap: on
line diff
--- a/mercurial/vfs.py	Wed Jan 29 02:17:33 2025 +0100
+++ b/mercurial/vfs.py	Wed Jan 29 02:23:02 2025 +0100
@@ -90,6 +90,8 @@
     # createmode is always available on subclasses
     createmode: int
 
+    _chmod: bool
+
     # TODO: type return, which is util.posixfile wrapped by a proxy
     @abc.abstractmethod
     def __call__(self, path: bytes, mode: bytes = b'rb', **kwargs) -> Any:
@@ -462,12 +464,17 @@
 
     def prepare_streamed_file(
         self, path: bytes, known_directories: Set[bytes]
-    ) -> None:
+    ) -> Tuple[bytes, Optional[int]]:
         """make sure we are ready to write a file from a stream clone
 
         The "known_directories" variable is here to avoid trying to create the
         same directories over and over during a stream clone. It will be
         updated by this function.
+
+        return (path, mode)::
+
+            <path> is the real file system path content should be written to,
+            <mode> is the file mode that need to be set if any.
         """
         self._auditpath(path, b'wb')
         self.register_file(path)
@@ -476,6 +483,10 @@
         if dirname not in known_directories:
             util.makedirs(dirname, self.createmode, True)
             known_directories.add(dirname)
+        mode = None
+        if self.createmode is not None:
+            mode = self.createmode & 0o666
+        return real_path, mode
 
 
 class vfs(abstractvfs):