[PATCH] D111252: [llvm] [Support] [Debuginfo] Add http and debuginfod client libraries and llvm-debuginfod-find tool
Noah Shutty via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 15 13:12:24 PDT 2021
noajshu marked an inline comment as done.
noajshu added inline comments.
================
Comment at: llvm/lib/Support/HTTPClient.cpp:31
+ size_t BufferSize = Buffer->size();
+ Buffer->resize(BufferSize + ChunkSize);
+ memcpy(&(Buffer[BufferSize]), Contents, ChunkSize);
----------------
noajshu wrote:
> phosek wrote:
> > One potential downside of this approach is you may have to resize the buffer multiple times as the data comes in which would be inefficient.
> >
> > I was reading about alternatives, one possibility would be check a priori what's the size of the resource you're fetching is by performing a HEAD request (via `CURLOPT_NOBODY` and `CURLOPT_HEADER` set to 1) asking for the HTTP headers to be written via `CURLOPT_WRITEHEADER` and `CURLOPT_WRITEFUNCTION` and parsing the `Content-Length` value. Then you can allocate an appropriately sized buffer and fetch the actual content. You might even use `WritableMemoryBuffer::getNewUninitMemBuffer` instead of `std::vector` since you don't need to resize.
> Thanks, this is a very interesting idea! I will try to do the same thing using just a single request, by triggering the resize in CURLOPT_HEADERFUNCTION when the content-length is available.
Thanks for this suggestion. I have implemented this single-allocation scheme and switched the HTTP buffer type to a LLVM MemoryBuffer. Please let me know if you have any comments on this. Thanks!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111252/new/
https://reviews.llvm.org/D111252
More information about the llvm-commits
mailing list