DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] hash: optimize the softrss computation
@ 2017-08-22 12:02 Yangchao Zhou
  2017-08-22 15:57 ` Vladimir Medvedkin
  0 siblings, 1 reply; 4+ messages in thread
From: Yangchao Zhou @ 2017-08-22 12:02 UTC (permalink / raw)
  To: dev

Use rte_bsf32 and fast bit unset operation to optimize the softrss computation.
The following measurements shows improvement over the default
softrss computation function.

tuple lens old(cycles) new(cycles)
    3        1225         337
    9        3743         992

Signed-off-by: Yangchao Zhou <zhouyates@gmail.com>
---
 lib/librte_hash/rte_thash.h | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/lib/librte_hash/rte_thash.h b/lib/librte_hash/rte_thash.h
index 2fffd61..4fa5e07 100644
--- a/lib/librte_hash/rte_thash.h
+++ b/lib/librte_hash/rte_thash.h
@@ -207,15 +207,14 @@ static inline uint32_t
 rte_softrss(uint32_t *input_tuple, uint32_t input_len,
 		const uint8_t *rss_key)
 {
-	uint32_t i, j, ret = 0;
+	uint32_t i, j, map, ret = 0;
 
 	for (j = 0; j < input_len; j++) {
-		for (i = 0; i < 32; i++) {
-			if (input_tuple[j] & (1 << (31 - i))) {
-				ret ^= rte_cpu_to_be_32(((const uint32_t *)rss_key)[j]) << i |
+		for (map = input_tuple[j]; map;	map &= (map - 1)) {
+			i = rte_bsf32(map);
+			ret ^= rte_cpu_to_be_32(((const uint32_t *)rss_key)[j]) << (31 - i) |
 					(uint32_t)((uint64_t)(rte_cpu_to_be_32(((const uint32_t *)rss_key)[j + 1])) >>
-					(32 - i));
-			}
+					(i + 1));
 		}
 	}
 	return ret;
@@ -238,14 +237,13 @@ static inline uint32_t
 rte_softrss_be(uint32_t *input_tuple, uint32_t input_len,
 		const uint8_t *rss_key)
 {
-	uint32_t i, j, ret = 0;
+	uint32_t i, j, map, ret = 0;
 
 	for (j = 0; j < input_len; j++) {
-		for (i = 0; i < 32; i++) {
-			if (input_tuple[j] & (1 << (31 - i))) {
-				ret ^= ((const uint32_t *)rss_key)[j] << i |
-					(uint32_t)((uint64_t)(((const uint32_t *)rss_key)[j + 1]) >> (32 - i));
-			}
+		for (map = input_tuple[j]; map;	map &= (map - 1)) {
+			i = rte_bsf32(map);
+			ret ^= ((const uint32_t *)rss_key)[j] << (31 - i) |
+				(uint32_t)((uint64_t)(((const uint32_t *)rss_key)[j + 1]) >> (i + 1));
 		}
 	}
 	return ret;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] hash: optimize the softrss computation
  2017-08-22 12:02 [dpdk-dev] [PATCH] hash: optimize the softrss computation Yangchao Zhou
@ 2017-08-22 15:57 ` Vladimir Medvedkin
  2017-09-22 15:33   ` De Lara Guarch, Pablo
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Medvedkin @ 2017-08-22 15:57 UTC (permalink / raw)
  To: Yangchao Zhou; +Cc: dev

Hi,

2017-08-22 15:02 GMT+03:00 Yangchao Zhou <zhouyates@gmail.com>:

> Use rte_bsf32 and fast bit unset operation to optimize the softrss
> computation.
> The following measurements shows improvement over the default
> softrss computation function.
>
> tuple lens old(cycles) new(cycles)
>     3        1225         337
>     9        3743         992
>
> Signed-off-by: Yangchao Zhou <zhouyates@gmail.com>
> ---
>  lib/librte_hash/rte_thash.h | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/lib/librte_hash/rte_thash.h b/lib/librte_hash/rte_thash.h
> index 2fffd61..4fa5e07 100644
> --- a/lib/librte_hash/rte_thash.h
> +++ b/lib/librte_hash/rte_thash.h
> @@ -207,15 +207,14 @@ static inline uint32_t
>  rte_softrss(uint32_t *input_tuple, uint32_t input_len,
>                 const uint8_t *rss_key)
>  {
> -       uint32_t i, j, ret = 0;
> +       uint32_t i, j, map, ret = 0;
>
>         for (j = 0; j < input_len; j++) {
> -               for (i = 0; i < 32; i++) {
> -                       if (input_tuple[j] & (1 << (31 - i))) {
> -                               ret ^= rte_cpu_to_be_32(((const uint32_t
> *)rss_key)[j]) << i |
> +               for (map = input_tuple[j]; map; map &= (map - 1)) {
> +                       i = rte_bsf32(map);
> +                       ret ^= rte_cpu_to_be_32(((const uint32_t
> *)rss_key)[j]) << (31 - i) |
>                                         (uint32_t)((uint64_t)(rte_cpu_to_be_32(((const
> uint32_t *)rss_key)[j + 1])) >>
> -                                       (32 - i));
> -                       }
> +                                       (i + 1));
>                 }
>         }
>         return ret;
> @@ -238,14 +237,13 @@ static inline uint32_t
>  rte_softrss_be(uint32_t *input_tuple, uint32_t input_len,
>                 const uint8_t *rss_key)
>  {
> -       uint32_t i, j, ret = 0;
> +       uint32_t i, j, map, ret = 0;
>
>         for (j = 0; j < input_len; j++) {
> -               for (i = 0; i < 32; i++) {
> -                       if (input_tuple[j] & (1 << (31 - i))) {
> -                               ret ^= ((const uint32_t *)rss_key)[j] << i
> |
> -                                       (uint32_t)((uint64_t)(((const
> uint32_t *)rss_key)[j + 1]) >> (32 - i));
> -                       }
> +               for (map = input_tuple[j]; map; map &= (map - 1)) {
> +                       i = rte_bsf32(map);
> +                       ret ^= ((const uint32_t *)rss_key)[j] << (31 - i) |
> +                               (uint32_t)((uint64_t)(((const uint32_t
> *)rss_key)[j + 1]) >> (i + 1));
>                 }
>         }
>         return ret;
> --
> 2.7.4
>
>
Looks good for me. Thanks!

Reviewed-by:  Medvedkin Vladimir <medvedkinv@gmail.com>

-- 
Regards,
Vladimir

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] hash: optimize the softrss computation
  2017-08-22 15:57 ` Vladimir Medvedkin
@ 2017-09-22 15:33   ` De Lara Guarch, Pablo
  2017-10-06 22:31     ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: De Lara Guarch, Pablo @ 2017-09-22 15:33 UTC (permalink / raw)
  To: Vladimir Medvedkin, Yangchao Zhou; +Cc: dev

Hi,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Vladimir
> Medvedkin
> Sent: Tuesday, August 22, 2017 4:57 PM
> To: Yangchao Zhou <zhouyates@gmail.com>
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] hash: optimize the softrss computation
> 
> Hi,
> 
> 2017-08-22 15:02 GMT+03:00 Yangchao Zhou <zhouyates@gmail.com>:
> 
> > Use rte_bsf32 and fast bit unset operation to optimize the softrss
> > computation.
> > The following measurements shows improvement over the default softrss
> > computation function.
> >
> > tuple lens old(cycles) new(cycles)
> >     3        1225         337
> >     9        3743         992
> >
> > Signed-off-by: Yangchao Zhou <zhouyates@gmail.com>

Commit message is a bit long. Could you wrap it to have less than 75 characters per line?
Although, the patch itself has lines with more than 90 characters, which should be avoided:

http://dpdk.org/ml/archives/test-report/2017-August/027283.html

Last thing, the "Reviewed-by" has an extra space, before the name.

Thanks,
Pablo

> >
> Looks good for me. Thanks!
> 
> Reviewed-by:  Medvedkin Vladimir <medvedkinv@gmail.com>
> 
> --
> Regards,
> Vladimir

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] hash: optimize the softrss computation
  2017-09-22 15:33   ` De Lara Guarch, Pablo
@ 2017-10-06 22:31     ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2017-10-06 22:31 UTC (permalink / raw)
  To: Yangchao Zhou; +Cc: dev, De Lara Guarch, Pablo, Vladimir Medvedkin

22/09/2017 17:33, De Lara Guarch, Pablo:
> From: Vladimir Medvedkin
> > 2017-08-22 15:02 GMT+03:00 Yangchao Zhou <zhouyates@gmail.com>:
> > 
> > > Use rte_bsf32 and fast bit unset operation to optimize the softrss
> > > computation.
> > > The following measurements shows improvement over the default softrss
> > > computation function.
> > >
> > > tuple lens old(cycles) new(cycles)
> > >     3        1225         337
> > >     9        3743         992
> > >
> > > Signed-off-by: Yangchao Zhou <zhouyates@gmail.com>
> 
> Commit message is a bit long. Could you wrap it to have less than 75 characters per line?
> Although, the patch itself has lines with more than 90 characters, which should be avoided:
> 
> http://dpdk.org/ml/archives/test-report/2017-August/027283.html
> 
> Last thing, the "Reviewed-by" has an extra space, before the name.

Applied, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-10-06 22:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-22 12:02 [dpdk-dev] [PATCH] hash: optimize the softrss computation Yangchao Zhou
2017-08-22 15:57 ` Vladimir Medvedkin
2017-09-22 15:33   ` De Lara Guarch, Pablo
2017-10-06 22:31     ` Thomas Monjalon

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).