hyperjson icon indicating copy to clipboard operation
hyperjson copied to clipboard

Use fnv hasher

Open greyblake opened this issue 7 years ago • 2 comments

Hey, I just watched your talk and you mentioned there, that you use BTreeMap and I thought I can try to contribute to make it a little bit faster.

This PR replaces BTreeMap with HashMap with fnv hasher. As far as I know it's probably the fastest available HashMap option in Rust world. Once I improved speed of whatlang by ~30% just replacing standard (default) HashMap hasher with fnv.

Regarding benchmarks: it looks like most of them got better, but some got worse. Please double check yourself if the change really makes sense.

Also if you have particular reasons to prefer BTreeMap instead of HashMap (e.g. you care about order), please feel free to reject this PR. But if so you have to reflect this fact in your tests, because they're still green ;)

greyblake avatar Sep 21 '18 18:09 greyblake

@mre Haha, you mentioned this PR today, but it never got merged :)

greyblake avatar Mar 05 '21 21:03 greyblake

Oh yeah. I think the reason is that I never got around to benchmarking the change myself. If there is no noticeable perf-improvement I'd opt for keeping the BTreeMap impl as it's part of std, so we have one less "third-party dependency". Then again the project is not very active anymore anyway and https://github.com/ijl/orjson is very likely the better choice for new projects. So perhaps we want to close the PR?

mre avatar Mar 25 '21 12:03 mre