[Wasmtime] Component model: Quenstion about floating point canonicalization #9826
Labels
performance
wasm-proposal:component-model
Issues related to the WebAssembly Component Model proposal
I noticed a significant performance penalty when returning
list<f32>
from WebAssembly components.By overriding/specializing
Lift::load_list
forVec<f32>
(similar to the implementation for integers), I was able to achieve significantly better performance (I will make an issue or PR about this when I find the time).While doing so I wondered whether it is necessary to canonicalize floating point numbers
lift
ed/load
ed from the WebAssembly runtime, as seen here:wasmtime/crates/wasmtime/src/runtime/component/func/typed.rs
Lines 932 to 945 in 128decd
I understand that (in the Component Model)
f32
andf64
logically only have a singleNaN
value.Is it correct that for this reason we must ensure that we only pass the canonical
NaN
to components?Anyways I don't quite understand why this should be necessary for values passed from components to the host, as Rust doesn't really make any promises about the bit patterns of
NaN
.Also, shouldn't all floating point numbers coming from a component already be provided in canonical form, making another canonicalization redundant?
I would be delighted if someone could enlighten me about this.
The text was updated successfully, but these errors were encountered: