Skip to content

Commit

Permalink
XrdTpc: Adjust buffer size based on number of streams.
Browse files Browse the repository at this point in the history
As we only write when buffers are full and we don't need a full 16MB
buffer when we are doing single-streams (for single stream, we're only
waiting to accumulate a "large-enough" MB-aligned buffer), we can
simply decrease the buffer size.  Saves some allocated-but-unused
space.
  • Loading branch information
bbockelm committed Jan 30, 2021
1 parent f897047 commit 3d28dd5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/XrdTpc/XrdTpcTPC.cc
Expand Up @@ -26,6 +26,7 @@ using namespace TPC;
uint64_t TPCHandler::m_monid{0};
int TPCHandler::m_marker_period = 5;
size_t TPCHandler::m_block_size = 16*1024*1024;
size_t TPCHandler::m_small_block_size = 1*1024*1024;
XrdSysMutex TPCHandler::m_monid_mutex;

XrdVERSIONINFO(XrdHttpGetExtHandler, HttpTPC);
Expand Down Expand Up @@ -356,6 +357,8 @@ int TPCHandler::RunCurlWithUpdates(CURL *curl, XrdHttpExtReq &req, State &state,
return req.SendSimpleResp(rec.status, NULL, NULL, msg, 0);
}

//curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 128*1024);

CURLMcode mres;
mres = curl_multi_add_handle(multi_handle, curl);
if (mres) {
Expand Down Expand Up @@ -592,6 +595,7 @@ int TPCHandler::ProcessPushReq(const std::string & resource, XrdHttpExtReq &req)
logTransferEvent(LogMask::Error, rec, "PUSH_FAIL", msg);
return req.SendSimpleResp(rec.status, NULL, NULL, msg, 0);
}

auto query_header = req.headers.find("xrd-http-fullresource");
std::string redirect_resource = req.resource;
if (query_header != req.headers.end()) {
Expand Down Expand Up @@ -733,7 +737,7 @@ int TPCHandler::ProcessPullReq(const std::string &resource, XrdHttpExtReq &req)
curl_easy_setopt(curl, CURLOPT_CAPATH, m_cadir.c_str());
}
curl_easy_setopt(curl, CURLOPT_URL, resource.c_str());
Stream stream(std::move(fh), streams * m_pipelining_multiplier, m_block_size, m_log);
Stream stream(std::move(fh), streams * m_pipelining_multiplier, streams > 1 ? m_block_size : m_small_block_size, m_log);
State state(0, stream, curl, false);
state.CopyHeaders(req);

Expand Down
1 change: 1 addition & 0 deletions src/XrdTpc/XrdTpcTPC.hh
Expand Up @@ -109,6 +109,7 @@ private:

static int m_marker_period;
static size_t m_block_size;
static size_t m_small_block_size;
bool m_desthttps;
std::string m_cadir;
static XrdSysMutex m_monid_mutex;
Expand Down

0 comments on commit 3d28dd5

Please sign in to comment.