Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-32808 Allow node caches > 4GB in size #19398

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any use to check if _memLimit == memLimit and bypass this work if true?

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 @@ -2713,17 +2713,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
Loading