diff mbox series

trace-cmd: remove ununsed knuth_hash*() routines

Message ID 20190626060101.220607-1-gthelen@google.com (mailing list archive)
State Superseded
Headers show
Series trace-cmd: remove ununsed knuth_hash*() routines | expand

Commit Message

Greg Thelen June 26, 2019, 6:01 a.m. UTC
Neither knuth_hash16() nor knuth_hash() are used.
Delete them.

Signed-off-by: Greg Thelen <gthelen@google.com>
---
 lib/trace-cmd/trace-filter-hash.c | 20 --------------------
 1 file changed, 20 deletions(-)

Comments

Steven Rostedt June 26, 2019, 7:34 p.m. UTC | #1
On Tue, 25 Jun 2019 23:01:01 -0700
Greg Thelen <gthelen@google.com> wrote:

> Neither knuth_hash16() nor knuth_hash() are used.
> Delete them.
> 

Yordan,

Do you foresee that we will be using the other two versions of the hash?

-- Steve

> Signed-off-by: Greg Thelen <gthelen@google.com>
> ---
>  lib/trace-cmd/trace-filter-hash.c | 20 --------------------
>  1 file changed, 20 deletions(-)
> 
> diff --git a/lib/trace-cmd/trace-filter-hash.c b/lib/trace-cmd/trace-filter-hash.c
> index 39b28790e0bc..c56628f69ff0 100644
> --- a/lib/trace-cmd/trace-filter-hash.c
> +++ b/lib/trace-cmd/trace-filter-hash.c
> @@ -29,26 +29,6 @@ static inline uint8_t knuth_hash8(uint32_t val)
>  	return UINT8_C(val) * UINT8_C(157);
>  }
>  
> -static inline uint16_t knuth_hash16(uint32_t val)
> -{
> -	/*
> -	 * Multiplicative hashing function.
> -	 * Multiplication by the Prime number, closest to the golden
> -	 * ratio of 2^16.
> -	 */
> -	return UINT16_C(val) * UINT16_C(40507);
> -}
> -
> -static inline uint32_t knuth_hash(uint32_t val)
> -{
> -	/*
> -	 * Multiplicative hashing function.
> -	 * Multiplication by the Prime number, closest to the golden
> -	 * ratio of 2^32.
> -	 */
> -	return val * UINT32_C(2654435761);
> -}
> -
>  struct tracecmd_filter_id_item *
>  tracecmd_filter_id_find(struct tracecmd_filter_id *hash, int id)
>  {
Yordan Karadzhov June 27, 2019, 3:40 p.m. UTC | #2
On 26.06.19 г. 22:34 ч., Steven Rostedt wrote:
> On Tue, 25 Jun 2019 23:01:01 -0700
> Greg Thelen <gthelen@google.com> wrote:
> 
>> Neither knuth_hash16() nor knuth_hash() are used.
>> Delete them.
>>
> 
> Yordan,
> 
> Do you foresee that we will be using the other two versions of the hash?
> 
> -- Steve
> 

Hi Greg,

Thanks for the fix!

I agree that we have to remove the unused hashing functions, but may I 
ask you to do a little bit of extra work here.
I think that if we are going to keep only one hashing function this 
function can be called simply knuth_has (not knuth_has8).

Also the comment on top which refers to the TAOCP book must be modified 
stating that the original idea from the book (32 bit hash) was adapted 
in order to be used for small tables.

cheers,
Yordan


PS: I just saw couple of new patches coming from you and I want to say 
that your help is more than welcome.



>> Signed-off-by: Greg Thelen <gthelen@google.com>
>> ---
>>   lib/trace-cmd/trace-filter-hash.c | 20 --------------------
>>   1 file changed, 20 deletions(-)
>>
>> diff --git a/lib/trace-cmd/trace-filter-hash.c b/lib/trace-cmd/trace-filter-hash.c
>> index 39b28790e0bc..c56628f69ff0 100644
>> --- a/lib/trace-cmd/trace-filter-hash.c
>> +++ b/lib/trace-cmd/trace-filter-hash.c
>> @@ -29,26 +29,6 @@ static inline uint8_t knuth_hash8(uint32_t val)
>>   	return UINT8_C(val) * UINT8_C(157);
>>   }
>>   
>> -static inline uint16_t knuth_hash16(uint32_t val)
>> -{
>> -	/*
>> -	 * Multiplicative hashing function.
>> -	 * Multiplication by the Prime number, closest to the golden
>> -	 * ratio of 2^16.
>> -	 */
>> -	return UINT16_C(val) * UINT16_C(40507);
>> -}
>> -
>> -static inline uint32_t knuth_hash(uint32_t val)
>> -{
>> -	/*
>> -	 * Multiplicative hashing function.
>> -	 * Multiplication by the Prime number, closest to the golden
>> -	 * ratio of 2^32.
>> -	 */
>> -	return val * UINT32_C(2654435761);
>> -}
>> -
>>   struct tracecmd_filter_id_item *
>>   tracecmd_filter_id_find(struct tracecmd_filter_id *hash, int id)
>>   {
>
Steven Rostedt June 27, 2019, 4:15 p.m. UTC | #3
On Thu, 27 Jun 2019 18:40:27 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:


> Hi Greg,
> 
> Thanks for the fix!
> 
> I agree that we have to remove the unused hashing functions, but may I 
> ask you to do a little bit of extra work here.
> I think that if we are going to keep only one hashing function this 
> function can be called simply knuth_has (not knuth_has8).

Hi Yordan,

Small nit. I think you meant "knuth_hash" not "knuth_has", even though
I'm sure knuth has a lot ;-)

> 
> Also the comment on top which refers to the TAOCP book must be modified 
> stating that the original idea from the book (32 bit hash) was adapted 
> in order to be used for small tables.

Ack.

-- Steve
Greg Thelen June 28, 2019, 3:55 p.m. UTC | #4
On Thu, Jun 27, 2019 at 9:15 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Thu, 27 Jun 2019 18:40:27 +0300
> "Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:
>
>
> > Hi Greg,
> >
> > Thanks for the fix!
> >
> > I agree that we have to remove the unused hashing functions, but may I
> > ask you to do a little bit of extra work here.
> > I think that if we are going to keep only one hashing function this
> > function can be called simply knuth_has (not knuth_has8).
>
> Hi Yordan,
>
> Small nit. I think you meant "knuth_hash" not "knuth_has", even though
> I'm sure knuth has a lot ;-)
>
> >
> > Also the comment on top which refers to the TAOCP book must be modified
> > stating that the original idea from the book (32 bit hash) was adapted
> > in order to be used for small tables.
>
> Ack.
>
> -- Steve

Nod.  I'll make these changes and post a patch in a day or so.
diff mbox series

Patch

diff --git a/lib/trace-cmd/trace-filter-hash.c b/lib/trace-cmd/trace-filter-hash.c
index 39b28790e0bc..c56628f69ff0 100644
--- a/lib/trace-cmd/trace-filter-hash.c
+++ b/lib/trace-cmd/trace-filter-hash.c
@@ -29,26 +29,6 @@  static inline uint8_t knuth_hash8(uint32_t val)
 	return UINT8_C(val) * UINT8_C(157);
 }
 
-static inline uint16_t knuth_hash16(uint32_t val)
-{
-	/*
-	 * Multiplicative hashing function.
-	 * Multiplication by the Prime number, closest to the golden
-	 * ratio of 2^16.
-	 */
-	return UINT16_C(val) * UINT16_C(40507);
-}
-
-static inline uint32_t knuth_hash(uint32_t val)
-{
-	/*
-	 * Multiplicative hashing function.
-	 * Multiplication by the Prime number, closest to the golden
-	 * ratio of 2^32.
-	 */
-	return val * UINT32_C(2654435761);
-}
-
 struct tracecmd_filter_id_item *
 tracecmd_filter_id_find(struct tracecmd_filter_id *hash, int id)
 {