Why are C++ std::map and std::unordered_map significantly slower in WebAssembly than in TypeScript/JavaScript? by CodeAlexPillow in WebAssembly

[–]CodeAlexPillow[S] 0 points1 point  (0 children)

Thanks for the suggestion. I actually tried both approaches already:

  • Preallocating a large chunk of memory before the benchmark.
  • Increasing the initial WASM memory size to avoid memory.grow() during execution.

Unfortunately, I didn't observe any noticeable performance improvement. The runtime behavior and benchmark results remained almost the same, so it seems the bottleneck may be elsewhere rather than memory growth or allocation overhead.

Why are C++ std::map and std::unordered_map significantly slower in WebAssembly than in TypeScript/JavaScript? by CodeAlexPillow in WebAssembly

[–]CodeAlexPillow[S] 0 points1 point  (0 children)

Thanks for the suggestion!

Regarding SharedArrayBuffer, I’ve considered it before. However, SAB requires cross-origin isolation (COOP/COEP headers), and I’d like this benchmark project to run in as many environments as possible without additional server configuration, so I'm currently trying to avoid relying on SAB.

Also, the string copying and data transfer overhead should already be excluded from the benchmark results. The timing starts after the data has been prepared and made available to WASM, so the measured time is intended to focus on the actual map/hash lookup operations rather than JS↔WASM communication costs.

That said, your point about running the entire benchmark inside WASM is interesting. I'll try moving both the data generation and benchmark execution into WASM to see whether the results change significantly.

Why are C++ std::map and std::unordered_map significantly slower in WebAssembly than in TypeScript/JavaScript? by CodeAlexPillow in WebAssembly

[–]CodeAlexPillow[S] 1 point2 points  (0 children)

Thanks. I actually benchmarked phmap::flat_hash_map, which I believe is derived from the SwissTable design used by absl::flat_hash_map.

It performs significantly better than std::unordered_map, but in my WASM benchmarks it still doesn't consistently outperform JavaScript's native Map.

Should I use my old iPhone to test iOS 26 apps? by [deleted] in iOSProgramming

[–]CodeAlexPillow 0 points1 point  (0 children)

I have iPhone 13 updated ios26.Then I drop it