Re: [PATCH v3] packed_ref_cache: don't use mmap() for small files
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 24, 2018, 18:05 UTC
- Message-ID
- <xmqq607rf7y1.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <cea5e366-dc95-6f41-6373-f8bbef103561@alum.mit.edu>
Michael Haggerty <mhagger@alum.mit.edu> writes:
Show 12 quoted lines
> The change to using `read()` rather than `mmap()` for small > `packed-refs` feels like it should be an improvement, but it occurred to > me that the performance numbers quoted in ea68b0ce9f8 (hash-object: > don't use mmap() for small files, 2010-02-21) are not directly > applicable to the `packed-refs` file. As far as I understand, the file > mmapped in `index_fd()` is always read in full, whereas the main point > of mmapping the packed-refs file is to avoid having to read the whole > file at all in some situations. That being said, a 32 KiB file would > only be 8 pages (assuming a page size of 4 KiB), and by the time you've > read the header and binary-searched to find the desired record, you've > probably paged in most of the file anyway. Reading the whole file at > once, in order, is almost certainly cheaper.
Yup. So unless your "small" is meaningfully large, we are likely to be better off with read(2), but I suspect that this might not be even measuable since we are only talking about "small" files.