In the relevant IC documents, I know that the upper limit of IC heap memory is 4GB.
At the same time, I found relevant suggestions in your forum to
“prevent the upgrade from becoming a brick, and the actual use should be controlled within 2GB”
I know that when upgrading ordinary variables, the hooks preupgrade and postupgrade need to be used to convert storage.
However, our code completely uses stable variables to store business data, so there is no need for hook conversion storage during upgrade.
So, in this case, can the storage limit be close to 4G?
In addition, in motoko, should Prim.rts_memory_size() or Prim.rts_heap_size() function be used to determine the current storage amount?
You’re correct, the wasm32 heap memory limit is 4 GiB. The 2 GiB threshold is also relevant if you’re storing your state in the heap. You’ll need sufficient free memory to serialize the state from the heap to stable memory and back.
I’m not a Motoko expert, so perhaps @ggreif or @claudio could provide insights on the second point regarding stable variables and Prim functions.
For Wasm64, the IC currently supports 6 GB and we intend to extend this further to 500 GB in future, to the same capacity as stable memory.
We also plan to make enhanced orthogonal persistence (EOP) the default for Motoko very soon.
The current default, classical persistence only supports maximum 2GB of stable objects (reachable through stable variables). And even then, several data structures (with sharing of immutable objects or structures with long pointer traces) do not scale at all and even crash at a few kilo- or megabytes.
Please let me know if I can provide more information.
Hello, thanks for your reply!
You mean Wasm64/6GB, it is not supported yet, right?
When and what version do we need to wait?
At the same time, can Wasm64 handle more update calls per second?
At present, the rapid growth of our users requires us to pay attention to performance and capacity!
Wasm64 is enabled since Sep 2024, and it has recently been extended to 6GB on mainnet.
I recommend using latest stable dfx 0.25.0 to use the latest fixes and improvements. Motoko’s enhanced orthogonal persistence (EOP) is also available since Sep 2024 and automatically adapts to increased Wasm memory sizes, e.g. extension to 6GB, without the need for any recompilation.
Wasm64 only targets memory scalability, while EOP additionally aims at speeding up upgrades for large canisters. Update call throughput still remains the same due to the actor model of the canister, executing messages only sequentially inside the canister.
There are specific architectures (balancing across multiple canisters, using query calls WITH certification for read-only-intense use cases) that may allow more throughput, however, with the price of extra software complexity.