DPDK patches and discussions
 help / color / mirror / Atom feed
From: Liang Ma <liangma@liangbit.com>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: Thomas Monjalon <thomas@monjalon.net>,
	anatoly.burakov@intel.com,
	Fengnan Chang <changfengnan@bytedance.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: [PATCH] malloc: fix malloc performance may becomes worse as the number of malloc increases
Date: Thu, 16 Feb 2023 14:02:07 +0000	[thread overview]
Message-ID: <Y+43X2Vxpcga7bRE@C02GF04TMD6V> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D8773F@smartserver.smartshare.dk>

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. 

> 


  parent reply	other threads:[~2023-02-16 14:04 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 [this message]
2023-02-17  2:14       ` Fengnan Chang
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=Y+43X2Vxpcga7bRE@C02GF04TMD6V \
    --to=liangma@liangbit.com \
    --cc=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=changfengnan@bytedance.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=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).