Mercurial > hg
changeset 51653:d6c895e4adc4 stable
mmap: only use mmap to read revlog index if it is safe
Cf `is_mmap_safe` docstring.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 03 Jul 2024 12:26:57 +0200 |
parents | ba205f944cb4 |
children | c0e30a019ce1 |
files | mercurial/revlog.py tests/test-revlog-mmapindex.t |
diffstat | 2 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlog.py Wed Jul 03 12:22:48 2024 +0200 +++ b/mercurial/revlog.py Wed Jul 03 12:26:57 2024 +0200 @@ -1460,7 +1460,10 @@ with self.opener(filepath) as fp: if mmap_threshold is not None: file_size = self.opener.fstat(fp).st_size - if file_size >= mmap_threshold: + if ( + file_size >= mmap_threshold + and self.opener.is_mmap_safe(filepath) + ): if size is not None: # avoid potentiel mmap crash size = min(file_size, size)
--- a/tests/test-revlog-mmapindex.t Wed Jul 03 12:22:48 2024 +0200 +++ b/tests/test-revlog-mmapindex.t Wed Jul 03 12:26:57 2024 +0200 @@ -37,7 +37,7 @@ mmap index which is now more than 4k long $ hg log -l 5 -T '{rev}\n' --config experimental.mmapindexthreshold=4k - mmapping $TESTTMP/a/.hg/store/00changelog.i + mmapping $TESTTMP/a/.hg/store/00changelog.i (no-pure !) mmapping $TESTTMP/a/.hg/store/00changelog-????????.nd (glob) (rust !) 100 99