From 48657d2fb6c9c709ec29264a609350c7b4a541f9 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Tue, 17 Dec 2024 14:20:48 +0100 Subject: batch fetch record cache values (#266) - Improvement: Batch fetch record attachments when appropriate - Improvement: Reduce memory buffer allocation in BlockStore::IterateBlock - Improvement: Tweaked BlockStore::IterateBlock logic when to use threaded work (at least 4 chunks requested) - Bugfix: CasContainerStrategy::IterateChunks could give wrong payload/index when requesting 1 or 2 chunks --- src/zenstore/compactcas.cpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'src/zenstore/compactcas.cpp') diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp index 50af7246e..30cf998f8 100644 --- a/src/zenstore/compactcas.cpp +++ b/src/zenstore/compactcas.cpp @@ -345,12 +345,13 @@ CasContainerStrategy::IterateChunks(std::span ChunkHashes, } } } - if (FoundChunkLocations.size() < 3) + if (FoundChunkLocations.size() < 4) { - for (size_t ChunkIndex : FoundChunkIndexes) + for (size_t Index = 0; Index < FoundChunkIndexes.size(); Index++) { - IoBuffer Chunk = m_BlockStore.TryGetChunk(FoundChunkLocations[ChunkIndex]); - if (!AsyncCallback(ChunkIndex, Chunk)) + IoBuffer Chunk = m_BlockStore.TryGetChunk(FoundChunkLocations[Index]); + size_t OuterIndex = FoundChunkIndexes[Index]; + if (!AsyncCallback(OuterIndex, Chunk)) { return false; } @@ -359,6 +360,18 @@ CasContainerStrategy::IterateChunks(std::span ChunkHashes, } auto DoOneBlock = [&](std::span ChunkIndexes) { + if (ChunkIndexes.size() < 4) + { + for (size_t ChunkIndex : ChunkIndexes) + { + IoBuffer Chunk = m_BlockStore.TryGetChunk(FoundChunkLocations[ChunkIndex]); + if (!AsyncCallback(FoundChunkIndexes[ChunkIndex], Chunk)) + { + return false; + } + } + return true; + } return m_BlockStore.IterateBlock( FoundChunkLocations, ChunkIndexes, @@ -378,19 +391,7 @@ CasContainerStrategy::IterateChunks(std::span ChunkHashes, Latch WorkLatch(1); std::atomic_bool AsyncContinue = true; bool Continue = m_BlockStore.IterateChunks(FoundChunkLocations, [&](uint32_t BlockIndex, std::span ChunkIndexes) { - if (ChunkIndexes.size() < 3) - { - for (size_t ChunkIndex : ChunkIndexes) - { - IoBuffer Chunk = m_BlockStore.TryGetChunk(FoundChunkLocations[ChunkIndex]); - if (!AsyncCallback(FoundChunkIndexes[ChunkIndex], Chunk)) - { - return false; - } - } - return true; - } - else if (OptionalWorkerPool) + if (OptionalWorkerPool && (ChunkIndexes.size() > 3)) { WorkLatch.AddCount(1); OptionalWorkerPool->ScheduleWork([&, ChunkIndexes = std::vector(ChunkIndexes.begin(), ChunkIndexes.end())]() { -- cgit v1.2.3 From 1ccfb3c387773f3b7b396ad2a775dc08b00e8109 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Tue, 17 Dec 2024 14:45:27 +0100 Subject: Miscellaneous minor LLM fixes (#268) With this change, LLM tags are assigned using the name,parent tuple rather than just by name only. This allows tag hierarchies like `cache/store` and `project/store` which would previously get collapsed into the first pair seen when registering the `store` tag. This PR also adds some more LLM tag annotations to more accurately associate memory allocations with subsystems In addition, this PR also tweaks the frequency of timer marker events to increase the resolution in Insights and avoid some cases of Insights deciding that marker events are too far apart since we don't allocate as frequently as UE tends to. --- src/zenstore/compactcas.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/zenstore/compactcas.cpp') diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp index 30cf998f8..2be0542db 100644 --- a/src/zenstore/compactcas.cpp +++ b/src/zenstore/compactcas.cpp @@ -199,6 +199,7 @@ CasContainerStrategy::InsertChunk(const void* ChunkData, size_t ChunkSize, const // reads, insert and GC. m_BlockStore.WriteChunk(ChunkData, ChunkSize, m_PayloadAlignment, [&](const BlockStoreLocation& Location) { + ZEN_MEMSCOPE(GetCasContainerTag()); ZEN_TRACE_CPU("CasContainer::UpdateLocation"); BlockStoreDiskLocation DiskLocation(Location, m_PayloadAlignment); const CasDiskIndexEntry IndexEntry{.Key = ChunkHash, .Location = DiskLocation}; @@ -232,7 +233,6 @@ CasContainerStrategy::InsertChunks(std::span Chunks, std::span ZEN_ASSERT(Chunks.size() == ChunkHashes.size()); std::vector Result(Chunks.size()); std::vector NewChunkIndexes; - Result.reserve(Chunks.size()); { RwLock::SharedLockScope _(m_LocationMapLock); for (size_t ChunkIndex = 0; ChunkIndex < ChunkHashes.size(); ChunkIndex++) @@ -264,6 +264,7 @@ CasContainerStrategy::InsertChunks(std::span Chunks, std::span size_t ChunkOffset = 0; m_BlockStore.WriteChunks(Datas, m_PayloadAlignment, [&](std::span Locations) { + ZEN_MEMSCOPE(GetCasContainerTag()); std::vector IndexEntries; for (const BlockStoreLocation& Location : Locations) { -- cgit v1.2.3