Re: [PATCH 00/20] Read `packed-refs` using mmap()
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Sep 14, 2017, 22:16 UTC
- Message-ID
- <alpine.DEB.2.21.1.1709150012550.219280@virtualbox>
- In-Reply-To
- <ef919cc7-7e41-afb6-38b2-e2fae4efcbf1@alum.mit.edu>
Hi Michael,
On Thu, 14 Sep 2017, Michael Haggerty wrote:
Show 8 quoted lines
> On 09/13/2017 07:15 PM, Michael Haggerty wrote: > > [...] > > * `mmap()` the whole file rather than `read()`ing it. > > [...] > > Apparently this doesn't work on Windows, because the `snapshot` is > keeping the `packed-refs` file open too long, so the new file can't be > renamed on top of it.
Indeed, I sent you a mail about it before I checked for new mails ;-)
> I didn't realize that this is even allowed, but TIL that you can close a > file while keeping it mmapped. Does that technique work on Windows? If > so, I'll change v2 to do it as sketched below.
I do not know whether that technique works on Windows, but it would not solve the problem *entirely*, as I outlined in my reply: in delete_branches(), for example, the main_worktree_ref_store is implicitly getting its snapshot initialized, and nothing seems to release it.
This is only one example, as I figure that multiple worktrees could cause even more ref_stores to have unreleased snapshots of the packed-refs file.
I imagine that something like close_all_packs() is needed ("clear_all_snapshots()"?).
Ciao, Dscho