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

Re: libgit2 - a true git library

From
Pierre Habouzit <madcoder@debian.org>
Date
Oct 31, 2008, 20:12 UTC
Message-ID
<20081031201235.GE8464@artemis.corp>
In-Reply-To
<20081031195711.GW14786@spearce.org>
On Fri, Oct 31, 2008 at 07:57:11PM +0000, Shawn O. Pearce wrote:
Show 5 quoted lines
> This "fixes" the "we leak everything" behavior and allows
> applications to have multiple pools on different threads if
> it needs to.  Thus the core git_revp_t isn't thread-safe and
> doesn't get weighed down by locking if the application wants
> multiple threads.

Note that on Linux (and also BSDs I think) many pthread locking functions have stubs in the glibc and cost 0 until you use the libpthread. So unless we need to use locking inside the tight-loop, it's virtually free to write a thread-safe library (a function call is basically 10 times cheaper than an xchg-based lock).

(Though for git it would suck as we get libpthread in our depends through some of the other dependencies.

Another way is to use function pointers for the locking, and have a function to make the object store thread safe by setting the pointers to functions actually doing locking, and to let it point to functions doing nothing else.

It looks unrealistic to me to let people deal with the locking, especially if we mean this library to _also_ be used in language bindings, hence used in sloppily written scripts.

But of course, if locking calls are used in the tight loop that would rather suck :/

Show 8 quoted lines
> Pierre Habouzit <madcoder@debian.org> wrote:
> > 
> > Well, I propose the following: we set-up on GNU-ld + gcc enabled systems
> > all what is needed to use symbol visibility, which isn't that intrusive,
> > and also rather easy given your GIT_EXPORT macro definition.
> 
> Yes, agreed.  Only I don't know how to do it myself.  I know its
> possible, so if someone wants to contribute a patch for this ... :-)

I will, basically, you need to build everything with -fvisibilty=hidden in your CFLAGS, and mark the prototypes of symbols you want to export with __attribute__((visibility("default"))) (that you can set into your EXPORT_GIT macro when you're building with __GNUC__).

You don't even need a linker script (unless we're going to do some symbol versioning but I'm unsure whether it's that useful for now).

Show 12 quoted lines
> > No, my worry was rather wrt git core itself, I really think we _must_
> > make it link against libgit2 if we want libgit2 to stay current, but git
> > core will _very likely_ need the private stuff, and it _will_ be a
> > problem. I mean we cannot seriously so-name a library and show its guts
> > at the same time, and I'm unsure how to fix that problem. _that_ was my
> > actual question.
> 
> Hmmph.  I agree git-core needs to link to libgit2.
> 
> I disagree it needs private bits.  If we do the library right
> git-core can use the public API.  And where it cannot its either
> not something that is "right" for libgit2
> (e.g. its parseopts and
> we aren't committed yet to including option parsing)
Sure, I didn't mean we have to put it in libgit2, it's highly UI related
and other tool may want to use something else, and it makes no sense for
many languages that have their library already (python, perl do e.g.).
 
Show 8 quoted lines
> or its highly
> experimental and we shouldn't put it into the library (and thus
> also git-core) until its more frozen.
> 
> That said, I don't think its criminal to have git-core include and
> link to a static libgit2, especially if git-core's usage of the
> library is ahead of what the library itself is able to expose at
> the present time.
Okay, we'll see how that turns out to work then :)
Show 22 quoted lines
> Off the top of my head some really important ones:
> 
> 	diff-delta.c
> 	object.c
> 	patch-delta.c
> 	refs.c
> 	revision.c
> 	sha1_file.c
> 	sha1_name.c
> 
> They form a pretty large part of the guts of what most people want
> from a git library.
> 
> Slightly less important, but still fairly core:
> 
> 	builtin-fetch-pack.c
> 	builtin-send-pack.c
> 	connect.c
> 	remote.c
> 	transport.c
> 
> Is most of the client side of the git:// transport, something people want.

Okay I'll let people mention what they would like to see too, and I'll work from that then.

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org
Previous: Shawn O. PearceNext: Junio C Hamano
Message 8 of 83 in “libgit2 - a true git library”
  1. Shawn O. PearceOct 31, 2008
  2. Pieter de BieOct 31, 2008
  3. Pieter de BieOct 31, 2008
  4. Pierre HabouzitOct 31, 2008
  5. Shawn O. PearceOct 31, 2008
  6. Pierre HabouzitOct 31, 2008
  7. Shawn O. PearceOct 31, 2008
  8. Pierre HabouzitOct 31, 2008
  9. Junio C HamanoOct 31, 2008
  10. Shawn O. PearceOct 31, 2008
  11. Pierre HabouzitNov 1, 2008
  12. Andreas EricssonNov 1, 2008
  13. Pierre HabouzitNov 1, 2008
  14. Shawn O. PearceNov 1, 2008
  15. Andreas EricssonNov 1, 2008
  16. Shawn O. PearceNov 2, 2008
  17. Andreas EricssonNov 3, 2008
  18. Shawn O. PearceNov 2, 2008
  19. Pierre HabouzitNov 2, 2008
  20. Nicolas PitreOct 31, 2008
  21. david@lang.hmOct 31, 2008
  22. Nicolas PitreOct 31, 2008
  23. Shawn O. PearceOct 31, 2008
  24. Shawn O. PearceOct 31, 2008
  25. Pierre HabouzitOct 31, 2008
  26. Pierre HabouzitOct 31, 2008
  27. Nicolas PitreOct 31, 2008
  28. Andreas EricssonNov 1, 2008
  29. Pieter de BieOct 31, 2008
  30. Shawn O. PearceOct 31, 2008
  31. Junio C HamanoOct 31, 2008
  32. Pierre HabouzitNov 1, 2008
  33. Shawn O. PearceNov 1, 2008
  34. Pierre HabouzitNov 1, 2008
  35. Shawn O. PearceNov 1, 2008
  36. Nicolas PitreNov 1, 2008
  37. Shawn O. PearceNov 1, 2008
  38. Nicolas PitreNov 1, 2008
  39. Shawn O. PearceNov 1, 2008
  40. Johannes SchindelinNov 1, 2008
  41. Pierre HabouzitNov 1, 2008
  42. Nicolas PitreNov 1, 2008
  43. Pierre HabouzitNov 1, 2008
  44. Johannes SchindelinNov 1, 2008
  45. Junio C HamanoOct 31, 2008
  46. Pierre HabouzitOct 31, 2008
  47. Shawn O. PearceOct 31, 2008
  48. Jakub NarebskiOct 31, 2008
  49. david@lang.hmNov 1, 2008
  50. Shawn O. PearceNov 1, 2008
  51. david@lang.hmNov 1, 2008
  52. Pierre HabouzitNov 1, 2008
  53. Nicolas PitreNov 1, 2008
  54. Pierre HabouzitNov 1, 2008
  55. Nicolas PitreNov 1, 2008
  56. Shawn O. PearceNov 1, 2008
  57. Nicolas PitreNov 1, 2008
  58. Shawn O. PearceNov 1, 2008
  59. Scott ChaconNov 2, 2008
  60. Scott ChaconNov 2, 2008
  61. Shawn O. PearceNov 2, 2008
  62. David BrownNov 2, 2008
  63. Shawn O. PearceNov 3, 2008
  64. Pierre HabouzitNov 1, 2008
  65. david@lang.hmNov 1, 2008
  66. Brian GernhardtOct 31, 2008
  67. Andreas EricssonOct 31, 2008
  68. Shawn O. PearceOct 31, 2008
  69. Junio C HamanoOct 31, 2008
  70. Andreas EricssonNov 1, 2008
  71. Johannes SchindelinOct 31, 2008
  72. Bruno SantosOct 31, 2008
  73. Shawn O. PearceOct 31, 2008
  74. Andreas EricssonNov 1, 2008
  75. Shawn O. PearceNov 1, 2008
  76. Johannes SchindelinNov 2, 2008
  77. Pierre HabouzitNov 2, 2008
  78. Andreas EricssonNov 3, 2008
  79. Steve FrécinauxNov 8, 2008
  80. Andreas EricssonNov 8, 2008
  81. Pierre HabouzitNov 8, 2008
  82. Andreas EricssonNov 9, 2008
  83. Shawn O. PearceNov 9, 2008

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.