DPDK patches and discussions
 help / color / mirror / Atom feed
From: Xiao Wang <xiao.w.wang@intel.com>
To: olivier.matz@6wind.com
Cc: dev@dpdk.org, arybchenko@solarflare.com,
	Xiao Wang <xiao.w.wang@intel.com>
Subject: [dpdk-dev] [PATCH] mempool: optimize copy in cache get
Date: Tue, 21 May 2019 17:03:21 +0800	[thread overview]
Message-ID: <20190521090321.138062-1-xiao.w.wang@intel.com> (raw)

Use rte_memcpy to improve the pointer array copy. This optimization method
has already been applied to __mempool_generic_put() [1], this patch applies
it to __mempool_generic_get(). Slight performance gain can be observed in
testpmd txonly test.

[1] 863bfb47449 ("mempool: optimize copy in cache")

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
---
 lib/librte_mempool/rte_mempool.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index 8053f7a04..975da8d22 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -1344,15 +1344,11 @@ __mempool_generic_get(struct rte_mempool *mp, void **obj_table,
 		      unsigned int n, struct rte_mempool_cache *cache)
 {
 	int ret;
-	uint32_t index, len;
-	void **cache_objs;
 
 	/* No cache provided or cannot be satisfied from cache */
 	if (unlikely(cache == NULL || n >= cache->size))
 		goto ring_dequeue;
 
-	cache_objs = cache->objs;
-
 	/* Can this be satisfied from the cache? */
 	if (cache->len < n) {
 		/* No. Backfill the cache first, and then fill from it */
@@ -1375,8 +1371,7 @@ __mempool_generic_get(struct rte_mempool *mp, void **obj_table,
 	}
 
 	/* Now fill in the response ... */
-	for (index = 0, len = cache->len - 1; index < n; ++index, len--, obj_table++)
-		*obj_table = cache_objs[len];
+	rte_memcpy(obj_table, &cache->objs[cache->len - n], sizeof(void *) * n);
 
 	cache->len -= n;
 
-- 
2.15.1


             reply	other threads:[~2019-05-21  9:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-21  9:03 Xiao Wang [this message]
2019-05-21  9:34 ` Andrew Rybchenko
2019-07-01 13:11   ` Olivier Matz
2019-07-01 14:21     ` Wang, Xiao W
2019-07-01 15:00       ` Olivier Matz

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=20190521090321.138062-1-xiao.w.wang@intel.com \
    --to=xiao.w.wang@intel.com \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.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).