DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: "wuchangsheng (C)" <wuchangsheng2@huawei.com>
Cc: "anatoly.burakov@intel.com" <anatoly.burakov@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"jiangheng (G)" <jiangheng14@huawei.com>,
	"Yanan (Euler)" <yanan@huawei.com>,
	"Suweifeng (Weifeng, EulerOS)" <suweifeng1@huawei.com>
Subject: Re: [DPDK] heap memory fragmentation issue
Date: Wed, 19 Apr 2023 00:35:31 +0300	[thread overview]
Message-ID: <20230419003531.6f492cce@sovereign> (raw)
In-Reply-To: <ba5b1a9815394b868b3fac8f4e1f3b27@huawei.com>

Hi,

2023-04-12 08:44 (UTC+0000), wuchangsheng (C):
> When using rte_malloc and rte_free to request and release memory repeatedly, the usage of large pages gradually increases.

Do you have a repro?

> Checking the relevant source code shows that memory requests and releases
> are started from the head of the freelist chain list of the heap.
> Memory fragmentation seems to result from this, which is considered because
> the memory recently released may be in the cache, and requesting this
> memory at the time of allocation may achieve higher performance?

Could you please elaborate?
DPDK uses "first fit" algorithm to select the free block,
is that what you mean by "memory fragmentation seems to result from this"?

> How does the community consider the heap's memory fragmentation issue? Is
> there a future plan for memory fragmentation optimization?

From my experience with a production app, fragmentation is indeed an issue.

Unfortunately, fragmentation often happens within a single 1G hugepage.
It is impossible to coalesce free fragments of a hugepage
into a contiguous block, like an OS would do with disjoint pages.

Often the application can move its objects in memory, though.
DPDK could provide means for applications to defragment memory this way.
I don't think DPDK should drive the defragmentation process,
because only the application knows when, which, and how much memory
it is reasonable to move around.
DPDK could provide facilities to analyze memory fragmentation degree
(now possible by tracking objects and inspecting memseg, but hard)
and to allocate memory at the desired range (API missing).

  reply	other threads:[~2023-04-18 21:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-12  8:44 wuchangsheng (C)
2023-04-18 21:35 ` Dmitry Kozlyuk [this message]
2023-04-18 22:43   ` Stephen Hemminger
2023-04-18  2:48 wuchangsheng (C)

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=20230419003531.6f492cce@sovereign \
    --to=dmitry.kozliuk@gmail.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=jiangheng14@huawei.com \
    --cc=suweifeng1@huawei.com \
    --cc=wuchangsheng2@huawei.com \
    --cc=yanan@huawei.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).