Hmm, I guess my comment is for code readability. If we don’t need the extra 
state that would be great.

I think "rte_hash" is defined as an internal data structure but expose the type 
to the public header. Would this work?

I propose to malloc inside function mostly because I think it is cleaner to the 
user. But your argument is
valid. Depending on use case I think it is OK.

Another comment is you put the total_entry in the state, is it for performance 
of the rte_hash_iterate?
If you use it to iterate conflict entries, especially If you reuse same "state" 
struct and init it again and again for different keys,
would this slow down the performance for your specific use case? 

Also iterate_conflic_entry may need reader lock protection.

Thanks
Yipeng

>-----Original Message-----
>From: Michel Machado [mailto:mic...@digirati.com.br]
>Sent: Tuesday, September 4, 2018 12:08 PM
>To: Wang, Yipeng1 <yipeng1.w...@intel.com>; Qiaobin Fu <qiaob...@bu.edu>; 
>Richardson, Bruce <bruce.richard...@intel.com>; De
>Lara Guarch, Pablo <pablo.de.lara.gua...@intel.com>
>Cc: dev@dpdk.org; douce...@bu.edu; Wiles, Keith <keith.wi...@intel.com>; 
>Gobriel, Sameh <sameh.gobr...@intel.com>; Tai, Charlie
><charlie....@intel.com>; step...@networkplumber.org; n...@arm.com; 
>honnappa.nagaraha...@arm.com
>Subject: Re: [PATCH v3] hash table: add an iterator over conflicting entries
>
>Hi Yipeng,
>
>On 09/04/2018 02:55 PM, Wang, Yipeng1 wrote:
>> Do we need both of the state and istate struct? struct 
>> rte_hash_iterator_state  seems not doing much.
>> How about we only have one "state" struct and just not expose the internals 
>> to the public API, similar to the
>> rte_hash struct or rte_member_setsum struct.
>> And in _init function use rte_malloc to allocate the state and add a _free 
>> function to free it.
>
>    The purpose of have struct state is to enable applications to
>allocate iterator states on their execution stack or embedding iterator
>states in larger structs to avoid an extra malloc()/free().
>
>    Do you foresee that the upcoming new underlying algorithm of hash
>tables will need to dynamically allocate iterator states?
>
>[ ]'s
>Michel Machado

Reply via email to