From d6176c14d97215a52d9cce339eab54d51fbf9996 Mon Sep 17 00:00:00 2001 From: Alja Mrak-Tadel Date: Wed, 24 Jun 2015 16:41:21 -0700 Subject: [PATCH] Cache prefetch score. --- src/XrdFileCache/XrdFileCacheFile.cc | 12 ++++++------ src/XrdFileCache/XrdFileCacheFile.hh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/XrdFileCache/XrdFileCacheFile.cc b/src/XrdFileCache/XrdFileCacheFile.cc index 1e66f9efb33..82220abebf2 100644 --- a/src/XrdFileCache/XrdFileCacheFile.cc +++ b/src/XrdFileCache/XrdFileCacheFile.cc @@ -88,6 +88,7 @@ m_in_sync(false), m_downloadCond(0), m_prefetchReadCnt(0), m_prefetchHitCnt(0), +m_prefetchScore(1), m_prefetchCurrentCnt(0) { clLog()->Debug(XrdCl::AppMsg, "File::File() %s", m_input.Path()); @@ -805,7 +806,7 @@ void File::Prefetch() if (cache()->RequestRAMBlock()) { m_prefetchReadCnt++; - + m_prefetchScore = m_prefetchHitCnt/m_prefetchReadCnt; Block *b = RequestBlock(block_idx, true); inc_ref_count(b); } @@ -820,8 +821,10 @@ void File::Prefetch() void File::CheckPrefetchStatRAM(Block* b) { if (Factory::GetInstance().RefConfiguration().m_prefetch) { - if (b->m_prefetch) + if (b->m_prefetch) { m_prefetchHitCnt++; + m_prefetchScore = m_prefetchHitCnt/m_prefetchReadCnt; + } } } @@ -837,10 +840,7 @@ void File::CheckPrefetchStatDisk(int idx) //______________________________________________________________________________ float File::GetPrefetchScore() const { - if (m_prefetchReadCnt) - return m_prefetchHitCnt/m_prefetchReadCnt; - - return 1; // AMT not sure if this should be 0.5 ... ???? + return m_prefetchScore; } //______________________________________________________________________________ diff --git a/src/XrdFileCache/XrdFileCacheFile.hh b/src/XrdFileCache/XrdFileCacheFile.hh index 8656db34a30..975ec2eef54 100644 --- a/src/XrdFileCache/XrdFileCacheFile.hh +++ b/src/XrdFileCache/XrdFileCacheFile.hh @@ -126,8 +126,8 @@ namespace XrdFileCache int m_prefetchReadCnt; int m_prefetchHitCnt; + int m_prefetchScore; //cached int m_prefetchCurrentCnt; - // AMT should I cache prefetch score for optimization of Cache::getNextFileToPrefetch() ??? public: