[PATCH 3 of 3] revlog: read index data using mmap
Jun Wu
quark at fb.com
Wed Oct 5 17:59:15 EDT 2016
Excerpts from Yuya Nishihara's message of 2016-10-05 19:50:33 +0900:
> On Tue, 4 Oct 2016 15:59:45 +0100, Jun Wu wrote:
> > # HG changeset patch
> > # User Jun Wu <quark at fb.com>
> > # Date 1475550701 -3600
> > # Tue Oct 04 04:11:41 2016 +0100
> > # Node ID 99e7b0589b916b83d825882e907dd79082f4a2d7
> > # Parent 5ebdfd4ffbedbfe66b7a36cbd06b1e8e624ae7ad
> > # Available At https://bitbucket.org/quark-zju/hg-draft
> > # hg pull https://bitbucket.org/quark-zju/hg-draft -r 99e7b0589b91
> > revlog: read index data using mmap
>
> What happens if revlog is stripped? Using mmap would introduce more error
> modes we'll need to test.
If revlog is truncated, I think we will have trouble without mmap, too - the
pre-truncated index was loaded into memory while the revlog date can be
truncated. Reading data of a truncated revision would cause an error. But
the error is catchable.
Possible solutions I can think of are:
- Change strip to copy the changelog index and rename it, instead of
truncating the original file directly. Seems like a reasonable solution
to me.
- Turn off mmap by default but gate it with a config option.
> FWIW, I know Python crashes if mmapped file is truncated to be empty.
>
> with open('foo', 'wb') as fp:
> fp.write('a')
> fp = open('foo', 'rb')
> s = mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ)
> with open('foo', 'wb') as fp2:
> pass # truncate
> print(s[0])
More information about the Mercurial-devel
mailing list