Using Pocket-ic for cycle usage forecast

Hi devs,

I want to know how accurately can PocketIC simulate and measure cycle consumption for the following scenarios on the Internet Computer:

  1. Inter-canister calls — both same-subnet and cross-subnet communication
  2. Storage costs — cycles burned for heap and stable memory usage
  3. Execution costs — Business logic

Specifically, I want to understand:

  • Does PocketIC reflect real mainnet cycle costs, or are there known discrepancies?
  • Are there any limitations or caveats when using PocketIC as a cost estimation tool compared to deploying on mainnet?

While PocketIC does its best to be as close to mainnet as possible I’m not sure how well it works for storage costs. The reason for this is that time doesn’t work like normal for PocketIC - you can fast-forward, you can manually control when time moves, and in general it mostly only does work when there is work to do AFAIK. On mainnet storage costs are charged every n second (was it 10? 30? or rounds? don’t remember…) and I’m not sure PocketIC runs such a process. For storage cost specifically I would suggest you measure your memory footprint every so often and then multiply from the cost table.

Execution and canister call costs should be exactly as mainnet, as long as you are on the same subnet type. But if you want things very precisely and maybe even benchmark critical sections, I would suggest canbench as it was created specifically to measure that

1 Like

Correct me if I’m wrong

Because there is no consensus required for pocket-ic the cycle cost will calculate equivalent to 1 node in subnet.

If it was the actual replica running then it would indeed find no other nodes in the subnet and charge the same as a 1-node subnet (same as dfx previously did). But PocketIC is bypassing consensus and therefore can set the numbers same as they would be on mainnet. You can even run subnets with the costs of the fiduciary subnet in PocketIC

1 Like