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

Provide backpressure on crypto binary #1486

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

akoshelev
Copy link
Collaborator

We've been reading from a file faster than we were encrypting. That caused sender buffer to grow infinitely.

We've been reading from a file faster than we were encrypting. That
caused sender buffer to grow infinitely.
@akoshelev
Copy link
Collaborator Author

I tested it locally and before this change, the memory used to encrypt 1M input was around 8Gb. After this change, I encrypted 30M and the memory usage stayed under 200Mb.

This change makes it a bit slower because once the channels are saturated, the producer (reading from a file) blocks on the first channel that is full while there may be others that are not full. Standard library does not expose channel size, so we would need to migrate to crossbeam if we want to do that

Copy link
Member

@eriktaubeneck eriktaubeneck left a comment

Choose a reason for hiding this comment

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

ship it!

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.28%. Comparing base (e7a234a) to head (ff65340).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1486      +/-   ##
==========================================
- Coverage   93.28%   93.28%   -0.01%     
==========================================
  Files         239      239              
  Lines       43532    43532              
==========================================
- Hits        40608    40607       -1     
- Misses       2924     2925       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@akoshelev akoshelev merged commit bb543f9 into private-attribution:main Dec 9, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants