-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Downloading a long sequence of URLs results in high CPU usage and slowness #429
Comments
curl --version (from the Ubuntu 14.04 repository) |
Interesting test. I've run it and got similar results with curl 7.45 (fedora 21). On the other hand, similar test with libcurl doesn't show this behaviour. #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
int main(int argc, char *argv[])
{
CURLcode ret;
CURL *hnd;
int i;
char base_url[] = "http://localhost:8888/";
hnd = curl_easy_init();
char *url = (char *) malloc(sizeof(base_url) + 7);
strcpy(url, base_url);
for(i = 0; i < 1000000; i++) {
sprintf(url + sizeof(base_url) - 1, "%i", i);
curl_easy_setopt(hnd, CURLOPT_URL, url);
ret = curl_easy_perform(hnd);
}
curl_easy_cleanup(hnd);
return ret;
} I can't tell why the tool behaves that way and I'm not sure I've considered all the aspects. |
perf report output from Ubuntu 14 x64 running curl built from master fad9604 2015-09-11. The If this is the case I think the fix would be not to do code generation unless it's requested. Though I wonder if this is one of those things that's a whole lot easier to say than do. Until this is resolved you could build curl with configure option |
Nice catch @jay, and indeed a silly flaw. We should of course only waste that time and memory if the user actually asked for code to get generated... |
Oh, and we should probably also consider using a linked list to which we can append strings at no extra cost even when the list gets very long so that this use case still would work fast and nice even when enabled. |
Nice indeed (and thanks for the perf tip)! |
Anyone volunteering to work on improving this piece of code? |
We should still pursue this proposal! Should I create a new issue for this? |
Yes, it would be good and yeah a separate issue/pull-request makes it more convenient. |
- Review of 4d95491. The author changed it so easysrc only initializes when --libcurl but did not do the same for the call to easysrc cleanup. Ref: #429
The easysrc generation is run only when --libcurl is initialized. Ref: curl#429
- Review of 4d95491. The author changed it so easysrc only initializes when --libcurl but did not do the same for the call to easysrc cleanup. Ref: curl#429
Here is what I did
In one terminal run: python -m SimpleHTTPServer 8888
In another terminal run: curl "localhost:8888/[1-1000000]" > /dev/null
In the beginning the speed was over 2000 URLs/second. By the time it reached the 50000th URL, the speed was under 300 URLs/second, and curl's CPU usage was about twice as high as it was at the start.
Restarting curl (without restarting the server) results again in high speed in the beginning, then gradually dropping. Same if I use a different range, e.g. [100000-1000000].
The text was updated successfully, but these errors were encountered: