Add GC-safe regions around ssl_read
and ssl_write
#265
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.
We've observed
mbedtls_ssl_read
andmbedtls_ssl_write
show up in CPU profiles while also seeing long GC time-to-safepoint. Theseccall
s call back into Julia (f_send
andf_recv
), during which GC should be able to run. But I can't tell if, for large enough reads or writes, there could be a long interval without reaching a GC safepoint.Adding GC-safe regions around the
ccall
s will let GC run even if a thread is busy inside. Sincec_send
andc_recv
are@cfunction
s, they will do the right thing wrt GC safety.Ref: JuliaLang/julia#51574
This is a temporary fix; when JuliaLang/julia#49933 lands, this should be changed to do whatever that requires.
If a reviewer knows for certain that a thread won't remain inside the
ccall
without calling back into Julia for multiple seconds, then this PR can be discarded.