From fdb98ab4e6f1b654928eb37a37514a1e06074fb1 Mon Sep 17 00:00:00 2001 From: Alja Mrak-Tadel Date: Tue, 12 Apr 2016 13:48:27 -0700 Subject: [PATCH] Merge configuration parameters prefetch and prefetch_max_blocks. --- src/XrdFileCache/XrdFileCache.hh | 3 +-- src/XrdFileCache/XrdFileCacheConfiguration.cc | 21 ++++++++++++------- src/XrdFileCache/XrdFileCacheFile.cc | 6 +++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/XrdFileCache/XrdFileCache.hh b/src/XrdFileCache/XrdFileCache.hh index e23aeefadf0..0341a6f0397 100644 --- a/src/XrdFileCache/XrdFileCache.hh +++ b/src/XrdFileCache/XrdFileCache.hh @@ -52,8 +52,7 @@ namespace XrdFileCache m_diskUsageLWM(-1), m_diskUsageHWM(-1), m_bufferSize(1024*1024), - m_NRamBuffers(8000), - m_prefetch(false), + m_NRamBuffers(8000), m_prefetch_max_blocks(10), m_hdfsbsize(128*1024*1024) {} diff --git a/src/XrdFileCache/XrdFileCacheConfiguration.cc b/src/XrdFileCache/XrdFileCacheConfiguration.cc index 4d3b86f2338..61a634a670d 100644 --- a/src/XrdFileCache/XrdFileCacheConfiguration.cc +++ b/src/XrdFileCache/XrdFileCacheConfiguration.cc @@ -251,13 +251,20 @@ bool Cache::ConfigParameters(std::string part, XrdOucStream& config ) } else if (part == "prefetch" ) { - int p = ::atoi(config.GetWord()); - if (p > 0) { - printf("prefetch enabled, max blocks per file=%d\n", p); - m_configuration.m_prefetch = true; - m_configuration.m_prefetch_max_blocks = p; - } else { - m_configuration.m_prefetch = false; + const char* params = config.GetWord(); + if (params) { + int p = ::atoi(config.GetWord()); + if (p > 0) { + printf("prefetch enabled, max blocks per file=%d\n", p); + m_configuration.m_prefetch_max_blocks = p; + } else { + m_log.Emsg("Config", "Prefetch is disabled"); + m_configuration.m_prefetch_max_blocks = 0; + } + } + { + m_log.Emsg("Config", "Error setting prefetch level."); + return false; } } else if (part == "nram" ) diff --git a/src/XrdFileCache/XrdFileCacheFile.cc b/src/XrdFileCache/XrdFileCacheFile.cc index 502bd1c1e19..6c8a09ccbbc 100644 --- a/src/XrdFileCache/XrdFileCacheFile.cc +++ b/src/XrdFileCache/XrdFileCacheFile.cc @@ -74,7 +74,7 @@ File::File(XrdOucCacheIO2 *inputIO, std::string& disk_file_path, long long iOffs m_input(inputIO), m_output(NULL), m_infoFile(NULL), -m_cfi(Cache::GetInstance().RefConfiguration().m_bufferSize, Cache::GetInstance().RefConfiguration().m_prefetch), +m_cfi(Cache::GetInstance().RefConfiguration().m_bufferSize, Cache::GetInstance().RefConfiguration().m_prefetch_max_blocks > 0), m_temp_filename(disk_file_path), m_offset(iOffset), m_fileSize(iFileSize), @@ -927,7 +927,7 @@ void File::Prefetch() //______________________________________________________________________________ void File::CheckPrefetchStatRAM(Block* b) { - if (Cache::GetInstance().RefConfiguration().m_prefetch) { + if (Cache::GetInstance().RefConfiguration().m_prefetch_max_blocks) { if (b->m_prefetch) { m_prefetchHitCnt++; m_prefetchScore = float(m_prefetchHitCnt)/m_prefetchReadCnt; @@ -938,7 +938,7 @@ void File::CheckPrefetchStatRAM(Block* b) //______________________________________________________________________________ void File::CheckPrefetchStatDisk(int idx) { - if (Cache::GetInstance().RefConfiguration().m_prefetch) { + if (Cache::GetInstance().RefConfiguration().m_prefetch_max_block) { if (m_cfi.TestPrefetchBit(idx)) m_prefetchHitCnt++; }