Mercurial > hg
view tests/list-tree.py @ 49622:dcb2581e33be stable
memory-usage: fix `hg log --follow --rev R F` space complexity
When running `hg log --follow --rev REVS FILES`, the log code will walk the
history of all FILES starting from the file revisions that exists in each REVS.
Before doing so, it looks if the files actually exists in the target revisions.
To do so, it opens the manifest of each revision in REVS to look up if we find
the associated items in FILES.
Before this changeset this was done in a way that created a changectx for
each target revision, keeping them in memory while we look into each file.
If the set of REVS is large, this means keeping the manifest for each entry in
REVS in memory. That can be largeā¦ if REV is in the form `::X`, this can quickly
become huge and saturate the memory. We have seen usage allocating 2GB per
second until memory runs out.
So this changeset invert the two loop so that only one revision is kept in
memory during the operation. This solve the memory explosion issue.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 19 Nov 2022 01:35:01 +0100 |
parents | 6000f5b25c9b |
children |
line wrap: on
line source
import argparse import os ap = argparse.ArgumentParser() ap.add_argument('path', nargs='+') opts = ap.parse_args() def gather(): for p in opts.path: if not os.path.exists(p): return if os.path.isdir(p): yield p + os.path.sep for dirpath, dirs, files in os.walk(p): for d in dirs: yield os.path.join(dirpath, d) + os.path.sep for f in files: yield os.path.join(dirpath, f) else: yield p print('\n'.join(sorted(gather(), key=lambda x: x.replace(os.path.sep, '/'))))