diff options
| author | Dan Engelbrecht <[email protected]> | 2022-12-08 14:44:14 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-12-08 05:44:14 -0800 |
| commit | 85c411df89737c153528c1ef0d99305bd2e060de (patch) | |
| tree | 437e90dbececb4609fb7984dd657d5488aab52f8 /zenserver/cache/structuredcache.cpp | |
| parent | Fix http parsing crash (#205) (diff) | |
| download | zen-85c411df89737c153528c1ef0d99305bd2e060de.tar.xz zen-85c411df89737c153528c1ef0d99305bd2e060de.zip | |
Path from handle perf improvement (#206)
* Read recorded requests to memory before parsing
This will more accurately simulate how requests comes in from a client
* Make a fast path for GetFinalPathNameByHandleW
Try to get the path with a fixes size buffer first to avoid always doing two calls to GetFinalPathNameByHandleW
Diffstat (limited to 'zenserver/cache/structuredcache.cpp')
| -rw-r--r-- | zenserver/cache/structuredcache.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index f649efa01..a7571b4c4 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -149,14 +149,15 @@ namespace cache::detail { } } uint32_t BlockCount = gsl::narrow<uint32_t>(MaxChunkPosition / RecordedRequestBlockSize) + 1; - m_IoBuffers.resize(BlockCount); + m_BlockFiles.resize(BlockCount); for (uint32_t BlockIndex = 0; BlockIndex < BlockCount; ++BlockIndex) { - m_IoBuffers[BlockIndex] = IoBufferBuilder::MakeFromFile(m_BasePath / fmt::format("chunks{}.bin", BlockIndex)); + m_BlockFiles[BlockIndex] = std::make_unique<BasicFile>(); + m_BlockFiles[BlockIndex]->Open(m_BasePath / fmt::format("chunks{}.bin", BlockIndex), BasicFile::Mode::kRead); } return m_Entries.size(); } - void EndRead() { m_IoBuffers.clear(); } + void EndRead() { m_BlockFiles.clear(); } ZenContentType ReadRequest(uint64_t RequestIndex, IoBuffer& OutBuffer) const { @@ -171,19 +172,22 @@ namespace cache::detail { } if (Entry.Offset != ~0ull) { - uint32_t BlockIndex = gsl::narrow<uint32_t>((Entry.Offset + Entry.Length) / RecordedRequestBlockSize); - uint64_t ChunkOffset = Entry.Offset - (BlockIndex * RecordedRequestBlockSize); - OutBuffer = IoBuffer(m_IoBuffers[BlockIndex], ChunkOffset, Entry.Length); + uint32_t BlockIndex = gsl::narrow<uint32_t>((Entry.Offset + Entry.Length) / RecordedRequestBlockSize); + uint64_t ChunkOffset = Entry.Offset - (BlockIndex * RecordedRequestBlockSize); + OutBuffer = IoBuffer(Entry.Length); + MutableMemoryView OutView = OutBuffer.GetMutableView(); + m_BlockFiles[BlockIndex]->Read(OutView.GetData(), OutView.GetSize(), ChunkOffset); return Entry.ContentType; } - OutBuffer = IoBufferBuilder::MakeFromFile(m_BasePath / fmt::format("request{}.bin", RequestIndex)); + BasicFile ChunkFile; + ChunkFile.Open(m_BasePath / fmt::format("request{}.bin", RequestIndex), BasicFile::Mode::kRead); + OutBuffer = ChunkFile.ReadAll(); return Entry.ContentType; } std::filesystem::path m_BasePath; std::vector<RecordedRequest> m_Entries; std::vector<std::unique_ptr<BasicFile>> m_BlockFiles; - std::vector<IoBuffer> m_IoBuffers; }; class DiskRequestRecorder : public IRequestRecorder |