snarkVM icon indicating copy to clipboard operation
snarkVM copied to clipboard

Fix Arc unwraps in Process::execute

Open ljedrz opened this issue 3 years ago • 3 comments
trafficstars

I'd like to make sure that the Arc used for the execution in Process::execute isn't "leaky".

ljedrz avatar Oct 11 '22 11:10 ljedrz

Nope, looks fine, so we should apply the correct unwrap in order to avoid deep-cloning.

ljedrz avatar Oct 11 '22 12:10 ljedrz

Could you provide a little more context on this change? Would love to learn :)

howardwu avatar Oct 11 '22 22:10 howardwu

Due to the way those values were being taken out of their Arcs, I thought that maybe Arc::try_unwrap was initially failing, and that's why it was not being used. Such failure would mean the existence of more than a single strong reference to the Arc, which would indicate a likely Arc-related memory leak (some strong reference not being dropped) happening somewhere in the execution.

ljedrz avatar Oct 12 '22 08:10 ljedrz

Rebased against testnet3.2.

It should also be noted that switching the deep clones to unwraps makes that operation much faster: it takes it down from ~23µs to ~70ns, which is a 99.7% speedup, which can easily become meaningful when a lot of executions are carried out.

ljedrz avatar Oct 27 '22 10:10 ljedrz

Oddly, I had to add Debug on the Inclusion struct, but not the Execution struct, despite them being similar.

howardwu avatar Nov 03 '22 18:11 howardwu