Closed andiflabs closed 2 weeks ago
These are the results I got -
on staging
Command being timed: "node --expose-gc --inspect=:0 --inspect-publish-uid=http --enable-source-maps bin/run wallet:rescan -d /Users/patni/.if0"
User time (seconds): 1.43
System time (seconds): 0.23
Percent of CPU this job got: 23%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:07.25
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 158400
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 4
Minor (reclaiming a frame) page faults: 10470
Voluntary context switches: 2219
Involuntary context switches: 23857
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 1
Socket messages received: 10391
Signals delivered: 0
Page size (bytes): 16384
Exit status: 0
On your branch:
Command being timed: "node --expose-gc --inspect=:0 --inspect-publish-uid=http --enable-source-maps bin/run wallet:rescan -d /Users/patni/.if0"
User time (seconds): 1.34
System time (seconds): 0.23
Percent of CPU this job got: 20%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:07.67
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 156864
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 4
Minor (reclaiming a frame) page faults: 10380
Voluntary context switches: 1939
Involuntary context switches: 26888
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 1
Socket messages received: 10403
Signals delivered: 9
Page size (bytes): 16384
Exit status: 0
I see a slight reduction. I am running my own devnet with around 10k blocks.
I see a slight reduction. I am running my own devnet with around 10k blocks.
Given that this took only 1 user second (7 seconds of wall clock time), I think that not all the 10k blocks got scanned, but a small fraction of them. You should see a higher reduction if you reset the createdAt of your accounts, or if e.g. you scan the whole mainnet.
Regardless, the reduction will not be huge, as there are many allocations performed in other places of our codebase. This PR mainly focuses on reducing the allocations involved in scans, but time
does not offer any way to differentiate between the two. The bottom line is: as long as time
shows some reduction during scans, it means that this PR is doing what it's supposed to do.
Summary
This changes the way the worker pool and the workers communicate in the following way:
Buffers sent to/from workers are now "transferred". This is a feature of
MessagePort.postMessage()
that allows to transfer ownership of certain objects to the receiving side, avoiding cloning, thus improving the performance of every worker.It's now possible to send to the workers an optional
SharedArrayBuffer
as an input (in addition to theBuffer
that is already supported).The
BackgroundNoteDecryptor
used by the wallet scanner has been updated to make use ofSharedArrayBuffer
to store the account keys.This is a draft because it requires https://github.com/iron-fish/jubjub/pull/4 to be merged first.
Testing Plan
wallet:rescan
for a set amount of time with a tool to measure memory usage and page fault, for example:Documentation
N/A
Breaking Change
N/A