git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 00/39] per-repository object store, part 1

From
BWBrandon Williams <bmwill@google.com>
Date
Aug 30, 2017, 23:07 UTC
Message-ID
<20170830230755.GF50018@google.com>
In-Reply-To
<20170830064634.GA153983@aiede.mtv.corp.google.com>
On 08/29, Jonathan Nieder wrote:
Show 75 quoted lines
> Hi,
> 
> Most of the credit for this series should go to Stefan Beller.  I just
> decided to pull the trigger on sending out what we have so far.
> 
> This series is about API.  It makes no functional change yet.
> 
> Today, when a git command wants to operate on some objects from another
> repository (e.g., a submodule), it has two choices:
> 
>  A. Use run_command to operate on that repository in a separate process.
> 
>  B. Use add_to_alternates_memory to pretend the repository is an
>     alternate.  This has a number of downsides.  Aside from aesthetics,
>     one particularly painful consequence is that as alternates
>     accumulate, the number of packs git has to check for objects
>     increases, which can cause significant slowdowns.
> 
> Brandon Williams's recent work to introduce "struct repository" points
> to a better way.  Encapsulating object access in struct repository
> would mean:
> 
>   i. The API for accessing objects in another repository becomes more
>      simple and familiar (instead of using the CLI or abusing alternates).
> 
>   ii. Operations on one repository do not interfere with another,
>       neither in semantics (e.g. replace objects do not work correctly
>       with the approach (B) above) nor performance (already described
>       above).
> 
>  iii. Resources associated with access to a repository could be freed
>       when done with that repo.
> 
>   iv. Thread-safe multiple readers to a single repository also become
>       straightforward, by using multiple repository objects for the same
>       repo.
> 
> This series is a small step in that direction.
> 
> At the end of this series, sha1_loose_object_info takes a repository
> argument and can be independently called for multiple repositories.
> Not incredibly useful on its own, but a future series will do the same
> for sha1_object_info, which will be enough to migrate a caller in
> submodule.c (which uses the object store for commit existence checks).
> 
> This series has a few phases:
> 
>  1. Patch 1 is a cleanup that made some of the later patches easier.
> 
>  2. Patches 2-6 create a struct object_store field inside struct
>     repository and move some globals to it.
> 
>  3. Patches 7-24 are mechanical changes that update some functions to
>     accept a repository argument. The only goal is to make the later
>     patches that teach these functions to actual handle a repository
>     other than the_repository easier to review.  The patches enforce
>     at compile time that no caller passes a repository other than
>     the_repository --- see patch 7 in particular for details on how
>     that works.
> 
>  4. Patches 25-39 update the implementations of those functions to
>     handle a repository other than the_repository.  This means the
>     safety check introduced in phase 3 goes away completely --- all
>     functions that gained a repository argument are safe to use with
>     a repository argument other than the_repository.
> 
> Patches 2-6 and 25-39 should be the most interesting to review.  I'd
> particularly appreciate if people can look over 25-39 carefully.  We
> were careful not to leave any calls to functions that assume they are
> operating on the_repository, but a triple-check is always welcome.
> 
> Thanks as well to brian m. carlson, who showed us how such a long and
> potentially tedius series can be made bearable for reviewers.
> 
> Thoughts of all kinds welcome, as always.

Just finished looking through the series. Thanks for keeping each commit very short and to the point, it made reviewing it much easier. I couldn't see anything wrong these transformations and I am very happy to see this work getting done.

One thing that needs to be noted is that currently the object_store is only really being used by the_repository so this series didn't need to create any object_store_init() or object_store_clear() type functions. So these types of functions will need to be added once submodules are using their own object store, in their own struct repository.

Show 86 quoted lines
> 
> Thanks,
> Jonathan Nieder (24):
>   pack: make packed_git_mru global a value instead of a pointer
>   object-store: move packed_git and packed_git_mru to object store
>     struct
>   pack: move prepare_packed_git_run_once to object store struct
>   pack: move approximate object count to object store struct
>   pack: add repository argument to install_packed_git
>   pack: add repository argument to prepare_packed_git_one
>   pack: add repository argument to rearrange_packed_git
>   pack: add repository argument to prepare_packed_git_mru
>   pack: add repository argument to prepare_packed_git
>   pack: add repository argument to reprepare_packed_git
>   pack: add repository argument to sha1_file_name
>   pack: add repository argument to map_sha1_file
>   pack: allow install_packed_git to handle arbitrary repositories
>   pack: allow rearrange_packed_git to handle arbitrary repositories
>   pack: allow prepare_packed_git_mru to handle arbitrary repositories
>   pack: allow prepare_packed_git_one to handle arbitrary repositories
>   pack: allow prepare_packed_git to handle arbitrary repositories
>   pack: allow reprepare_packed_git to handle arbitrary repositories
>   pack: allow sha1_file_name to handle arbitrary repositories
>   pack: allow stat_sha1_file to handle arbitrary repositories
>   pack: allow open_sha1_file to handle arbitrary repositories
>   pack: allow map_sha1_file_1 to handle arbitrary repositories
>   pack: allow map_sha1_file to handle arbitrary repositories
>   pack: allow sha1_loose_object_info to handle arbitrary repositories
> 
> Stefan Beller (15):
>   repository: introduce object store field
>   object-store: move alt_odb_list and alt_odb_tail to object store
>     struct
>   sha1_file: add repository argument to alt_odb_usable
>   sha1_file: add repository argument to link_alt_odb_entry
>   sha1_file: add repository argument to read_info_alternates
>   sha1_file: add repository argument to link_alt_odb_entries
>   sha1_file: add repository argument to stat_sha1_file
>   sha1_file: add repository argument to open_sha1_file
>   sha1_file: add repository argument to map_sha1_file_1
>   sha1_file: add repository argument to sha1_loose_object_info
>   object-store: add repository argument to prepare_alt_odb
>   object-store: add repository argument to foreach_alt_odb
>   sha1_file: allow alt_odb_usable to handle arbitrary repositories
>   object-store: allow prepare_alt_odb to handle arbitrary repositories
>   object-store: allow foreach_alt_odb to handle arbitrary repositories
> 
>  builtin/count-objects.c             |  10 ++-
>  builtin/fsck.c                      |  15 ++--
>  builtin/gc.c                        |   8 +-
>  builtin/index-pack.c                |   1 +
>  builtin/pack-objects.c              |  23 +++--
>  builtin/pack-redundant.c            |   8 +-
>  builtin/receive-pack.c              |   4 +-
>  builtin/submodule--helper.c         |   4 +-
>  bulk-checkin.c                      |   3 +-
>  cache.h                             |  50 ++---------
>  contrib/coccinelle/packed_git.cocci |  15 ++++
>  fast-import.c                       |  10 ++-
>  fetch-pack.c                        |   3 +-
>  http-backend.c                      |   8 +-
>  http-push.c                         |   1 +
>  http-walker.c                       |   4 +-
>  http.c                              |   9 +-
>  mru.h                               |   1 +
>  object-store.h                      |  71 ++++++++++++++++
>  pack-bitmap.c                       |   6 +-
>  pack-check.c                        |   1 +
>  pack-revindex.c                     |   1 +
>  packfile.c                          |  94 ++++++++++----------
>  packfile.h                          |   6 +-
>  reachable.c                         |   1 +
>  repository.c                        |   4 +-
>  repository.h                        |   7 ++
>  server-info.c                       |   8 +-
>  sha1_file.c                         | 165 ++++++++++++++++++++----------------
>  sha1_name.c                         |  11 ++-
>  streaming.c                         |   5 +-
>  transport.c                         |   4 +-
>  32 files changed, 344 insertions(+), 217 deletions(-)
>  create mode 100644 contrib/coccinelle/packed_git.cocci
>  create mode 100644 object-store.h
> 
> -- 
> 2.14.1.581.gf28d330327
> 
-- 
Brandon Williams
Previous: Jonathan Nieder
Message 46 of 46 in “per-repository object store, part 1”
  1. 00/39 per-repository object store, part 1Jonathan Nieder, Aug 30, 2017
  2. 01/39 pack: make packed_git_mru global a value instead of a pointerJonathan Nieder, Aug 30, 2017
  3. Jeff KingAug 30, 2017
  4. Junio C HamanoSep 6, 2017
  5. 02/39 repository: introduce object store fieldJonathan Nieder, Aug 30, 2017
  6. 03/39 object-store: move alt_odb_list and alt_odb_tail to object storeJonathan Nieder, Aug 30, 2017
  7. 04/39 object-store: move packed_git and packed_git_mru to object storeJonathan Nieder, Aug 30, 2017
  8. 05/39 pack: move prepare_packed_git_run_once to object storeJonathan Nieder, Aug 30, 2017
  9. 06/39 pack: move approximate object count to object storeJonathan Nieder, Aug 30, 2017
  10. 07/39 sha1_file: add repository argument to alt_odb_usableJonathan Nieder, Aug 30, 2017
  11. Brandon WilliamsAug 30, 2017
  12. 08/39 sha1_file: add repository argument to link_alt_odb_entryJonathan Nieder, Aug 30, 2017
  13. 09/39 sha1_file: add repository argument to read_info_alternatesJonathan Nieder, Aug 30, 2017
  14. 10/39 sha1_file: add repository argument to link_alt_odb_entriesJonathan Nieder, Aug 30, 2017
  15. 11/39 sha1_file: add repository argument to stat_sha1_fileJonathan Nieder, Aug 30, 2017
  16. 12/39 sha1_file: add repository argument to open_sha1_fileJonathan Nieder, Aug 30, 2017
  17. 13/39 sha1_file: add repository argument to map_sha1_file_1Jonathan Nieder, Aug 30, 2017
  18. 14/39 sha1_file: add repository argument to sha1_loose_object_infoJonathan Nieder, Aug 30, 2017
  19. 15/39 object-store: add repository argument to prepare_alt_odbJonathan Nieder, Aug 30, 2017
  20. 16/39 object-store: add repository argument to foreach_alt_odbJonathan Nieder, Aug 30, 2017
  21. 17/39 pack: add repository argument to install_packed_gitJonathan Nieder, Aug 30, 2017
  22. 18/39 pack: add repository argument to prepare_packed_git_oneJonathan Nieder, Aug 30, 2017
  23. 19/39 pack: add repository argument to rearrange_packed_gitJonathan Nieder, Aug 30, 2017
  24. 20/39 pack: add repository argument to prepare_packed_git_mruJonathan Nieder, Aug 30, 2017
  25. 21/39 pack: add repository argument to prepare_packed_gitJonathan Nieder, Aug 30, 2017
  26. 22/39 pack: add repository argument to reprepare_packed_gitJonathan Nieder, Aug 30, 2017
  27. 23/39 pack: add repository argument to sha1_file_nameJonathan Nieder, Aug 30, 2017
  28. 24/39 pack: add repository argument to map_sha1_fileJonathan Nieder, Aug 30, 2017
  29. 25/39 sha1_file: allow alt_odb_usable to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  30. Junio C HamanoSep 6, 2017
  31. Stefan BellerSep 6, 2017
  32. 26/39 object-store: allow prepare_alt_odb to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  33. 27/39 object-store: allow foreach_alt_odb to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  34. 28/39 pack: allow install_packed_git to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  35. 29/39 pack: allow rearrange_packed_git to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  36. 30/39 pack: allow prepare_packed_git_mru to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  37. 31/39 pack: allow prepare_packed_git_one to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  38. 32/39 pack: allow prepare_packed_git to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  39. 33/39 pack: allow reprepare_packed_git to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  40. 34/39 pack: allow sha1_file_name to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  41. 35/39 pack: allow stat_sha1_file to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  42. 36/39 pack: allow open_sha1_file to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  43. 37/39 pack: allow map_sha1_file_1 to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  44. 38/39 pack: allow map_sha1_file to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  45. 39/39 pack: allow sha1_loose_object_info to handle arbitrary repositoriesJonathan Nieder, Aug 30, 2017
  46. Brandon WilliamsAug 30, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.