From: Patrick Steinhardt <ps@pks.im>
To: Derrick Stolee <stolee@gmail.com>
Cc: Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org, gitster@pobox.com, peff@peff.net
Subject: Re: [PATCH 1/2] read-cache: free threaded memory pool
Date: Tue, 1 Oct 2024 16:11:31 +0200 [thread overview]
Message-ID: <ZvwDEyhe-3DyQp75@pks.im> (raw)
In-Reply-To: <8ebebcd5-4ddb-4c1e-9bf8-4e9a79944e2b@gmail.com>
On Tue, Oct 01, 2024 at 09:20:01AM -0400, Derrick Stolee wrote:
> On 9/30/24 8:32 AM, Patrick Steinhardt wrote:
> > On Mon, Sep 30, 2024 at 11:40:23AM +0000, Derrick Stolee via GitGitGadget wrote:
> > > From: Derrick Stolee <stolee@gmail.com>
> > >
> > > In load_cache_entries_threaded(), each thread is allocated its own
> >
> > s/allocated/allocating/
>
> You're right that the wording is awkward but I'm not thrilled with the
> suggested alternative.
>
> Perhaps "each thread allocates its own"
Sure, works for me :)
> > > memory pool. This pool needs to be cleaned up while closing the threads
> > > down, or it will be leaked.
>
> > Okay. We move over the contents of the pool, but forgot to free the pool
> > itself. As far as I can see the pool is always allocated and only used
> > in two functions, both of which assume that it is allocated. So I wonder
> > why it is allocated in the first place instead of making it a direct
> > member of `struct load_cache_entries_thread_data`.
>
> I took a look at what it would take to replace the pointer with an inline
> struct but found complications with situations such as the find_mem_pool()
> method. While we could replace some of the logic to recognize the new
> type, the existing logic seems to depend on using the NULL pointer as an
> indicator that the pool should be lazily initialized.
>
> If we were to pull the struct inline, we would either need another boolean
> to indicate initialization or lose lazy initialization.
>
> I'm leaning towards the simpler leak fix over the disruption of that
> change.
Fair enough, no complaint from my side. I thought it would've been easy,
but didn't dive deep. So if you say it is harder than I made it out to
be with my shallow understanding I'm going to trust your judgement.
After all, the leak fix is a strict improvement by itself.
Patrick
next prev parent reply other threads:[~2024-10-01 14:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-30 11:40 [PATCH 0/2] read-cache: two small leak fixes Derrick Stolee via GitGitGadget
2024-09-30 11:40 ` [PATCH 1/2] read-cache: free threaded memory pool Derrick Stolee via GitGitGadget
2024-09-30 12:32 ` Patrick Steinhardt
2024-10-01 13:20 ` Derrick Stolee
2024-10-01 14:11 ` Patrick Steinhardt [this message]
2024-09-30 11:40 ` [PATCH 2/2] read-cache: free hash context in do_write_index() Derrick Stolee via GitGitGadget
2024-09-30 12:32 ` Patrick Steinhardt
2024-10-01 10:01 ` Derrick Stolee
2024-10-01 10:16 ` Patrick Steinhardt
2024-10-01 17:37 ` [PATCH v2] read-cache: free threaded memory pool Derrick Stolee via GitGitGadget
2024-10-02 10:49 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZvwDEyhe-3DyQp75@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).