diff -r 7f848cfc4286 -r 58baa86c7a02 mercurial/streamclone.py --- a/mercurial/streamclone.py Mon Jan 20 15:13:30 2025 +0100 +++ b/mercurial/streamclone.py Mon Jan 27 19:15:39 2025 +0100 @@ -44,6 +44,16 @@ ) +# Number arbitrarily picked, feel free to change them (but the LOW one) +# +# update the configuration documentation if you touch this. +DEFAULT_NUM_WRITER = { + scmutil.RESOURCE_LOW: 1, + scmutil.RESOURCE_MEDIUM: 2, + scmutil.RESOURCE_HIGH: 4, +} + + def new_stream_clone_requirements( default_requirements: Iterable[bytes], streamed_requirements: Iterable[bytes], @@ -1103,6 +1113,7 @@ 'repo.vfs must not be added to vfsmap for security reasons' ) + cpu_profile = scmutil.get_resource_profile(repo.ui, b'cpu') threaded = repo.ui.configbool( b"worker", b"parallel-stream-bundle-processing" ) @@ -1110,6 +1121,8 @@ b"worker", b"parallel-stream-bundle-processing.num-writer", ) + if num_writer <= 0: + num_writer = DEFAULT_NUM_WRITER[cpu_profile] with repo.transaction(b'clone'): ctxs = (vfs.backgroundclosing(repo.ui) for vfs in vfsmap.values()) with nested(*ctxs):