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

Re: [RFD PATCH 0/3] Free all the memory!

From
EWEric Wong <e@80x24.org>
Date
May 18, 2016, 07:23 UTC
Message-ID
<20160518072329.GA1723@dcvr.yhbt.net>
In-Reply-To
<CAGZ79kaJoAxqtsTuErQSgJiVeD_vdZ1MQXKr-LTtyro-FbscTQ@mail.gmail.com>
Stefan Beller <sbeller@google.com> wrote:
Show 7 quoted lines
> Eric Wong writes:
> > I haven't checked for git, but I suspect we get speedups by not
> > calling free().  I've never needed to profile git, but free() at
> > exit has been a measurable bottleneck in other projects I've
> > worked on.  Often, free() was more expensive than *alloc().
> 
> Thanks for reiterating that original response I got back then :)
Heh, I suspected I missed some of the original discussion.
Show 9 quoted lines
> > #ifdef FREE_ALL_MEMORY
> > static inline void optional_free(void *ptr) {}
> > #else
> > #  define FREE_ALL_MEMORY (0)
> > #  define optional_free(ptr) free(ptr)
> > #endif
> 
> Shouldn't that be "#ifndef" instead? I really like the
> "optional_free", I'll keep it in mind!

Yes, I got my conditionals backwards. That's what I get for being awake way past my bedtime :x

We may also want to find a way to annotate *alloc calls as "lifetime" so they can pair with optional_free. Maybe sparse can help with that?

Previous: Stefan BellerNext: Ævar Arnfjörð Bjarmason
Message 12 of 15 in “Free all the memory!”
  1. 0/3 Free all the memory!Stefan Beller, May 17, 2016
  2. 1/3 mv: free memory at the end if desiredStefan Beller, May 17, 2016
  3. Torsten BögershausenMay 17, 2016
  4. 2/3 pack-redundant: free all memoryStefan Beller, May 17, 2016
  5. Eric SunshineMay 17, 2016
  6. 3/3 rev-parse: free all memoryStefan Beller, May 17, 2016
  7. Eric SunshineMay 17, 2016
  8. Eric WongMay 17, 2016
  9. Stefan BellerMay 17, 2016
  10. Junio C HamanoMay 17, 2016
  11. Stefan BellerMay 17, 2016
  12. Eric WongMay 18, 2016
  13. Ævar Arnfjörð BjarmasonMay 18, 2016
  14. David TurnerMay 17, 2016
  15. Matthieu MoyMay 17, 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.