facebook / folly

An open-source C++ library developed and used at Facebook.
https://groups.google.com/forum/?fromgroups#!forum/facebook-folly
Apache License 2.0
27.77k stars 5.5k forks source link

Why is F14 worse in performance and memory than std:: unordered_map in WebAssembly #1973

Open runzi opened 1 year ago

runzi commented 1 year ago

1 million data:

----------------------- | insert(ms) | memory(K) | find(ms) | erase(ms) | iterator(ms) std::unordered_map -| 526------ | 37680 | 0 | 0 | 0 std::map-------------- | 1116 ---- | 39062 | 0 | 0 | 0 folly::F14ValueMap---| 535 ----- | 37680 | 0 | 0 | 0 folly::F14NodeMap---| 531 ---- | 37680 | 0 | 0 | 0 folly::F14VectorMap--| 543----- | 37680 | 0 | 0 | 0 folly::F14FastMap---- | 527------ | 37680 | 0 | 0 | 0

10 million data: ----------------------- | insert(ms) | memory(K) | find(ms) | erase(ms) | iterator(ms) std::unordered_map-| 7576----- | 363945 | 0 | 0 | 0 std::map--------------| 20009 ----| 598958 | 0 | 0 | 0 folly::F14ValueMap---| 11579 --- | 598320 | 0 | 0 | 0 folly::F14NodeMap---| 11768----|598320 | 0 | 0 | 0 folly::F14VectorMap--| 11737----| 598320 | 0 | 0 | 0 folly::F14FastMap-----| 11722----| 598320 | 0 | 0 | 0

I compile under the webassembly.

Orvid commented 1 year ago

F14 is designed with the assumption that vectorized instructions are available, and we've made no effort to make it fast in the fallback path when vectorized instructions are not available, so I'm not particularly surprised that it's unusually slow when compiled for webassembly.

skimhugo commented 2 months ago

I think maybe you can try some test by remove sse and avx for compiler parameter.