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

Re: [PATCH V2 3/3] strbuf: allow to use preallocated memory

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 8, 2016, 19:48 UTC
Message-ID
<xmqq37onlawb.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160608191918.GB19572@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> That made me wonder if we could repeatedly reuse a buffer attached to
> the file descriptor. And indeed, isn't that what stdio is? The whole
> reason this buffer exists is because we are using a direct descriptor
> write. If we switched this function to use fprintf(), we'd avoid the
> whole buffer question, have a fixed cap on our memory use (since we just
> flush anytime the buffer is full) _and_ we'd reduce the number of
> write syscalls we're making by almost a factor of 100.

The primary reason why we avoid stdio in the lower level part of I/O is that the error reporting and handling is horrible.

e.g. c.f. http://article.gmane.org/gmane.comp.version-control.git/27019

Otherwise, I'd agree with your "Why aren't we using stdio if counting and avoiding overflow is so hard?".

Previous: Matthieu MoyNext: Jeff King
Message 30 of 32 in “strbuf: improve API”
  1. 0/3 strbuf: improve APIWilliam Duclot, Jun 6, 2016
  2. 1/3 strbuf: add testsWilliam Duclot, Jun 6, 2016
  3. Matthieu MoyJun 6, 2016
  4. Johannes SchindelinJun 7, 2016
  5. 2/3 pretty.c: rename strbuf_wrap() functionWilliam Duclot, Jun 6, 2016
  6. Matthieu MoyJun 6, 2016
  7. Johannes SchindelinJun 7, 2016
  8. 3/3 strbuf: allow to use preallocated memoryWilliam Duclot, Jun 6, 2016
  9. Matthieu MoyJun 6, 2016
  10. Junio C HamanoJun 6, 2016
  11. William DuclotJun 6, 2016
  12. Junio C HamanoJun 6, 2016
  13. Jeff KingJun 6, 2016
  14. Junio C HamanoJun 6, 2016
  15. Junio C HamanoJun 6, 2016
  16. Jeff KingJun 6, 2016
  17. William DuclotJun 7, 2016
  18. Junio C HamanoJun 7, 2016
  19. Michael HaggertyJun 8, 2016
  20. Junio C HamanoJun 8, 2016
  21. Jeff KingJun 8, 2016
  22. send-pack: use buffered I/O to talk to pack-objectsJeff King, Jun 8, 2016
  23. Matthieu MoyJun 9, 2016
  24. Ramsay JonesJun 9, 2016
  25. Jeff KingJun 9, 2016
  26. Ramsay JonesJun 9, 2016
  27. Junio C HamanoJun 9, 2016
  28. Jeff KingJun 9, 2016
  29. Matthieu MoyJun 9, 2016
  30. Junio C HamanoJun 8, 2016
  31. Jeff KingJun 8, 2016
  32. Junio C HamanoJun 8, 2016

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.