How can Rust be slower than JavaScript?

I understand it’s a weird question to ask, but I am puzzled by this issue I have. I wrote two functions, one in JavaScript, one in Rust (with the intention of using it via WASM). I cannot share code, but, basically, it’s an implementation of the LTTB algorithm. Very basic approach, Float32Array in JS, [f32] and Vec with initial capacity set in Rust (so no push), no extra data structures, pretty straightforward math stuff. All in all a 1:1 code.

When I run the code against 20M points, I get around

120ms in JavaScript

but…

150ms in Rust

And it pretty much stays like that for any data, for example, on 70M points, Rust=520ms, JS=370ms

Note: I am measuring the exact duration of the LTTB algorithm inside Rust, not the overhead added by the Rust->JS data transfer.

Rust is compiled with

[profile.release]
codegen-units = 1
lto = "fat"
panic = "abort"
strip = "debuginfo"

I would have been ok with a tie, but the fact that JS is faster seems fishy to me.

Any insights would be greatly appreciated. Thanks!