-
Notifications
You must be signed in to change notification settings - Fork 573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a sparse array in DecryptNotesResponse
#5128
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
andiflabs
force-pushed
the
andrea/decrypt-notes-response-sparse-array
branch
from
July 10, 2024 23:49
d47ad02
to
9aa2688
Compare
andiflabs
force-pushed
the
andrea/worker-pool-transfer-and-shared-mem
branch
from
July 11, 2024 16:41
6f3dd00
to
148f41b
Compare
andiflabs
force-pushed
the
andrea/decrypt-notes-response-sparse-array
branch
from
July 11, 2024 16:41
9aa2688
to
d29c962
Compare
andiflabs
force-pushed
the
andrea/worker-pool-transfer-and-shared-mem
branch
from
July 11, 2024 16:55
148f41b
to
8e8a2b7
Compare
andiflabs
force-pushed
the
andrea/decrypt-notes-response-sparse-array
branch
from
July 11, 2024 16:55
d29c962
to
b4fe7d0
Compare
andiflabs
force-pushed
the
andrea/worker-pool-transfer-and-shared-mem
branch
from
July 11, 2024 19:31
8e8a2b7
to
f280136
Compare
andiflabs
force-pushed
the
andrea/decrypt-notes-response-sparse-array
branch
from
July 11, 2024 20:32
b4fe7d0
to
720b052
Compare
andiflabs
force-pushed
the
andrea/worker-pool-transfer-and-shared-mem
branch
from
July 11, 2024 20:54
f280136
to
abc46be
Compare
hughy
approved these changes
Jul 11, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, tested locally and scanning seems to work correctly
I think we might benefit from more test coverage that addresses an example of a sparse response
andiflabs
force-pushed
the
andrea/worker-pool-transfer-and-shared-mem
branch
from
July 11, 2024 22:12
abc46be
to
1dcff5a
Compare
andiflabs
force-pushed
the
andrea/decrypt-notes-response-sparse-array
branch
from
July 11, 2024 22:16
720b052
to
403f126
Compare
andiflabs
force-pushed
the
andrea/worker-pool-transfer-and-shared-mem
branch
from
July 11, 2024 22:20
1dcff5a
to
930aa7f
Compare
andiflabs
force-pushed
the
andrea/decrypt-notes-response-sparse-array
branch
from
July 11, 2024 22:20
403f126
to
f8763fc
Compare
Base automatically changed from
andrea/worker-pool-transfer-and-shared-mem
to
staging
July 11, 2024 23:15
andiflabs
force-pushed
the
andrea/decrypt-notes-response-sparse-array
branch
from
July 11, 2024 23:16
f8763fc
to
8c4ec51
Compare
Most of the note decryption will fail. Currently, if a `DecryptNotesResponse` contains 100 undecrypted notes, it will create a dense array containing 100 `null` values, causing unnecessary large memory allocations and large memory writes. It was in fact observed that the arrays from `DecryptNotesResponse` were one of the top contributors to memory usage during wallet scans. This commit changes the implementation so that now `DecryptNotesResponse` would create a sparse array containing no values at all. This means that, when no notes are decrypted (i.e. the most common case), all `DecryptNotesResponse` objects consume the same amount of memory, regardless of how many accounts are in the wallet, or how many encrypted notes were requested. This was shown to reduce the peak memory usage of the node process, as well as reduce the number of minor page faults.
andiflabs
force-pushed
the
andrea/decrypt-notes-response-sparse-array
branch
from
July 15, 2024 21:32
8c4ec51
to
dad63ba
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Most of the note decryption will fail. Currently, if a
DecryptNotesResponse
contains 100 undecrypted notes, it will create a dense array containing 100null
values, causing unnecessary large memory allocations and large memory writes. It was in fact observed that the arrays fromDecryptNotesResponse
were one of the top contributors to memory usage during wallet scans.This commit changes the implementation so that now
DecryptNotesResponse
would create a sparse array containing no values at all. This means that, when no notes are decrypted (i.e. the most common case), allDecryptNotesResponse
objects consume the same amount of memory, regardless of how many accounts are in the wallet, or how many encrypted notes were requested.This was shown to reduce the peak memory usage of the node process, as well as reduce the number of minor page faults.
Testing Plan
Documentation
N/A
Breaking Change
N/A