http4s-curl icon indicating copy to clipboard operation
http4s-curl copied to clipboard

Pool easy handles?

Open armanbilge opened this issue 3 years ago • 2 comments

https://github.com/typelevel/keypool

Easy handles are meant and designed to be reused. When you have done a single transfer with the easy handle, you can immediately use it again for your next transfer.

https://everything.curl.dev/libcurl/easyhandle#reuse

After the transfer has been made, you can set new options and make another transfer, or if you are done, cleanup the session by calling curl_easy_cleanup. If you want persistent connections, you do not cleanup immediately, but instead run ahead and perform other transfers using the same easy handle.

https://curl.se/libcurl/c/libcurl-easy.html

Sounds like a mistake that we're not reusing these 😅

armanbilge avatar Aug 25 '22 04:08 armanbilge

Keypool is not published for Native yet, but I can bootleg it real quick if someone wants to work on this. Just ping me :)

armanbilge avatar Aug 25 '22 04:08 armanbilge

Actually I don't think this is so necessary after all, since we are using the multi API. The multi-handle will maintain the connection pool

When you are using the multi API, the connection pool is instead kept associated with the multi handle. This allows you to cleanup and re-create easy handles freely without risking losing the connection pool, and it allows the connection used by one easy handle to get reused by a separate one in a later transfer. Just reuse the multi handle!

https://everything.curl.dev/libcurl/connectionreuse

Using a pool to reuse easy-handles may still be useful from a memory allocation perspective? But a pool adds overhead too.

armanbilge avatar Aug 30 '22 11:08 armanbilge