Until the Internet Computer refines the instruction counting, the fastest way to do memcpy is to copy to stable memory and then again from.
Motoko doesn’t use stable memory during normal execution, so we can use it as scratch space.
We should measure how large a memcpy needs to be to make going via stable memory cheaper, and then use that in memcpy_bytes in src/mem.rs. We need to be careful to not use it in pre_upgrade and post_upgrade.
Best put behind a flag so that developers can opt-out so that when instruction counting is refined, they don’t have to wait for a motoko upgrade.
Until the Internet Computer refines the instruction counting, the fastest way to do
memcpy
is to copy to stable memory and then again from.Motoko doesn’t use stable memory during normal execution, so we can use it as scratch space.
We should measure how large a
memcpy
needs to be to make going via stable memory cheaper, and then use that inmemcpy_bytes
insrc/mem.rs
. We need to be careful to not use it in pre_upgrade and post_upgrade.Best put behind a flag so that developers can opt-out so that when instruction counting is refined, they don’t have to wait for a motoko upgrade.