question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Thoughts on hashing optimizations

See original GitHub issue

Your hasing function looks like the hashCode algorhythm. That correct?

Hypothetically

Would you be willing to have any dependencies? Would you be willing to have different dependencies for the npm/node.js version?

  • murmurhash3 (pure javascript) is about 140% as fast as hashCode.
  • cityhash (c++ node.js module) is about 280% as fast as hashCode

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
kofrasacommented, Dec 2, 2020

Hi Ben,

I think your request sounds reasonable. Different use cases may need different hashing guarantees.

I will take a look at the PR soon.

Regards, Francis

On Mon, Nov 30, 2020 at 6:25 PM Benjamin DANIEL notifications@github.com wrote:

Here a fork to avoid hash collision, but loosing performances : https://github.com/BenjD90/mingo

Here an exemple of processing error that it avoid :

import mingo from ‘mingo’ const collection = [ { “codes”: [“KNE_OC42-midas”] }, { “codes”: [“KNE_OCS3-midas”] }]; const criteria = { “codes”: { “$in”: [“KNE_OCS3-midas”] }}; console.log(---- START ----); let query = new mingo.Query(criteria)const cursor = query.find(collection) // print all match, should match only the 2ndwhile (cursor.hasNext()) { console.log(cursor.next())} console.log(---- END ----) /* Output :---- START ----{ codes: [ ‘KNE_OC42-midas’ ] }{ codes: [ ‘KNE_OCS3-midas’ ] }---- END ----*/

I’ll try do make de PR soon, to allow user to give it’s own hash function, and tell it in the documentation.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kofrasa/mingo/issues/62#issuecomment-735891543, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHF7EPQHIKYLBYGFUDC6CLSSPBPHANCNFSM4DZ2RXRA .

1reaction
kofrasacommented, Sep 15, 2017

After some tweaks and a few more runs, it turns out the XOR version of the djb2 algorithm provides better performance per collision. [UPDATE] hashCode still performs better

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optimizing a Hashing Strategy - DZone
Overview. The strategy that's used for hashing keys can have a direct impact on the performance of a hashed collection such as a...
Read more >
Optimizing Hashing Algorithms - LearnHowToProgram.com
A good hashing algorithm needs to evenly distribute key-value pairs into buckets, resulting in as few collisions as possible. We may end up...
Read more >
Optimization Part III: Better Hash Tables - Colin's Notes
How about looking for more efficient implementations of standard data structures in libraries? Optimizing C++ Applications With Better Hash ...
Read more >
A Study on the Optimization of Blockchain Hashing Algorithm ...
This paper proposes an optimization scheme of blockchain hashing algorithm based on PRCA.
Read more >
How should I go about optimizing a hash table for a given ...
Show activity on this post. I would make sure that your key's hash to unique values. This will ensure that every lookup will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found