o1js
o1js copied to clipboard
Memory leak of 150MB per proof
Reported on discord:
https://discord.com/channels/484437221055922177/1168969852296376461/1169230889058848778
It was tested using the code in https://github.com/dfstio/minanft-lib/blob/large-contract/test/nftupdate.test.ts; one can clone the branch large-contract of the repo and run
yarn test nftupdate.test
The last message before the process hung was:
console.log
Sending update...
at MinaNFT.commit (src/minanft.ts:411:13)
console.log
{
rss: '6580.5 MB -> Resident Set Size - total memory allocated for the process execution',
heapTotal: '940.09 MB -> total size of the allocated heap',
heapUsed: '882.47 MB -> actual memory used during the execution',
external: '47.01 MB -> V8 external memory'
}
at memory (test/nftupdate.test.ts:232:11)
console.log
Updating, iteration 17...
at Object.<anonymous> (test/nftupdate.test.ts:169:15)
console.log
Creating proofs...
at MinaNFT.generateProof (src/minanft.ts:475:13)
On the first iterations, the RSS is 4444 MB:
console.log
Updating, iteration 2...
at Object.<anonymous> (test/nftupdate.test.ts:169:15)
console.log
Creating proofs...
at MinaNFT.generateProof (src/minanft.ts:475:13)
console.time
Proofs created: 95195 ms
at MinaNFT.generateProof (src/minanft.ts:504:13)
console.log
Commiting updates to blockchain...
at MinaNFT.commit (src/minanft.ts:388:13)
console.log
Sending update...
at MinaNFT.commit (src/minanft.ts:411:13)
console.log
{
rss: '4444.42 MB -> Resident Set Size - total memory allocated for the process execution',
heapTotal: '1119.06 MB -> total size of the allocated heap',
heapUsed: '1075.65 MB -> actual memory used during the execution',
external: '63.84 MB -> V8 external memory'
}
at memory (test/nftupdate.test.ts:232:11)
console.log
Updating, iteration 3...
My last tests with o1js 0.17.0 show that the prover hangs out after the garbage collection cycle, decreasing the use of RSS memory by more than 300 MB.
For example, when RSS memory goes from 7402 MB to 7056 MB, it usually means that the prover will hang out soon, although if RSS memory is about 7000 MB and there is no garbage collection decreasing the use of RSS memory, the prover will work as expected.
I think this is quite a valuable issue to keep!