Re: [PATCH] odb/files: be less aggressive with geometric repacking
Justin Tobler <[email protected]>
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <anuFzZluJEU21MB0@denethor> |
On 26/08/11 11:04AM, Patrick Steinhardt wrote: > When performing auto-maintenance with geometric repacking we have two > conditions that may trigger a repack: > > - Either the geometric sequence of packfiles is invalidated. > > - Or we have too many loose objects. > > The first condition shouldn't trigger all that often: it may be hit when > we fetch a new packfile, but users tend to not do that all the time. The > second condition is what typically triggers more regularly though, as > every command that ends up writing new objects may cause us to cross the > threshold of loose objects. It is thus preferable to not be too > aggressive here, as otherwise we may end up repacking objects quite > often. > > For the geometric-repacking strategy though we have a default of 100 > objects, only. As we're approximating the count of objects by only > reading the "objects/17/" shared, we'd only need 2 objects in there > before we perform a repack by default, which is quite aggressive. > git-gc(1) on the other hand has a default of 6700, so it is quite a bit > more conservative here. Ok IIUC, the reason two loose objects can potentially trigger repacking is because the heuristic used to estimate the number of loose objects only counts objects in "objects/17/" and multiples it by 256 (the maximum number of directories that are fanned-out). That makes sense and indeed seems like it could lead to repacking processes be spawned more frequently than desired. My first thought is whether the heuristic itself should be updated to capture a more accurate estimate for the number of objects. That would of course require looking up more objects and thus be more expensive. If the goal here is just for a very rough estimate anyways, maybe it wouldn't be worth it though. Increasing the loose object threshold here to be more conservative seems like a reasonable approach. I'm not sure exactly why 6700 was chosen here. 6700 / 256 ~= 26.2 which means "objects/17/" would have to contain at least 27 objects before repacking is triggered. That is certainly much more conservative. I see that 6700 has also been chosen else where in the codebase as the threshold too. It might be nice to explain the reasoning a bit more in the commit message though. > Being this aggressive is also causing problems as reported by our users. > When running lots of concurrent writers, those writes will constantly > end up spawning maintenance jobs that end up repacking objects. As we > also prune objects, a concurrently running process that tries to write > an object may see that the sharding directories get removed under their > feet. While we try re-creating such leading directories, we only do so a > single time, and it may happen that the directory vanishes again before > we had the chance to create the loose object. This is not a new problem, > but it is exacerbated by us running maintenance this aggressively. > > Improve the status quo by reducing the frequency at which we pack loose > objects to the same frequency that git-gc(1) uses. Makes sense and the patch itself looks trivially correct. -Justin