From: 胡哲宁 <adlternative@gmail.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: "阿德烈 via GitGitGadget" <gitgitgadget@gmail.com>,
"Git List" <git@vger.kernel.org>,
"Junio C Hamano" <gitster@pobox.com>,
"Stefan Beller" <sbeller@google.com>
Subject: Re: [PATCH v2] alloc.h|c: migrate alloc_states to mem-pool
Date: Tue, 2 Feb 2021 21:12:10 +0800 [thread overview]
Message-ID: <CAOLTT8Rf0vjB1+RuChbVPgf=YDif4B1mnro2MEF6E8+uGXM24Q@mail.gmail.com> (raw)
In-Reply-To: <7a9e78d0-732d-a990-0cb5-6bd8cf940a88@web.de>
To René Scharfe:
Thanks for checking in.
René Scharfe <l.s.r@web.de> 于2021年2月2日周二 上午1:55写道:
>
> Am 01.02.21 um 11:39 schrieb 阿德烈 via GitGitGadget:
> > From: ZheNing Hu <adlternative@gmail.com>
> >
> > "alloc_state" may have similar effects with "mem_pool".
> > Using the new memory pool API may be more beneficial
> > to our memory management in the future.
>
> Replacing the custom object allocator with mem-pool would allow reducing
> the code size. What other effects might it have? Do you expect changes
> in memory use and/or performance with the current code and your patch?
>
> > functions "alloc_*_node" now change to "mem_pool_alloc_*_node".
>
> Why rename these functions? Do callers need to care about the
> underlying allocator? The function signatures stay the same. In any
> case, this renaming would be easier to review if it was moved to a
> separate patch.
>
Truly,I will change it.
> > At the same time ,I add the member `alloc_count` of
> > struct mem_pool ,so that we can effective track
> > node alloc count,and adapt to the original interface `alloc_report`.
>
> This function has no callers. Why not remove it (in a separate patch)?
>
Before I may have some confuse about choosing `alloc_state`or`mem_pool`,
so It has not been deleted yet.I remember that now.
> > diff --git a/alloc.c b/alloc.c
> > index 957a0af3626..951ef3e4ed7 100644
> > --- a/alloc.c
> > +++ b/alloc.c
> > @@ -71,30 +71,30 @@ static inline void *alloc_node(struct alloc_state *s, size_t node_size)
> > return ret;
> > }
>
> This keeps the now unused function alloc_node(), which breaks the build
> with -Werror.
>
> allocate_alloc_state() and clear_alloc_state() become unused as well,
> but the compiler doesn't complain because those functions are
> exported. Nevertheless this patch should remove them, no?
>
> > diff --git a/object.h b/object.h
> > index 59daadce214..43031d8dc04 100644
> > --- a/object.h
> > +++ b/object.h
> > @@ -10,11 +10,11 @@ struct parsed_object_pool {
> > int nr_objs, obj_hash_size;
> >
> > /* TODO: migrate alloc_states to mem-pool? */
>
> This comment becomes stale with this patch and should be removed at
> the same time.
>
OK.
> > - struct alloc_state *blob_state;
> > - struct alloc_state *tree_state;
> > - struct alloc_state *commit_state;
> > - struct alloc_state *tag_state;
> > - struct alloc_state *object_state;
> > + struct mem_pool *blob_pool;
> > + struct mem_pool *tree_pool;
> > + struct mem_pool *commit_pool;
> > + struct mem_pool *tag_pool;
> > + struct mem_pool *object_pool;
>
> Why have pointers here instead of the structs themselves? It's not like
> a struct parsed_object_pool is of much use without them, right?
>
> The same question applies to the original code as well, of course.
Here I may have some questions: why use `struct mem_pool` instead of
using `struct mem_pool *`?
I hope you can answer my doubts, thank you!
>
> René
next prev parent reply other threads:[~2021-02-02 13:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-30 12:59 [PATCH] alloc.h|c: migrate alloc_states to mem-pool 阿德烈 via GitGitGadget
2021-02-01 10:39 ` [PATCH v2] " 阿德烈 via GitGitGadget
2021-02-01 17:55 ` René Scharfe
2021-02-02 13:12 ` 胡哲宁 [this message]
2021-02-02 16:36 ` René Scharfe.
2021-02-01 17:56 ` Junio C Hamano
2021-02-02 13:06 ` 胡哲宁
2021-02-04 10:33 ` [PATCH v3] " 阿德烈 via GitGitGadget
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOLTT8Rf0vjB1+RuChbVPgf=YDif4B1mnro2MEF6E8+uGXM24Q@mail.gmail.com' \
--to=adlternative@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
--cc=sbeller@google.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).