Skip to content

Commit

Permalink
slow-testing-hpcc-31968 Test 1MB buffer with instrumentation
Browse files Browse the repository at this point in the history
Add intrumentation to the 1MB buffer size commit.

Signed-off-by: Terrence Asselin <[email protected]>
  • Loading branch information
asselitx committed Jul 3, 2024
1 parent 2f399ca commit db143f2
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions esp/bindings/http/platform/httptransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "platform.h"
#include "esphttp.hpp"
#include "persistent.hpp"
#include "cumulativetimer.hpp"

#ifdef _WIN32
#include <algorithm>
Expand Down Expand Up @@ -2226,31 +2227,45 @@ void CHttpRequest::readUploadFileContent(StringArray& fileNames, StringArray& fi
int CHttpRequest::readContentToFiles(const char * netAddress, const char * path, StringArray& fileNames)
{
const char* contentType = m_content_type.get();
IEspContext* ctx = this->queryContext();
CumulativeTimer* readTimer = ctx->queryTraceSummaryCumulativeTimer(LogMin, "uploadRead", TXSUMMARY_GRP_CORE);
CumulativeTimer* writeTimer = ctx->queryTraceSummaryCumulativeTimer(LogMin, "uploadWrite", TXSUMMARY_GRP_CORE);
CumulativeTimer* uploadCreateTimer = ctx->queryTraceSummaryCumulativeTimer(LogMin, "uploadfileCreateMs", TXSUMMARY_GRP_CORE);
CumulativeTimer* uploadOpenTimer = ctx->queryTraceSummaryCumulativeTimer(LogMin, "uploadfileIOOpenMs", TXSUMMARY_GRP_CORE);

if (!contentType || !*contentType)
throw MakeStringException(-1, "Content Type not found.");
Owned<CMimeMultiPart> multipart = new CMimeMultiPart("1.0", contentType, "", "", "");
unsigned __int64 start;
multipart->parseContentType(contentType);

MemoryBuffer fileContent, moreContent;
__int64 bytesNotRead = m_content_length;
while (1)
{
StringBuffer fileName;
if (!readUploadFileName(multipart, fileName, fileContent, bytesNotRead))
{
UERRLOG("No file name found for upload");
break;
CumulativeTimer::Scope readScope(readTimer);
if (!readUploadFileName(multipart, fileName, fileContent, bytesNotRead))
{
UERRLOG("No file name found for upload");
break;
}
}

fileNames.append(fileName);
StringBuffer fileNameWithPath;
start = msTick();
Owned<IFile> file = createUploadFile(netAddress, path, fileName, fileNameWithPath);
uploadCreateTimer->add(msTick() - start);
if (!file)
{
UERRLOG("Uploaded file %s cannot be created", fileName.str());
break;
}
start = msTick();
Owned<IFileIO> fileio = file->open(IFOcreate);
uploadOpenTimer->add(msTick() - start);
if (!fileio)
{
UERRLOG("Uploaded file %s cannot be opened", fileName.str());
Expand All @@ -2265,6 +2280,7 @@ int CHttpRequest::readContentToFiles(const char * netAddress, const char * path,
foundAnotherFile = multipart->separateMultiParts(fileContent, moreContent, bytesNotRead);
if (fileContent.length() > 0)
{
CumulativeTimer::Scope writeScope(writeTimer);
if (fileio->write(writeOffset, fileContent.length(), fileContent.toByteArray()) != fileContent.length())
{
UERRLOG("Failed to write Uploaded file %s", fileName.str());
Expand All @@ -2281,8 +2297,11 @@ int CHttpRequest::readContentToFiles(const char * netAddress, const char * path,
moreContent.clear();
}

if(foundAnotherFile || (bytesNotRead <= 0) || !readContentToBuffer(fileContent, bytesNotRead))
break;
{
CumulativeTimer::Scope readScope(readTimer);
if(foundAnotherFile || (bytesNotRead <= 0) || !readContentToBuffer(fileContent, bytesNotRead))
break;
}
}

if (writeError)
Expand Down

0 comments on commit db143f2

Please sign in to comment.