aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2024-12-17 14:45:27 +0100
committerGitHub Enterprise <[email protected]>2024-12-17 14:45:27 +0100
commit1ccfb3c387773f3b7b396ad2a775dc08b00e8109 (patch)
tree636678458dcd30d96e53503594a2b943cfd56336 /src
parent5.5.17-pre0 (diff)
downloadzen-1ccfb3c387773f3b7b396ad2a775dc08b00e8109.tar.xz
zen-1ccfb3c387773f3b7b396ad2a775dc08b00e8109.zip
Miscellaneous minor LLM fixes (#268)v5.5.17-pre0
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.
Diffstat (limited to 'src')
-rw-r--r--src/zencore/memory/llm.cpp4
-rw-r--r--src/zencore/memtrack/memorytrace.cpp4
-rw-r--r--src/zenstore/cache/cachedisklayer.cpp2
-rw-r--r--src/zenstore/compactcas.cpp3
4 files changed, 9 insertions, 4 deletions
diff --git a/src/zencore/memory/llm.cpp b/src/zencore/memory/llm.cpp
index fe4853d49..61fa29a66 100644
--- a/src/zencore/memory/llm.cpp
+++ b/src/zencore/memory/llm.cpp
@@ -15,6 +15,7 @@ static const int32_t TagNamesBaseIndex = 256;
static const int32_t TrackedTagNameCount = 256;
static const char* TagNames[TrackedTagNameCount];
static uint32_t TagNameHashes[TrackedTagNameCount];
+static int32_t ParentTags[TrackedTagNameCount];
static RwLock TableLock;
@@ -46,7 +47,7 @@ FLLMTag::AssignAndAnnounceNewTag(const char* TagName)
for (int TagIndex = 0; TagIndex <= CurrentMaxTagIndex; ++TagIndex)
{
- if (TagNameHashes[TagIndex] == TagNameHash)
+ if (TagNameHashes[TagIndex] == TagNameHash && ParentTags[TagIndex] == m_ParentTag)
{
m_Tag = TagIndex + TagNamesBaseIndex;
// could verify the string matches here to catch hash collisions
@@ -64,6 +65,7 @@ FLLMTag::AssignAndAnnounceNewTag(const char* TagName)
{
TagNameHashes[TagIndex] = TagNameHash;
TagNames[TagIndex] = TagName;
+ ParentTags[TagIndex] = m_ParentTag;
}
else
{
diff --git a/src/zencore/memtrack/memorytrace.cpp b/src/zencore/memtrack/memorytrace.cpp
index 7089c356a..e4ae8148e 100644
--- a/src/zencore/memtrack/memorytrace.cpp
+++ b/src/zencore/memtrack/memorytrace.cpp
@@ -41,8 +41,8 @@ void MemoryTrace_EnableTracePump();
////////////////////////////////////////////////////////////////////////////////
namespace {
-// Controls how often time markers are emitted (default: every 4095 allocations).
-constexpr uint32_t MarkerSamplePeriod = (4 << 10) - 1;
+// Controls how often time markers are emitted (must be POW2-1 as this is used as a mask)
+constexpr uint32_t MarkerSamplePeriod = 128 - 1;
// Number of shifted bits to SizeLower
constexpr uint32_t SizeShift = 3;
diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp
index 9f09713ee..cbc1d6e83 100644
--- a/src/zenstore/cache/cachedisklayer.cpp
+++ b/src/zenstore/cache/cachedisklayer.cpp
@@ -1267,6 +1267,7 @@ ZenCacheDiskLayer::CacheBucket::EndPutBatch(PutBatchHandle* Batch) noexcept
size_t IndexOffset = 0;
m_BlockStore.WriteChunks(Batch->Buffers, m_Configuration.PayloadAlignment, [&](std::span<BlockStoreLocation> Locations) {
+ ZEN_MEMSCOPE(GetCacheDiskTag());
std::vector<DiskIndexEntry> DiskEntries;
{
RwLock::ExclusiveLockScope IndexLock(m_IndexLock);
@@ -2679,6 +2680,7 @@ ZenCacheDiskLayer::CacheBucket::PutInlineCacheValue(const IoHash& HashKey,
Value.Value.Size(),
m_Configuration.PayloadAlignment,
[&](const BlockStoreLocation& BlockStoreLocation) {
+ ZEN_MEMSCOPE(GetCacheDiskTag());
ZEN_TRACE_CPU("Z$::Bucket::UpdateLocation");
DiskLocation Location(BlockStoreLocation, m_Configuration.PayloadAlignment, EntryFlags);
m_SlogFile.Append({.Key = HashKey, .Location = Location});
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<IoBuffer> Chunks, std::span<IoHash>
ZEN_ASSERT(Chunks.size() == ChunkHashes.size());
std::vector<CasStore::InsertResult> Result(Chunks.size());
std::vector<size_t> 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<IoBuffer> Chunks, std::span<IoHash>
size_t ChunkOffset = 0;
m_BlockStore.WriteChunks(Datas, m_PayloadAlignment, [&](std::span<BlockStoreLocation> Locations) {
+ ZEN_MEMSCOPE(GetCasContainerTag());
std::vector<CasDiskIndexEntry> IndexEntries;
for (const BlockStoreLocation& Location : Locations)
{