Scheduled Txs: Optimise transaction scheduler process
We should optimise the check that is always performed at the begining of process() function to not check the first item in the array, but instead hold the first item in array cached in a variable. This way the loading of array from storage is avoided thus reducing the execution effort used.
https://github.com/onflow/flow-core-contracts/blob/master/contracts/FlowTransactionScheduler.cdc#L483
That might not be easy to do because we can't add fields in upgrades.
@devbugging Can you elaborate on what the issue is? Or have we already addressed it? The code looks like it changed, so the line you link to isn't really relevant any more.
I was thinking of caching the first element in the array in a seperate variable so we don't access a big array, but I'm not sure how much of a performance impact that is in Cadence. https://github.com/onflow/flow-core-contracts/blob/master/contracts/FlowTransactionScheduler.cdc#L517
I don't believe that accessing a single array element is very costly, even if the array is large. I think that copying a large array or iterating through a large array are what is costly. @onflow/cadence Can you confirm?
Also, in order to track that, we would have to use account storage and copy it from storage every time we checked there, which is probably also costly