From: Fengnan Chang <changfengnan@bytedance.com>
To: Liang Ma <liangma@liangbit.com>
Cc: "Morten Brørup" <mb@smartsharesystems.com>,
"Thomas Monjalon" <thomas@monjalon.net>,
anatoly.burakov@intel.com, dev@dpdk.org, rsanford@akamai.com,
bruce.richardson@intel.com, maxime.coquelin@redhat.com,
david.marchand@redhat.com, jerinj@marvell.com,
honnappa.nagarahalli@arm.com,
"Fidaullah Noonari" <fidaullah.noonari@emumba.com>
Subject: Re: [External] Re: [PATCH] malloc: fix malloc performance may becomes worse as the number of malloc increases
Date: Fri, 17 Feb 2023 10:14:52 +0800 [thread overview]
Message-ID: <CAPFOzZsuEXifady9W7PNAq8jU=5sx6836Qy6XNLOct+kbm_RWg@mail.gmail.com> (raw)
In-Reply-To: <Y+43X2Vxpcga7bRE@C02GF04TMD6V>
Liang Ma <liangma@liangbit.com> 于2023年2月16日周四 22:04写道:
>
> On Wed, Feb 15, 2023 at 12:10:23PM +0100, Morten Brørup wrote:
> > +CC: Fidaullah Noonari <fidaullah.noonari@emumba.com>, your name also shows up in the git log; perhaps you can help review this patch.
> >
> >
> > I gave up reviewing in depth, because the existing code is not easy to quickly understand, and it would take too long for me. E.g. the malloc_elem->size is field is undocumented, and find_suitable_element() calls the malloc_elem_free_list_index() function with the raw size (as passed to the function), but malloc_elem_free_list_insert() calls the malloc_elem_free_list_index() with malloc_elem->size - MALLOC_ELEM_HEADER_LEN.
> >
> > Looking isolated at the patch itself...
> >
> > I agree with the way the patch modifies the ranges of the free list, and the consequential removal of the "- 1" from the calculation of log2.
> >
> > Intuitively, the lists should cover ranges such as [0x100..0x3FF], which this patch does, not [0x101..0x400], how it was previously... The ranges with this patch make much more sense.
> >
> > So if the existing code is otherwise correct, i.e. handles the size with/without MALLOC_ELEM_HEADER_LEN correctly, my gut feeling says this patch is an improvement.
> >
> > Acked-by: Morten Brørup <mb@smartsharesystems.com>
> I run the test with DPDK malloc perf test. The issue is replicated.
> IMO, the whole process is if application use rte_malloc with a relative
> large alignment size. e.g. 4K alignment. Currently implementation will
> generate lots "fragment" because of the large alignment in related mem
> element free list. In the test code, 4K malloc size + 4k alignment will
> lead to the actually space is needed has to take from upper level mem
> element idx free list. The consequence is that will generate lots
> fragment element and those element is inserted to the current level mem
> free-list. However, when the rte_malloc select which free list to start
> scan with, it doesn't take the alignment into account, which ends up
> with waste some time in the current level free-list. If the scan logic
> take alignment into account, it might "smartly" skip current level and
> jump to the upper level directly.
>
Thank you for the detailed explanation !
You may have already found the problem that this patch can only solve
the fragmentation problem of 4k/16k/64k scenes, not work for 3k/15k/63k.
For example, alloc 3k and align with 1k, also has this problem.
Now this patch can't handle all similar scenarios,We already started
working on a new soultion which aims to solve all similar problems .
BTW, this patch is still useful, because even without fragmentation
problems, the probability of finding a suitable elem from a larger size list
is greater than from a smaller size list.
> >
>
next prev parent reply other threads:[~2023-02-17 2:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-10 6:30 Fengnan Chang
2023-02-15 10:10 ` Thomas Monjalon
2023-02-15 11:10 ` Morten Brørup
2023-02-15 17:16 ` Stephen Hemminger
2023-02-16 2:54 ` [External] " Fengnan Chang
2023-02-16 14:02 ` Liang Ma
2023-02-17 2:14 ` Fengnan Chang [this message]
2023-02-16 10:40 ` Liang Ma
2023-02-20 10:59 ` David Marchand
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='CAPFOzZsuEXifady9W7PNAq8jU=5sx6836Qy6XNLOct+kbm_RWg@mail.gmail.com' \
--to=changfengnan@bytedance.com \
--cc=anatoly.burakov@intel.com \
--cc=bruce.richardson@intel.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=fidaullah.noonari@emumba.com \
--cc=honnappa.nagarahalli@arm.com \
--cc=jerinj@marvell.com \
--cc=liangma@liangbit.com \
--cc=maxime.coquelin@redhat.com \
--cc=mb@smartsharesystems.com \
--cc=rsanford@akamai.com \
--cc=thomas@monjalon.net \
/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).