diff options
| author | Dan Engelbrecht <[email protected]> | 2023-10-13 09:38:02 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-13 09:38:02 +0200 |
| commit | 1d992a472c54ef9a63364996031e3c6d2f8affe5 (patch) | |
| tree | bb20344ed4c5b4295c12914bf0124e11be5ff3a7 /src/zenserver/projectstore/httpprojectstore.cpp | |
| parent | Merge pull request #465 from EpicGames/zs/default-port-change (diff) | |
| download | zen-1d992a472c54ef9a63364996031e3c6d2f8affe5.tar.xz zen-1d992a472c54ef9a63364996031e3c6d2f8affe5.zip | |
faster oplog iteration (#471)
* use a CbObjectView instead of CbObject to avoid creating IOBufferCore instances
* use BasicFileBuffer directly where possible
* changelog
Diffstat (limited to 'src/zenserver/projectstore/httpprojectstore.cpp')
| -rw-r--r-- | src/zenserver/projectstore/httpprojectstore.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/zenserver/projectstore/httpprojectstore.cpp b/src/zenserver/projectstore/httpprojectstore.cpp index 3edcf5903..261485834 100644 --- a/src/zenserver/projectstore/httpprojectstore.cpp +++ b/src/zenserver/projectstore/httpprojectstore.cpp @@ -57,14 +57,13 @@ CSVWriteOp(CidStore& CidStore, bool AttachmentDetails, int LSN, const Oid& Key, - CbObject Op, + CbObjectView Op, StringBuilderBase& CSVWriter) { StringBuilder<32> KeyStringBuilder; Key.ToString(KeyStringBuilder); const std::string_view KeyString = KeyStringBuilder.ToView(); - SharedBuffer Buffer = Op.GetBuffer(); if (AttachmentDetails) { Op.IterateAttachments([&CidStore, &CSVWriter, &ProjectId, &OplogId, LSN, &KeyString](CbFieldView FieldView) { @@ -86,8 +85,8 @@ CSVWriteOp(CidStore& CidStore, AttachmentsSize += Attachment.GetSize(); }); CSVWriter << "\r\n" - << ProjectId << ", " << OplogId << ", " << LSN << ", " << KeyString << ", " << gsl::narrow<uint64_t>(Buffer.GetSize()) - << ", " << AttachmentCount << ", " << gsl::narrow<uint64_t>(AttachmentsSize); + << ProjectId << ", " << OplogId << ", " << LSN << ", " << KeyString << ", " << gsl::narrow<uint64_t>(Op.GetSize()) << ", " + << AttachmentCount << ", " << gsl::narrow<uint64_t>(AttachmentsSize); } else { @@ -105,17 +104,16 @@ namespace { bool AttachmentDetails, int LSN, const Oid& Key, - CbObject Op, + CbObjectView Op, CbObjectWriter& CbWriter) { CbWriter.BeginObject(); { - SharedBuffer Buffer = Op.GetBuffer(); CbWriter.AddObjectId("key", Key); if (Details) { CbWriter.AddInteger("lsn", LSN); - CbWriter.AddInteger("size", gsl::narrow<uint64_t>(Buffer.GetSize())); + CbWriter.AddInteger("size", gsl::narrow<uint64_t>(Op.GetSize())); } if (AttachmentDetails) { @@ -176,7 +174,7 @@ namespace { { Cbo.BeginArray("ops"); { - Oplog.IterateOplogWithKey([&Cbo, &CidStore, Details, OpDetails, AttachmentDetails](int LSN, const Oid& Key, CbObject Op) { + Oplog.IterateOplogWithKey([&Cbo, &CidStore, Details, OpDetails, AttachmentDetails](int LSN, const Oid& Key, CbObjectView Op) { CbWriteOp(CidStore, Details, OpDetails, AttachmentDetails, LSN, Key, Op, Cbo); }); } @@ -1350,7 +1348,7 @@ HttpProjectService::HandleOpLogEntriesRequest(HttpRouterRequest& Req) { Response.BeginArray("entries"sv); - FoundLog->IterateOplog([&Response](CbObject Op) { Response << Op; }); + FoundLog->IterateOplog([&Response](CbObjectView Op) { Response << Op; }); Response.EndArray(); } @@ -1638,7 +1636,7 @@ HttpProjectService::HandleDetailsRequest(HttpRouterRequest& Req) m_ProjectStore->IterateProjects([&](ProjectStore::Project& Project) { Project.IterateOplogs([&](const RwLock::SharedLockScope&, ProjectStore::Oplog& Oplog) { Oplog.IterateOplogWithKey( - [this, &Project, &Oplog, &CSVWriter, Details, AttachmentDetails](int LSN, const Oid& Key, CbObject Op) { + [this, &Project, &Oplog, &CSVWriter, Details, AttachmentDetails](int LSN, const Oid& Key, CbObjectView Op) { CSVWriteOp(m_CidStore, Project.Identifier, Oplog.OplogId(), Details, AttachmentDetails, LSN, Key, Op, CSVWriter); }); }); @@ -1693,7 +1691,7 @@ HttpProjectService::HandleProjectDetailsRequest(HttpRouterRequest& Req) FoundProject->IterateOplogs([&](const RwLock::SharedLockScope&, ProjectStore::Oplog& Oplog) { Oplog.IterateOplogWithKey( - [this, &Project, &Oplog, &CSVWriter, Details, AttachmentDetails](int LSN, const Oid& Key, CbObject Op) { + [this, &Project, &Oplog, &CSVWriter, Details, AttachmentDetails](int LSN, const Oid& Key, CbObjectView Op) { CSVWriteOp(m_CidStore, Project.Identifier, Oplog.OplogId(), Details, AttachmentDetails, LSN, Key, Op, CSVWriter); }); }); @@ -1748,9 +1746,10 @@ HttpProjectService::HandleOplogDetailsRequest(HttpRouterRequest& Req) ExtendableStringBuilder<4096> CSVWriter; CSVHeader(Details, AttachmentDetails, CSVWriter); - Oplog.IterateOplogWithKey([this, &Project, &Oplog, &CSVWriter, Details, AttachmentDetails](int LSN, const Oid& Key, CbObject Op) { - CSVWriteOp(m_CidStore, Project.Identifier, Oplog.OplogId(), Details, AttachmentDetails, LSN, Key, Op, CSVWriter); - }); + Oplog.IterateOplogWithKey( + [this, &Project, &Oplog, &CSVWriter, Details, AttachmentDetails](int LSN, const Oid& Key, CbObjectView Op) { + CSVWriteOp(m_CidStore, Project.Identifier, Oplog.OplogId(), Details, AttachmentDetails, LSN, Key, Op, CSVWriter); + }); HttpReq.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, CSVWriter.ToView()); } else |