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

Re: Make the git codebase thread-safe

From
ZTZachary Turner <zturner@chromium.org>
Date
Feb 15, 2014, 01:15 UTC
Message-ID
<CAAErz9gO3NrAF5Zhu277NLqBv-4otQVWGBP6fX00x2OJ3v0_fg@mail.gmail.com>
In-Reply-To
<CACsJy8AQNmmW40R-H7kz1dmwiaSKVgu+GP=Jt1qTKgfbZoMkMA@mail.gmail.com>

Even if we make that change to use TLS for this case, the implementation of pread() will still change in such a way that the semantics of pread() are different on Windows. Is that ok?

Just to summarize, here's the viable approaches I've seen discussed so far:
1) Use _WINVER at compile time to select either a thread-safe or
non-thread-safe implementation of pread.  This is the easiest possible
code change, but would necessitate 2 binary distributions of git for
windows.
2) Use TLS as you suggest and have one fd per pack thread.  Probably
the most complicated code change (at least for me, being a first-time
contributor)
3) Use Karsten's suggested implementation from earlier in the thread.
Seems to work, but it's a little confusing from a readability
standpoint since the implementation is not-thread safe except in this
specific usage context.
On Fri, Feb 14, 2014 at 4:56 PM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 29 quoted lines
> On Sat, Feb 15, 2014 at 7:50 AM, Stefan Zager <szager@google.com> wrote:
>> On Fri, Feb 14, 2014 at 4:45 PM, Duy Nguyen <pclouds@gmail.com> wrote:
>>> On Sat, Feb 15, 2014 at 2:16 AM, Zachary Turner <zturner@chromium.org> wrote:
>>>> (Gah, sorry if you're receiving multiple emails to your personal
>>>> addresses, I need to get used to manually setting Plain-text mode
>>>> every time I send a message).
>>>>
>>>> For the mixed read, we wouldn't be looking for another caller of
>>>> pread() (since it doesn't care what the file pointer is), but instead
>>>> a caller of read() or lseek() (since those do depend on the current
>>>> file pointer).  In index-pack.c, I see two possible culprits:
>>>>
>>>> 1) A call to xread() from inside fill()
>>>> 2) A call to lseek in parse_pack_objects()
>>>>
>>>> Do you think these could be related?  If so, maybe that opens up some
>>>> other solutions?
>>>
>>> For index-pack alone, what's wrong with open one file handle per thread?
>>
>> Nothing wrong with that, except that it would mean either using
>> thread-local storage (which the code doesn't currently use); or
>> plumbing pack_fd through the call stack, which doesn't sound very fun.
>
> Current code does use thread-local storage (struct thread_local and
> get_thread_data). Adding a new file handle when NO_THREAD_SAFE_PREAD
> is defined is simpler imo.
> --
> Duy
Previous: Duy NguyenNext: Duy Nguyen
Message 51 of 55 in “Make the git codebase thread-safe”
  1. Stefan ZagerFeb 12, 2014
  2. Robin H. JohnsonFeb 12, 2014
  3. Duy NguyenFeb 12, 2014
  4. Karsten BleesFeb 12, 2014
  5. Mike HommeyFeb 12, 2014
  6. Karsten BleesFeb 13, 2014
  7. Stefan ZagerFeb 12, 2014
  8. Duy NguyenFeb 12, 2014
  9. Stefan ZagerFeb 12, 2014
  10. Matthieu MoyFeb 12, 2014
  11. Stefan ZagerFeb 12, 2014
  12. David KastrupFeb 12, 2014
  13. Stefan ZagerFeb 12, 2014
  14. David KastrupFeb 12, 2014
  15. Mike HommeyFeb 12, 2014
  16. David KastrupFeb 13, 2014
  17. Mike HommeyFeb 13, 2014
  18. Mike HommeyFeb 13, 2014
  19. David KastrupFeb 13, 2014
  20. Junio C HamanoFeb 12, 2014
  21. Stefan ZagerFeb 12, 2014
  22. Junio C HamanoFeb 12, 2014
  23. Erik Faye-LundFeb 12, 2014
  24. Stefan ZagerFeb 12, 2014
  25. Erik Faye-LundFeb 12, 2014
  26. Stefan ZagerFeb 12, 2014
  27. Erik Faye-LundFeb 12, 2014
  28. Karsten BleesFeb 12, 2014
  29. Stefan ZagerFeb 12, 2014
  30. Johannes SixtFeb 13, 2014
  31. David KastrupFeb 13, 2014
  32. Stefan ZagerFeb 13, 2014
  33. Zachary TurnerFeb 13, 2014
  34. Karsten BleesFeb 13, 2014
  35. Stefan ZagerFeb 13, 2014
  36. Zachary TurnerFeb 13, 2014
  37. Karsten BleesFeb 14, 2014
  38. Stefan ZagerFeb 14, 2014
  39. brian m. carlsonFeb 13, 2014
  40. Matheus TavaresApr 2, 2019
  41. Duy NguyenApr 2, 2019
  42. David KastrupApr 2, 2019
  43. Duy NguyenApr 2, 2019
  44. David KastrupApr 2, 2019
  45. Matheus Tavares BernardinoApr 2, 2019
  46. Zachary TurnerFeb 14, 2014
  47. Karsten BleesFeb 14, 2014
  48. Duy NguyenFeb 15, 2014
  49. Stefan ZagerFeb 15, 2014
  50. Duy NguyenFeb 15, 2014
  51. Zachary TurnerFeb 15, 2014
  52. Duy NguyenFeb 15, 2014
  53. Junio C HamanoFeb 18, 2014
  54. Zachary TurnerFeb 18, 2014
  55. Stefan ZagerFeb 14, 2014

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.