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

Re: [PATCH 03/16] refs: add methods for the ref iterators

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Jan 5, 2016, 13:43 UTC
Message-ID
<568BC88C.6000703@alum.mit.edu>
In-Reply-To
<xmqqziwlnp7d.fsf@gitster.mtv.corp.google.com>
On 01/04/2016 08:01 PM, Junio C Hamano wrote:
Show 24 quoted lines
> David Aguilar <davvid@gmail.com> writes:
> [...]
>> My only comment is that it seems like having a single static global
>> the_refs_backend seems like it should be avoided.
>> [...]
> 
> I think the ship is sailing in a different direction.  The API to
> deal with refs, possibly in multiple repositories, is that you use a
> single ref backend, and that backend is expected to handle refs in
> submodule repositories.  I.e. refs.c::for_each_ref_in_submodule()
> calls into the backend implementation of the same method.  So from
> that point of view, you cannot say "the top level repository uses
> LMDB backend but this and that submodule refs are looked up by
> consulting files backend".
> 
> If we want to go the opposite direction, so that we can keep more
> than one in-core representations of "repository" (what you called
> "application context") and optionally have different refs backend
> handling different repositories, we most likely would want to
> rethink the part of the refs API that special cases the submodule
> refs from within the current repository.  Their implementation
> should be excised from the API set, and instead made to be a set
> of thin wrapper functions that explicitly refer to a repository
> instance that represents the submodule.

I definitely think that the "one and only one refs backend per process" model is not a good long-term approach. For example, submodules are relatively independent but are nevertheless sometimes accessed from a single process. I don't think insisting that they all use the same references backend is tenable over the long term.

But I haven't insisted on this flexibility yet because I don't think it will be much extra work in total to retrofit it later. What we mostly want to avoid is the need to rewrite all call sites more than once. The current patch series hasn't had to rewrite callers at all, so we still have a rewrite in reserve :-)

Actually, maybe we will never have to rewrite all callers. I rather think that we will retain one simplified API for dealing with "*this* repository's references" and a second for dealing with other repos' refs.

By the way, I think the next step towards the ability to work with multiple backends at the same time would be to store a pointer to the refs backend inside the ref_cache instance (possibly renaming the latter) and allowing them both to be looked up by submodule name as is already done by get_ref_cache(). I think this change could also be done without rewriting callers.

Show 5 quoted lines
> [...]
> The caching of already read refs is a responsiblity of each ref
> backend in the current codebase.  I am not sure if that is a good
> placement, or a single implementation of the caching layer should
> instead sit on top of any and ll ref backends.

I still dream about having compoundable reference backends, in which case, ultimately, a "CacheReferenceStore" instance would optionally wrap on top of an arbitrary other "ReferenceStore" instance (so to speak) to give it caching functionality.

Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
Previous: Junio C HamanoNext: Junio C Hamano
Message 15 of 73 in “LMDB refs backend atop pre-vtable”
  1. 00/16 LMDB refs backend atop pre-vtableDavid Turner, Dec 3, 2015
  2. 01/16 refs: add a backend method structure with transaction functionsDavid Turner, Dec 3, 2015
  3. Junio C HamanoDec 5, 2015
  4. 02/16 refs: add methods for misc ref operationsDavid Turner, Dec 3, 2015
  5. Junio C HamanoDec 11, 2015
  6. David TurnerDec 11, 2015
  7. Junio C HamanoDec 11, 2015
  8. David TurnerDec 11, 2015
  9. Junio C HamanoDec 12, 2015
  10. David TurnerDec 12, 2015
  11. Howard ChuDec 18, 2015
  12. 03/16 refs: add methods for the ref iteratorsDavid Turner, Dec 3, 2015
  13. David AguilarJan 3, 2016
  14. Junio C HamanoJan 4, 2016
  15. Michael HaggertyJan 5, 2016
  16. Junio C HamanoJan 5, 2016
  17. Ronnie SahlbergJan 4, 2016
  18. Junio C HamanoJan 4, 2016
  19. Jeff KingJan 5, 2016
  20. Junio C HamanoJan 5, 2016
  21. 04/16 refs: add do_for_each_per_worktree_refDavid Turner, Dec 3, 2015
  22. Junio C HamanoDec 11, 2015
  23. David TurnerDec 12, 2015
  24. 05/16 refs: add methods for reflogDavid Turner, Dec 3, 2015
  25. 06/16 refs: add method for initial ref transaction commitDavid Turner, Dec 3, 2015
  26. 07/16 refs: add method for delete_refsDavid Turner, Dec 3, 2015
  27. 08/16 refs: add methods to init refs backend and dbDavid Turner, Dec 3, 2015
  28. Michael HaggertyDec 23, 2015
  29. David TurnerDec 23, 2015
  30. 09/16 refs: add method to rename refsDavid Turner, Dec 3, 2015
  31. 10/16 refs: make lock genericDavid Turner, Dec 3, 2015
  32. 11/16 refs: move duplicate check to common codeDavid Turner, Dec 3, 2015
  33. Michael HaggertyDec 23, 2015
  34. David TurnerJan 5, 2016
  35. 12/16 refs: always handle non-normal refs in files backendDavid Turner, Dec 3, 2015
  36. Michael HaggertyDec 23, 2015
  37. David TurnerJan 6, 2016
  38. 1/3 refs: allow log-only updatesDavid Turner, Jan 6, 2016
  39. 2/3 refs: resolve symbolic refs firstDavid Turner, Jan 6, 2016
  40. 3/3 refs: always handle non-normal refs in files backendDavid Turner, Jan 6, 2016
  41. David TurnerJan 8, 2016
  42. David TurnerJan 6, 2016
  43. 13/16 init: allow alternate backends to be set for new reposDavid Turner, Dec 3, 2015
  44. Junio C HamanoDec 5, 2015
  45. Duy NguyenDec 5, 2015
  46. Jeff KingDec 5, 2015
  47. David TurnerDec 8, 2015
  48. Michael HaggertyDec 23, 2015
  49. Jeff KingDec 23, 2015
  50. Jeff KingDec 10, 2015
  51. David TurnerDec 10, 2015
  52. clone: use child_process for recursive checkoutsMichael Haggerty, Dec 23, 2015
  53. David TurnerJan 6, 2016
  54. Michael HaggertyDec 23, 2015
  55. David TurnerJan 5, 2016
  56. Junio C HamanoJan 5, 2016
  57. David TurnerJan 5, 2016
  58. Michael HaggertyJan 6, 2016
  59. Duy NguyenJan 6, 2016
  60. Shawn PearceJan 7, 2016
  61. 14/16 refs: allow ref backend to be set for cloneDavid Turner, Dec 3, 2015
  62. Michael HaggertyDec 23, 2015
  63. Eric SunshineDec 23, 2015
  64. 15/16 refs: add LMDB refs backendDavid Turner, Dec 3, 2015
  65. Junio C HamanoDec 5, 2015
  66. David TurnerDec 5, 2015
  67. Jonathan NiederDec 17, 2015
  68. David TurnerDec 17, 2015
  69. Jonathan NiederDec 17, 2015
  70. Michael HaggertyDec 23, 2015
  71. David TurnerJan 8, 2016
  72. 16/16 refs: tests for lmdb backendDavid Turner, Dec 3, 2015
  73. David TurnerDec 22, 2015

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.