Skip to content

Commit

Permalink
Merge pull request #19398 from ghalliday/issue32808
Browse files Browse the repository at this point in the history
HPCC-32808 Allow node caches > 4GB in size

Reviewed-By: Dan S. Camper <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Jan 14, 2025
2 parents c3adb18 + 508b5aa commit ed54571
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions roxie/ccd/ccdmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1313,11 +1313,11 @@ int CCD_API roxie_main(int argc, const char *argv[], const char * defaultYaml)

setKeyIndexCacheSize((unsigned)-1); // unbound
nodeCacheMB = topology->getPropInt("@nodeCacheMem", 100);
setNodeCacheMem(nodeCacheMB * 0x100000);
setNodeCacheMem(nodeCacheMB * 0x100000ULL);
leafCacheMB = topology->getPropInt("@leafCacheMem", 50);
setLeafCacheMem(leafCacheMB * 0x100000);
setLeafCacheMem(leafCacheMB * 0x100000ULL);
blobCacheMB = topology->getPropInt("@blobCacheMem", 0);
setBlobCacheMem(blobCacheMB * 0x100000);
setBlobCacheMem(blobCacheMB * 0x100000ULL);
if (topology->hasProp("@nodeFetchThresholdNs"))
setNodeFetchThresholdNs(topology->getPropInt64("@nodeFetchThresholdNs"));
setIndexWarningThresholds(topology);
Expand Down
6 changes: 3 additions & 3 deletions roxie/ccd/ccdstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2318,7 +2318,7 @@ class CRoxiePackageSetManager : implements IRoxieQueryPackageManagerSet, impleme
{
blobCacheMB = control->getPropInt("@val", 0);
topology->setPropInt("@blobCacheMem", blobCacheMB);
setBlobCacheMem(blobCacheMB * 0x100000);
setBlobCacheMem(blobCacheMB * 0x100000ULL);
}
else
unknown = true;
Expand Down Expand Up @@ -2549,7 +2549,7 @@ class CRoxiePackageSetManager : implements IRoxieQueryPackageManagerSet, impleme
{
leafCacheMB = control->getPropInt("@val", 50);
topology->setPropInt("@leafCacheMem", leafCacheMB);
setLeafCacheMem(leafCacheMB * 0x100000);
setLeafCacheMem(leafCacheMB * 0x100000ULL);
}
else if (stricmp(queryName, "control:listFileOpenErrors")==0)
{
Expand Down Expand Up @@ -2656,7 +2656,7 @@ class CRoxiePackageSetManager : implements IRoxieQueryPackageManagerSet, impleme
{
nodeCacheMB = control->getPropInt("@val", 100);
topology->setPropInt("@nodeCacheMem", nodeCacheMB);
setNodeCacheMem(nodeCacheMB * 0x100000);
setNodeCacheMem(nodeCacheMB * 0x100000ULL);
}
else if (stricmp(queryName, "control:numFilesToProcess")==0)
{
Expand Down
34 changes: 17 additions & 17 deletions system/jhtree/jhtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,18 +695,18 @@ class DelayedCacheEntryReleaser : public IRemovedMappingCallback
typedef OwningSimpleHashTableOf<CNodeMapping, CKeyIdAndPos> CNodeTable;
class CNodeMRUSubCache final : public CMRUCacheOf<CKeyIdAndPos, CNodeCacheEntry, CNodeMapping, CNodeTable>
{
std::atomic<size32_t> sizeInMem{0};
size32_t memLimit = 0;
std::atomic<size_t> sizeInMem{0};
size_t memLimit = 0;
public:
mutable CriticalSection lock;
RelaxedAtomic<__uint64> numHits{0};
RelaxedAtomic<__uint64> numAdds{0};
RelaxedAtomic<__uint64> numDups{0};
RelaxedAtomic<__uint64> numEvicts{0};

size32_t setMemLimit(size32_t _memLimit)
size_t setMemLimit(size_t _memLimit)
{
size32_t oldMemLimit = memLimit;
size_t oldMemLimit = memLimit;
memLimit = _memLimit;
if (full())
makeSpace(nullptr);
Expand All @@ -722,7 +722,7 @@ class CNodeMRUSubCache final : public CMRUCacheOf<CKeyIdAndPos, CNodeCacheEntry,
{
CNodeMapping *tail = mruList.tail();
if (unlikely(!tail))
throw makeStringExceptionV(9999, "Index cache appears full but contains no entries size=%x limit=%x", sizeInMem.load(), memLimit);
throw makeStringExceptionV(9999, "Index cache appears full but contains no entries size=%zx limit=%zx", sizeInMem.load(), memLimit);

//Never evict an entry that hasn't yet loaded - otherwise the sizeInMem can become inconsistent
//When running with slow remote storage this can take a long time to be ready - so we need
Expand All @@ -749,7 +749,7 @@ class CNodeMRUSubCache final : public CMRUCacheOf<CKeyIdAndPos, CNodeCacheEntry,
}
virtual bool full()
{
if (((size32_t)-1) == memLimit) return false;
if (((size_t)-1) == memLimit) return false;
return sizeInMem > memLimit;
}
virtual void elementRemoved(CNodeMapping *mapping)
Expand Down Expand Up @@ -782,7 +782,7 @@ class CNodeMRUSubCache final : public CMRUCacheOf<CKeyIdAndPos, CNodeCacheEntry,
void traceState(StringBuffer & out)
{
//Should be safe to call outside of a critical section, but values may be inconsistent
out.append(table.ordinality()).append(":").append(sizeInMem);
out.append(table.ordinality()).append(":").append((__uint64)sizeInMem);
out.appendf(" [%" I64F "u:%" I64F "u:%" I64F "u:%" I64F "u]", numHits.load(), numAdds.load(), numDups.load(), numEvicts.load());
}
unsigned __int64 getStatisticValue(StatisticKind kind) const
Expand Down Expand Up @@ -875,9 +875,9 @@ class CNodeMRUCache
cache[j].reportEntries(cacheInfo);
}

size32_t setCacheMem(size32_t newSize)
size_t setCacheMem(size_t newSize)
{
unsigned oldV = 0;
size_t oldV = 0;
for (unsigned i=0; i < cacheBuckets; i++)
{
CriticalBlock block(cache[i].lock);
Expand Down Expand Up @@ -915,7 +915,7 @@ class CNodeCache : public CInterface
CNodeMRUCache cache[CacheMax] = { CacheBranch, CacheLeaf, CacheBlob };
std::vector<std::shared_ptr<hpccMetrics::IMetric>> metrics;
public:
CNodeCache(size32_t maxNodeMem, size32_t maxLeaveMem, size32_t maxBlobMem)
CNodeCache(size_t maxNodeMem, size_t maxLeaveMem, size_t maxBlobMem)
{
setNodeCacheMem(maxNodeMem);
setLeafCacheMem(maxLeaveMem);
Expand All @@ -925,15 +925,15 @@ class CNodeCache : public CInterface
const CJHTreeNode *getCachedNode(const INodeLoader *key, unsigned keyID, offset_t pos, NodeType type, IContextLogger *ctx, bool isTLK);
void getCacheInfo(ICacheInfoRecorder &cacheInfo);

inline size32_t setNodeCacheMem(size32_t newSize)
inline size_t setNodeCacheMem(size_t newSize)
{
return setCacheMem(newSize, CacheBranch);
}
inline size32_t setLeafCacheMem(size32_t newSize)
inline size_t setLeafCacheMem(size_t newSize)
{
return setCacheMem(newSize, CacheLeaf);
}
inline size32_t setBlobCacheMem(size32_t newSize)
inline size_t setBlobCacheMem(size_t newSize)
{
return setCacheMem(newSize, CacheBlob);
}
Expand Down Expand Up @@ -965,7 +965,7 @@ class CNodeCache : public CInterface
}

protected:
size32_t setCacheMem(size32_t newSize, CacheType type)
size_t setCacheMem(size_t newSize, CacheType type)
{
return cache[type].setCacheMem(newSize);
}
Expand Down Expand Up @@ -2825,17 +2825,17 @@ extern jhtree_decl void resetIndexMetrics()
queryKeyStore()->resetMetrics();
}

extern jhtree_decl size32_t setNodeCacheMem(size32_t cacheSize)
extern jhtree_decl size_t setNodeCacheMem(size_t cacheSize)
{
return queryNodeCache()->setNodeCacheMem(cacheSize);
}

extern jhtree_decl size32_t setLeafCacheMem(size32_t cacheSize)
extern jhtree_decl size_t setLeafCacheMem(size_t cacheSize)
{
return queryNodeCache()->setLeafCacheMem(cacheSize);
}

extern jhtree_decl size32_t setBlobCacheMem(size32_t cacheSize)
extern jhtree_decl size_t setBlobCacheMem(size_t cacheSize)
{
return queryNodeCache()->setBlobCacheMem(cacheSize);
}
Expand Down
6 changes: 3 additions & 3 deletions system/jhtree/jhtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ extern jhtree_decl unsigned setKeyIndexCacheSize(unsigned limit);
extern jhtree_decl void clearNodeCache();
extern jhtree_decl void logCacheState();
// these methods return previous values
extern jhtree_decl size32_t setNodeCacheMem(size32_t cacheSize);
extern jhtree_decl size32_t setLeafCacheMem(size32_t cacheSize);
extern jhtree_decl size32_t setBlobCacheMem(size32_t cacheSize);
extern jhtree_decl size_t setNodeCacheMem(size_t cacheSize);
extern jhtree_decl size_t setLeafCacheMem(size_t cacheSize);
extern jhtree_decl size_t setBlobCacheMem(size_t cacheSize);
extern jhtree_decl void setNodeFetchThresholdNs(__uint64 thresholdNs);
extern jhtree_decl void setIndexWarningThresholds(IPropertyTree * options);

Expand Down

0 comments on commit ed54571

Please sign in to comment.