Skip to content
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

Pull secp256k1 contexts from per-peer to per-PeerManager #1472

Merged

Conversation

TheBlueMatt
Copy link
Collaborator

I was running some heap profiling on an LDK application and noticed we currently allocate a full secp context per peer, so figured I'd just remove it.

Instead of including a Secp256k1 context per
PeerChannelEncryptor, which is relatively expensive memory-wise
and nontrivial CPU-wise to construct, we should keep one for all
peers and simply reuse it.

This is relatively trivial so we do so in this commit.

Since its trivial to do so, we also take this opportunity to
randomize the new PeerManager context.

@codecov-commenter
Copy link

codecov-commenter commented May 9, 2022

Codecov Report

Merging #1472 (3a4258c) into main (29727a3) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 3a4258c differs from pull request most recent head 2ab8814. Consider uploading reports for the commit 2ab8814 to get more accurate results

@@            Coverage Diff             @@
##             main    #1472      +/-   ##
==========================================
- Coverage   90.94%   90.94%   -0.01%     
==========================================
  Files          75       75              
  Lines       41891    41899       +8     
  Branches    41891    41899       +8     
==========================================
+ Hits        38097    38103       +6     
- Misses       3794     3796       +2     
Impacted Files Coverage Δ
lightning/src/ln/peer_channel_encryptor.rs 94.47% <100.00%> (-0.52%) ⬇️
lightning/src/ln/peer_handler.rs 53.85% <100.00%> (+0.30%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29727a3...2ab8814. Read the comment docs.

dunxen
dunxen previously approved these changes May 10, 2022
Copy link
Contributor

@dunxen dunxen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 2ab8814

Instead of including a `Secp256k1` context per
`PeerChannelEncryptor`, which is relatively expensive memory-wise
and nontrivial CPU-wise to construct, we should keep one for all
peers and simply reuse it.

This is relatively trivial so we do so in this commit.

Since its trivial to do so, we also take this opportunity to
randomize the new PeerManager context.
@TheBlueMatt
Copy link
Collaborator Author

Rebased.

Copy link
Contributor

@dunxen dunxen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK e6aaf7c

@valentinewallace valentinewallace merged commit b20aea1 into lightningdevkit:main May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants