Canister interfaces · PocketIC
What do 20 update methods cost?
Three canisters implement the same 20 updates, from acknowledging a transfer record to returning a 1 MiB blob. Compare how much Wasm each build deploys and how many instructions it spends processing the same inputs.
What each build uses
The DFINITY canister uses the standard typed update handlers from ic-cdk 0.20.3 with stock Candid 0.10.38 on Wasm32. All three are optimized release builds. “Stock” identifies the unmodified Candid library from crates.io.
The two RSX builds use the same SDK on Wasm64. One uses RSX’s optimized Candid 0.10.38 fork and the other uses Toko Studios’ IC Wire 0.7.21. Comparing those two holds the runtime and target constant. Comparing either with DFINITY also includes the differences in CDK, entry code and Wasm target.
Wasm size in uncompressed bytes
How much space did the API add? The empty RSX actor compiled to 196,561 bytes. With the same 20 updates, optimized Candid added 538,110 bytes and IC Wire added 92,812. That is 82.8% less added Wasm with IC Wire. The difference includes the handlers, the codec code they use and their interface metadata. Original size measurements
The deployable size includes code, data and module metadata. The second row isolates executable code. All three modules retain their name section.
| Bytes | DFINITY ic-cdk · stock Candid | RSX · optimized Candid | RSX · IC Wire |
|---|---|---|---|
| Deployable module | 775,955 | 734,671 | 289,373 |
| Executable code section | 609,203 | 527,578 | 197,717 |
Including the shared RSX runtime, the IC Wire module was 60.6% smaller than the optimized-Candid module. Against stock Candid on DFINITY ic-cdk, the whole-module reduction was 62.7%.
Instructions per complete update
RSX with IC Wire used the fewest instructions in 17 of the 20 updates. Stock Candid on DFINITY ic-cdk was the lowest for processing 512 packed records and for generating and returning the 64 KiB and 1 MiB blobs.
Each value is the average of eight steady calls on the same PocketIC build, rounded to the nearest whole instruction. It includes entry, request decoding, the work inside the method, reply encoding and memory-page charges. Each call’s response was checked against the fixture’s expected result.
| Update | DFINITY ic-cdk · stock Candid | RSX · optimized Candid | RSX · IC Wire |
|---|---|---|---|
| Increment u64 | 495,790 | 493,981 | 164,790 |
| Transfer record → acknowledgement | 539,306 | 506,658 | 166,266 |
| Transform 32-byte digest | 537,851 | 511,242 | 171,824 |
| Short UTF-8 text echo | 498,506 | 498,233 | 328,025 |
| Read/checksum 8 KiB text | 629,548 | 608,583 | 437,998 |
| Read/checksum 32 KiB blob | 1,072,469 | 1,352,113 | 1,009,938 |
| Read/checksum entire 1 MiB blob | 17,214,197 | 17,490,261 | 17,152,754 |
| Reject 1 MiB request using header | 8,819,412 | 8,043,552 | 7,705,781 |
| Read only 256 bytes from 1 MiB | 8,820,090 | 8,046,868 | 7,709,293 |
| Read 4 KiB from three 256 KiB fields | 6,802,516 | 6,302,371 | 5,950,841 |
| Read profile/name/bio; skip 256 KiB avatar | 2,751,313 | 2,751,875 | 2,563,821 |
| Reject profile using header | 2,677,993 | 2,666,451 | 2,487,144 |
| Process 512 packed records | 740,341 | 1,021,502 | 836,799 |
| Reject 4,096-record request using count | 1,589,577 | 1,728,282 | 1,390,541 |
| Generate/return 32-byte blob | 514,160 | 498,383 | 328,149 |
| Generate/return 4 KiB text | 808,731 | 834,423 | 660,370 |
| Generate/return 64 KiB blob | 4,769,795 | 5,679,578 | 4,964,716 |
| Generate/return 1 MiB blob | 68,617,674 | 76,224,507 | 72,126,557 |
| Echo 32 KiB blob | 2,670,345 | 2,758,713 | 2,386,079 |
| Echo 256 KiB blob | 17,526,026 | 16,420,548 | 15,663,007 |
How small is a standalone codec example?
Toko Studios measured a standalone program that encodes and decodes lists of up to 4,096 unsigned integers. These are whole Wasm sizes for the ordinary Rust vector (Vec<u32>) under two compiler settings. Toko Studios’ numeric-list benchmark
| Compiler setting | Candid bytes | IC Wire bytes | Size reduction |
|---|---|---|---|
| Optimize for size (opt-z) | 259,180 | 21,592 | 91.7% |
| Optimize for speed (opt-3) | 358,649 | 23,172 | 93.5% |
Measurements and reproduction
The RSX measurements come from the original run on PocketIC 16.1.0. We ran the stock DFINITY build twice on fresh installations of the same simulator. In each run, all 180 request and reply payloads matched the archived optimized-Candid run byte for byte. Both stock runs returned the same instruction counts.
These methods exercise request and reply handling on a canister with no populated application data. The transfer method computes an acknowledgement in memory.