Replies: 2 comments 2 replies
-
This probably warrants a bit more thought, but here's an initial response: So the good news is that if you go sufficiently lower down in the stack packing will be thread safe. The code you provide is thread safe I believe, with two caveats: Assuming that there is no overlap in objects that you want to pack (since otherwise one thread could call remove_loose_object for objects that another wants to call get_loose_object for). You can address this by calling object_store[sha] so that if the object has already been packed you retrieve the object from either the loose object or the pack. Creating packs in parallel this way might also not be the most efficient way to do things, especially if you're creating loose objects that mirror objects already in packs. |
Beta Was this translation helpful? Give feedback.
-
You can see the basics of it in I plan on applying a bit further clean-ups, in particular so that logging and progress are fully abstracted so that it only happens on the main thread. And probably use I deliberately elected to use a regular interval of commits for packing, combined with a final “clean up”, as counting loose objects seems relatively slow in Dulwich. Ideally, it'd do some of the black magic in EDIT: Issue #92 is relevant to this. |
Beta Was this translation helpful? Give feedback.
-
I'd like to add support for packing loose objects to
hg-git
. At the moment, all objects are written as loose objects when converting a Mercurial repository to Git, leading to excessively large and fragmented repositories.Instead, I'd like to write the objects as packs so that they are compressed somewhat. The simplest solution is to write a single commit as a pack, but that has two downsides:
Instead, I'd like to repack the repository while actually converting it. This appears to work well in practice, and the compression appears to allow use of multiple cores, but I wonder if its actually safe? Is there some reason that packing some objects while adding other objects to the repository wouldn't work?
In particular I intend to do something like this from multiple threads:
Do you think that would be safe to invoke from multiple threads concurrently? Do you think it would conflict with the general conversion happening in another thread?
Beta Was this translation helpful? Give feedback.
All reactions