Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate hashing methods #32

Open
object88 opened this issue Jan 7, 2017 · 3 comments
Open

Investigate hashing methods #32

object88 opened this issue Jan 7, 2017 · 3 comments
Labels

Comments

@object88
Copy link
Owner

object88 commented Jan 7, 2017

Current performance for Get is between 2 and 7 times slower than native implementation for maps (depending on map size). There are many possible reasons, including the performance of the hashing mechanism.

The current code uses the built-in FNV32a hash methods, as supplied in the hash package. Using the benchmark tools, we can see that...

for i := 0; i < max; i++ {
  hasher := fnv.New32a()
  binary.Write(hasher, binary.LittleEndian, uint32(i))
  hash32 = hasher.Sum32()
}

...takes about 0.02ns / op, where max is 500,000.

Although it seems that there is little to gain here, we might find some slightly better performance by using a custom hashing mechanism.

@object88
Copy link
Owner Author

object88 commented Jan 7, 2017

On further investigation, after fixing the benchmarking and performing some profiling, it looks like the hashing method may be more at fault than initially presumed. When using the default hash function (FNV32a), the hash function consumed roughly 30% of CPU time.

@object88
Copy link
Owner Author

First release, #36 . Very limited in scope; required custom hashing on all Key types. Need to move to something shared or more generic, reusable.

@object88 object88 added the ready label Jan 18, 2017
@object88
Copy link
Owner Author

Have been pointed to the xxhash library; may be sufficient for hashing needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant