Is libcURL slower than hand creating socket requests in C?
konceptz.com
konceptz.com
I would be very hesitant to be giving this kind of advice until i had an answer to that.
Would be nice if OP profiled his new code vs. his old code, though I'm guessing libcurl isn't the issue even without seeing profiling results
-Incomparable harnesses
-Misuse of the library's api
-Build switches
-UA sniffing
-Not measuring or controlling for system/net load
This isn't a post about why you shouldn't use libcurl; it's a post about why you shouldn't benchmark your way to blind conclusions.
You're right about the conclusion, I'll reword the title.
As far as why, my calls are certainly in the post somewhat buried in the github code linked to directly on the post.
Certainly more attention should be paid to how testing was done, I'll update that later tonight.
Do you know where I might find some documentation on this?
> I still haven't answered a very important question. Why is libcUrl so much slower?
I'd assume it's likely a result of misuse of libcUrl, or cUrl properly implementing some part of the spec that this hand-rolled implementation ignores.
On top of this, the author's C code isn't very well written. There's use of `sprintf` without arithmetic bounds checks (really he should use `snprintf`), unnecessary construction of a one-character array (that's what a dereference is for), inconsistent whitespace, `malloc` when a stack allocation would make more sense, use of `unsigned char` instead of `char` for strings, etc.
From what I can tell, the libcUrl guys are serious about performance, and I have trouble believing such a wild allegation without any further analysis.
Author again. I have my code in the post, it would be helpful for me to see what mistakes I've made in libcUrl utilization.
Did the OP even test with ruby/python/wget/curl ? Could be a DNS issue and nothing to do with libcurl.
Why spend all that time and not run `gprof` ?!
Showing curl and wget from the command would have been highly beneficial. Would you not have tested that before writing an HTTP client in C?
wget -vv http://localhost:8080/bigbin.bin --header="Range:bytes=1000-20000" -O test.out
curl -vvv http://localhost:8080/bigbin.bin --header "Range: bytes=1000-200000" -o test.out
Both of these got 350MB/s +for impl, it isn't terribly difficult
In [2]: from requests import Request, Session
In [3]: s = Session()
In [8]: req = Request('GET', 'http://localhost:8080/bigbin.bin', headers = { 'Range' : 'bytes=1000-2000000' } )
In [9]: prepped = s.prepare_request(req)
In [10]: %timeit resp = s.send(prepped)
1 loops, best of 3: 238 ms per loop
All of these are faster than what he outlined. So there is some _other_ issue going on. His hand rolled http request is faster but not for the reason he thinks. Crack out some wireshark, not some code.