spatie / ray

Debug with Ray to fix problems faster
https://myray.app
MIT License
554 stars 102 forks source link

Implement cURL Handle Caching #864

Closed JSlush611 closed 7 months ago

JSlush611 commented 7 months ago

This PR implements caching of the cURL handle created by curl_init() to increase performance and reduce system overhead that comes with repeated creation and destruction of curl handles.

It modifies the getCurlHandle() method and only calls curl_init() once instead of each call to send(). It also removes now unnecessary calls to curl_close() in order to retain the pointer to the cached handle.

Calls to curl_init call curl_easy_init under the hood - the cURL documentation for curl_easy_init says "[You are]...encouraged to reuse easy handles for repeated transfers..." (see https://curl.se/libcurl/c/curl_easy_init.html). This PR implements this suggestion. The documentation for cURL also states "...reusing handles is a key to good performance with libcurl."

@patinthehat

freekmurze commented 7 months ago

Thanks!