Good day, I want to perform profiling on stable data structure libraries in Motoko Language for my research. I would like to ensure that the measurements are valid by asking for your clarification on a number of nuances.
Sorry, this will be quite a mouthful .
Measured parameters:
1) Stable memory usage for different number of elements: I want to use ExperimentalStableMemory.stableVarQuery as Claudio suggested to measure stable memory used:
a) When I run this on an empty canister (without any variables or funcs) - it always shows me value of 9 bytes, should I just subtract 9 from all the next measurements?
b) I tried using it for measuring simple stable variables, when I make an array: âstable var t: [Nat64] = [1, 2, 3, 4];â and then call stableVarQuery, after subtraction of 9 I get 40, regardless of the size of the array (tried adding a lot more elements or initing an empty arr ). Should it not take 8 bytes per each element (are the measurements of stableVarQuery always accurate?). Source Code
2) Heap memory usage for different number of elements: I want to use rts values, as alexeychirkov did to measure heap memory used. I use ââforce-gcâ in compiler args as mentioned here to make gc run at the end of message and ensure correct measurements:
a) I tried using it to measure simple variables, like array: âvar t: [Nat64] = [1, 2, 3, 4];â, but no matter the size of array, it always gives me ârts_heap_size = 44â like in empty canister, should it not be 8 bytes per each element? Source code
b) Is the cycle cost for storing memory on the canister calculated as â({Stable memory used} + {rts_heap_size}) * {cycle cost per byte}â or is it â{rts_memory_size} * {cycle cost per byte}â for all allocated memory as mentioned by rossberg. Just want to clarify, because the answer was in 2022.
3) Cycle cost for calling update functions: I want to use ExperimentalInternetComputer.countInstructions:
a) It says that it does not not account for any deferred garbage collection costs incurred by the function that is measured. If Дhe operations are performed on a stable variable, how can I measure the gc costs? I want to use incremental gc. Maybe we should use {rts_reclaimed}, but what do we multiply it by to obtain cycle cost?