* Question regarding rte_hash_hash and rte_hash_add_key_with_hash_data
@ 2025-06-07 19:06 venkatesh bs
2025-06-08 15:47 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: venkatesh bs @ 2025-06-07 19:06 UTC (permalink / raw)
To: dev
[-- Attachment #1: Type: text/plain, Size: 1093 bytes --]
Hi @dpdk community,
In my application, I am using the dpdk hash table as below.
1. calculate the hash value.
2. using this signature add the key and data into a table.
3. lock is used in the 2nd call (add).
Below is the code sniffer for the same.
==================================================================
hash_sig_t sig = rte_hash_hash(hash_tablele, (void *) &new_key);
pthread_mutex_lock(&lock);
int32_t ret = rte_hash_add_key_with_hash_data(hash_table,
(void *)&new_key,
sig,
info);
if (ret < 0)
{
pthread_mutex_unlock(lock);
return TOS_E_FAIL;
}
pthread_mutex_unlock(lock);
return OK..
==================================================================
My application is having a lot of threads and when run with heavy load , I
am getting a lot of insertion failure, i felt the reason could be
calculating and adding the has value in 2 api's as opposed to
rte_hash_add() that is safe under a lock..
Please let me know your thoughts.
Thank you,
Venkatesh.
[-- Attachment #2: Type: text/html, Size: 1574 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question regarding rte_hash_hash and rte_hash_add_key_with_hash_data
2025-06-07 19:06 Question regarding rte_hash_hash and rte_hash_add_key_with_hash_data venkatesh bs
@ 2025-06-08 15:47 ` Stephen Hemminger
2025-06-10 6:49 ` venkatesh bs
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2025-06-08 15:47 UTC (permalink / raw)
To: venkatesh bs; +Cc: dev
On Sun, 8 Jun 2025 00:36:02 +0530
venkatesh bs <venki.bsv@gmail.com> wrote:
> Hi @dpdk community,
>
> In my application, I am using the dpdk hash table as below.
>
> 1. calculate the hash value.
> 2. using this signature add the key and data into a table.
> 3. lock is used in the 2nd call (add).
>
> Below is the code sniffer for the same.
> ==================================================================
> hash_sig_t sig = rte_hash_hash(hash_tablele, (void *) &new_key);
>
> pthread_mutex_lock(&lock);
> int32_t ret = rte_hash_add_key_with_hash_data(hash_table,
> (void *)&new_key,
> sig,
> info);
>
> if (ret < 0)
> {
> pthread_mutex_unlock(lock);
> return TOS_E_FAIL;
> }
> pthread_mutex_unlock(lock);
>
> return OK..
> ==================================================================
>
> My application is having a lot of threads and when run with heavy load , I
> am getting a lot of insertion failure, i felt the reason could be
> calculating and adding the has value in 2 api's as opposed to
> rte_hash_add() that is safe under a lock..
>
>
> Please let me know your thoughts.
Which architecture and DPDK version?
What flags did you use during hash creation?
As always with open source, the first thing to do is look at the source
and see what is really happening, rather than just relying on the documentation.
I assume you are using the default hash function which is CRC.
First what is the return value, which error?
It might just be key collisions. How big is the table and how many inserts?
Also, the current DPDK hash flags with better locking and RCU.
This would be faster than simple pthread mutex.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Question regarding rte_hash_hash and rte_hash_add_key_with_hash_data
2025-06-08 15:47 ` Stephen Hemminger
@ 2025-06-10 6:49 ` venkatesh bs
0 siblings, 0 replies; 3+ messages in thread
From: venkatesh bs @ 2025-06-10 6:49 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
[-- Attachment #1: Type: text/plain, Size: 3514 bytes --]
Hi @Stephen Hemminger <stephen@networkplumber.org> ,
Thanks for the reply , please find the details below.
DPDK version : 20.11.6
#define LOADBAL_HASH_ENTRIES_MAX (1024*1024*36)
#define LOADBAL_HASH_TABLE_SIZE_MULTIPLIER 2
hashSizeMultiplier = LOADBAL_HASH_TABLE_SIZE_MULTIPLIER;
struct rte_hash_parameters loadbal_hash_params = {
.name = NULL,
.entries = LOADBAL_HASH_ENTRIES_MAX * hashSizeMultiplier,
.key_len = sizeof(flow_key_t),
.hash_func = app_hash_crc(internally it calls
rte_hash_crc_4byte for v4/v6)
.hash_func_init_val = 0,
};
First, what is the return value, which error?
we captured only the return value, and will check what error it is
returning.
IPv4 Load-Bal Flow hash table:
numInsertions: 998214247
numInsertionsFailures: 4252
numRemovals: 997197485
numRemovalFailures: 214902
numObjects: 1016762
NumBuckets: 75497472
TableCapacity: 75497472
LoadFactor: 1%
NumLookupSuccess: 389165605
NumLookupFails: 2704814006
Failure Analysis:
TableFull(>=95%): 0
HighLoad(75-95%): 0
MediumLoad(50-75%): 0
LowLoad(<50%): 4252
We are try to analyze the code and find out the details,
Initially there will be no issues, insertion starts failing after 24 HRS or
so.
Thanks,
Venkatesh.
On Sun, Jun 8, 2025 at 9:17 PM Stephen Hemminger <stephen@networkplumber.org>
wrote:
> On Sun, 8 Jun 2025 00:36:02 +0530
> venkatesh bs <venki.bsv@gmail.com> wrote:
>
> > Hi @dpdk community,
> >
> > In my application, I am using the dpdk hash table as below.
> >
> > 1. calculate the hash value.
> > 2. using this signature add the key and data into a table.
> > 3. lock is used in the 2nd call (add).
> >
> > Below is the code sniffer for the same.
> > ==================================================================
> > hash_sig_t sig = rte_hash_hash(hash_tablele, (void *) &new_key);
> >
> > pthread_mutex_lock(&lock);
> > int32_t ret = rte_hash_add_key_with_hash_data(hash_table,
> > (void *)&new_key,
> > sig,
> > info);
> >
> > if (ret < 0)
> > {
> > pthread_mutex_unlock(lock);
> > return TOS_E_FAIL;
> > }
> > pthread_mutex_unlock(lock);
> >
> > return OK..
> > ==================================================================
> >
> > My application is having a lot of threads and when run with heavy load ,
> I
> > am getting a lot of insertion failure, i felt the reason could be
> > calculating and adding the has value in 2 api's as opposed to
> > rte_hash_add() that is safe under a lock..
> >
> >
> > Please let me know your thoughts.
>
> Which architecture and DPDK version?
> What flags did you use during hash creation?
>
> As always with open source, the first thing to do is look at the source
> and see what is really happening, rather than just relying on the
> documentation.
>
> I assume you are using the default hash function which is CRC.
>
> First what is the return value, which error?
> It might just be key collisions. How big is the table and how many inserts?
>
> Also, the current DPDK hash flags with better locking and RCU.
> This would be faster than simple pthread mutex.
>
>
[-- Attachment #2: Type: text/html, Size: 4618 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-10 6:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-07 19:06 Question regarding rte_hash_hash and rte_hash_add_key_with_hash_data venkatesh bs
2025-06-08 15:47 ` Stephen Hemminger
2025-06-10 6:49 ` venkatesh bs
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).