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

Reduce memory allocation when writing to SSLSocket #1924

Closed
wants to merge 1 commit into from

Conversation

janko
Copy link
Contributor

@janko janko commented Aug 4, 2018

I'm opening https://bugs.ruby-lang.org/issues/14426 as a pull request as this way it will hopefully gain more visibility.

At the moment OpenSSL::Buffering#do_write allocates some additional strings, and in my profiling writing 5MB of data allocates additional 7.7MB of strings.

This patch greatly reduces memory allocations, and now writing 5MB of data allocates only additional 0.2MB of strings. This means that large file uploads would effectively not allocate additional memory anymore.

At the moment OpenSSL::Buffering#do_write allocates some additional
strings, and in my profiling writing 5MB of data allocates additional
7.7MB of strings.

This patch greatly reduces memory allocations, and now writing 5MB of
data allocates only additional 0.2MB of strings. This means that large
file uploads would effectively not allocate additional memory anymore.
rhenium pushed a commit to rhenium/ruby-openssl that referenced this pull request Aug 8, 2018
At the moment OpenSSL::Buffering#do_write allocates some additional
strings, and in my profiling writing 5MB of data allocates additional
7.7MB of strings.

This patch greatly reduces memory allocations, and now writing 5MB of
data allocates only additional 0.2MB of strings. This means that large
file uploads would effectively not allocate additional memory anymore.

Reference: https://bugs.ruby-lang.org/issues/14426
Reference: ruby/ruby#1924
@rhenium
Copy link
Member

rhenium commented Aug 8, 2018

Sorry for the delay, and thanks for the patch! It is now merged into ruby/openssl's master and Ruby's trunk.

@rhenium rhenium closed this Aug 8, 2018
mcr pushed a commit to CIRALabs/ruby-openssl that referenced this pull request Feb 11, 2019
At the moment OpenSSL::Buffering#do_write allocates some additional
strings, and in my profiling writing 5MB of data allocates additional
7.7MB of strings.

This patch greatly reduces memory allocations, and now writing 5MB of
data allocates only additional 0.2MB of strings. This means that large
file uploads would effectively not allocate additional memory anymore.

Reference: https://bugs.ruby-lang.org/issues/14426
Reference: ruby/ruby#1924
rhenium pushed a commit to rhenium/ruby-openssl that referenced this pull request Sep 26, 2021
[ This is a backport to the 2.1 branch. ]

At the moment OpenSSL::Buffering#do_write allocates some additional
strings, and in my profiling writing 5MB of data allocates additional
7.7MB of strings.

This patch greatly reduces memory allocations, and now writing 5MB of
data allocates only additional 0.2MB of strings. This means that large
file uploads would effectively not allocate additional memory anymore.

Reference: https://bugs.ruby-lang.org/issues/14426
Reference: ruby/ruby#1924
(cherry picked from commit 251b5be)
@hsbt hsbt added the Backport label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants