Skip to content

Commit

Permalink
Add configuration parameter for flush frequency.
Browse files Browse the repository at this point in the history
  • Loading branch information
alja committed May 12, 2017
1 parent c7e54a5 commit 2063ee6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/XrdFileCache/XrdFileCache.hh
Expand Up @@ -60,7 +60,8 @@ struct Configuration
m_RamAbsAvailable(0),
m_NRamBuffers(-1),
m_prefetch_max_blocks(10),
m_hdfsbsize(128*1024*1024)
m_hdfsbsize(128*1024*1024),
m_flushCnt(100)
{}

bool m_hdfsmode; //!< flag for enabling block-level operation
Expand All @@ -79,15 +80,17 @@ struct Configuration
size_t m_prefetch_max_blocks; //!< maximum number of blocks to prefetch per file

long long m_hdfsbsize; //!< used with m_hdfsmode, default 128MB
long long m_flushCnt; //!< nuber of unsynced blcoks on disk before flush is called
};

struct TmpConfiguration
{
std::string m_diskUsageLWM;
std::string m_diskUsageHWM;
std::string m_flushRaw;

TmpConfiguration() :
m_diskUsageLWM("0.90"), m_diskUsageHWM("0.95")
m_diskUsageLWM("0.90"), m_diskUsageHWM("0.95"), m_flushRaw("100")
{}
};

Expand Down
29 changes: 27 additions & 2 deletions src/XrdFileCache/XrdFileCacheConfiguration.cc
Expand Up @@ -220,6 +220,23 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char
}
}

// sets flush frequency
{
if (::isalpha(*(tmpc.m_flushRaw.rbegin())))
{
if (XrdOuca2x::a2sz(m_log, "Error getting number of blocks to flush", tmpc.m_flushRaw.c_str(), &m_configuration.m_flushCnt, 100*m_configuration.m_bufferSize , 5000*m_configuration.m_bufferSize))
{
return false;
}
m_configuration.m_flushCnt /= m_configuration.m_bufferSize;
}
else
{
m_configuration.m_flushCnt = ::atol(tmpc.m_flushRaw.c_str());
}
}


// get number of available RAM blocks after process configuration
if (m_configuration.m_RamAbsAvailable == 0)
{
Expand All @@ -245,7 +262,8 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char
" pfc.ram %.fg\n"
" pfc.diskusage %lld %lld sleep %d\n"
" pfc.spaces %s %s\n"
" pfc.trace %d",
" pfc.trace %d\n"
" pfc.flush %lld",
config_filename,
m_configuration.m_bufferSize,
m_configuration.m_prefetch_max_blocks,
Expand All @@ -255,7 +273,10 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char
m_configuration.m_purgeInterval,
m_configuration.m_data_space.c_str(),
m_configuration.m_meta_space.c_str(),
m_trace->What);
m_trace->What,
m_configuration.m_flushCnt);



if (m_configuration.m_hdfsmode)
{
Expand Down Expand Up @@ -408,6 +429,10 @@ bool Cache::ConfigParameters(std::string part, XrdOucStream& config, TmpConfigur
}
}
}
else if ( part == "flush" )
{
tmpc.m_flushRaw = config.GetWord();
}
else
{
m_log.Emsg("Cache::ConfigParameters() unmatched pfc parameter", part.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/XrdFileCache/XrdFileCacheFile.cc
Expand Up @@ -748,7 +748,7 @@ void File::WriteBlockToDisk(Block* b)
{
m_cfi.SetBitSynced(pfIdx);
++m_non_flushed_cnt;
if (m_non_flushed_cnt >= 100)
if (m_non_flushed_cnt >= Cache::GetInstance().RefConfiguration().m_flushCnt)
{
schedule_sync = true;
m_in_sync = true;
Expand Down

0 comments on commit 2063ee6

Please sign in to comment.