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

Re: [PATCH v3 3/3] Move reusable parts of memory pool into its own file

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 27, 2018, 16:43 UTC
Message-ID
<xmqqlgeda2pd.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180326170351.197793-4-jamill@microsoft.com>
Jameson Miller <jamill@microsoft.com> writes:
Show 12 quoted lines
> This moves the reusable parts of the memory pool logic used by
> fast-import.c into its own file for use by other components.
>
> Signed-off-by: Jameson Miller <jamill@microsoft.com>
> ---
>  Makefile      |  1 +
>  fast-import.c | 70 +----------------------------------------------------------
>  mem-pool.c    | 55 ++++++++++++++++++++++++++++++++++++++++++++++
>  mem-pool.h    | 34 +++++++++++++++++++++++++++++
>  4 files changed, 91 insertions(+), 69 deletions(-)
>  create mode 100644 mem-pool.c
>  create mode 100644 mem-pool.h

OK. This is indeed straight-forward line movements and nothing else, other than obviously a few static helpers are now extern.

I said I'd anticipate that the allocation that bypasses the pool subsystem would want to become traceable by the pool subsystem, which would allow us to free() the pieces of memory allocated directly with xmalloc() in mem_pool_alloc() instead of leaking. I am OK if the structure of this series is to make that change after these three steps we see here. When that happens, it will start to make sense to bill the "this is too big so do not attempt to carve it out from block, and do not overallocate and make the remainder available for later requests" to the pool instance mem_pool_alloc() is working on, as that piece of memory is also known to a specific pool instance.

After I wrote review for 2/3, I found out that you changed the meaning of total_allocd (which should probably be described in its log message). Unlike the original that counted "total", it now is used only for memory that is allocated directly by fast-import.c and does not account for memory obtained by calling mem-pool.

The output routine is changed in 2/3 to add fi_mem_pool's pool_alloc to it, so billing oversized allocation that does *not* belong to any specific pool to _some_ pool and ignoring total_allocd would cancel things out. It still feels a bit fishy, but I think it is OK.

So all in all, I think we are in no worse shape than the original (we call it "bug-to-bug compatible" ;-)), and successfully extracted a reusable piece in a separate file in a clean way so that we can refine and extend it further. Nicely done.

Will queue; the proposed log for step 2/3 may want to be a bit polished, though.

Thanks.
Previous: Jameson MillerNext: Jameson Miller
Message 22 of 29 in “Extract memory pool logic into reusable component”
  1. 0/3 Extract memory pool logic into reusable componentjameson.miller81@gmail.com, Mar 21, 2018
  2. 1/3 fast-import: rename mem_pool to fi_mem_pooljameson.miller81@gmail.com, Mar 21, 2018
  3. 3/3 fast-import: use built-in mem pooljameson.miller81@gmail.com, Mar 21, 2018
  4. 2/3 Introduce a reusable memory pool typejameson.miller81@gmail.com, Mar 21, 2018
  5. Junio C HamanoMar 21, 2018
  6. 0/3 Extract memory pool logic into reusable componentJameson Miller, Mar 23, 2018
  7. 1/5 fast-import: rename mem_pool type to mp_blockJameson Miller, Mar 23, 2018
  8. Junio C HamanoMar 23, 2018
  9. 2/5 fast-import: introduce mem_pool typeJameson Miller, Mar 23, 2018
  10. Junio C HamanoMar 23, 2018
  11. 3/5 fast-import: update pool_* functions to work on local poolJameson Miller, Mar 23, 2018
  12. Junio C HamanoMar 23, 2018
  13. 5/5 Expand implementation of mem-pool typeJameson Miller, Mar 23, 2018
  14. Junio C HamanoMar 23, 2018
  15. 4/5 Move the reusable parts of memory pool into its own fileJameson Miller, Mar 23, 2018
  16. Junio C HamanoMar 23, 2018
  17. 2/3 fast-import: introduce mem_pool typeJameson Miller, Mar 26, 2018
  18. Eric SunshineMar 26, 2018
  19. Junio C HamanoMar 27, 2018
  20. 1/3 fast-import: rename mem_pool type to mp_blockJameson Miller, Mar 26, 2018
  21. 3/3 Move reusable parts of memory pool into its own fileJameson Miller, Mar 26, 2018
  22. Junio C HamanoMar 27, 2018
  23. Jameson MillerMar 29, 2018
  24. 0/3 Extract memory pool logic into reusable componentJameson Miller, Mar 26, 2018
  25. 0/3 Extract memory pool logic into reusable componentJameson Miller, Apr 11, 2018
  26. Jameson MillerApr 17, 2018
  27. 3/3 Move reusable parts of memory pool into its own fileJameson Miller, Apr 11, 2018
  28. 2/3 fast-import: introduce mem_pool typeJameson Miller, Apr 11, 2018
  29. 1/3 fast-import: rename mem_pool type to mp_blockJameson Miller, Apr 11, 2018

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.