From 005f76adc5a9d4b5c3aea46e66c54f085751082c Mon Sep 17 00:00:00 2001 From: Alja Mrak-Tadel Date: Wed, 7 Jun 2017 14:24:08 -0700 Subject: [PATCH] Alter ram limits and blocks size parameter if caching is on the client side. --- src/XrdFileCache/XrdFileCache.cc | 5 +++-- src/XrdFileCache/XrdFileCache.hh | 2 +- src/XrdFileCache/XrdFileCacheConfiguration.cc | 20 ++++++++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/XrdFileCache/XrdFileCache.cc b/src/XrdFileCache/XrdFileCache.cc index b02223e7c42..4e1703641ef 100644 --- a/src/XrdFileCache/XrdFileCache.cc +++ b/src/XrdFileCache/XrdFileCache.cc @@ -147,7 +147,8 @@ Cache::Cache() : XrdOucCache(), m_trace(0), m_traceID("Manager"), m_prefetch_condVar(0), - m_RAMblocks_used(0) + m_RAMblocks_used(0), + m_isClient(false) { m_trace = new XrdOucTrace(&m_log); // default log level is Warning @@ -340,7 +341,7 @@ void Cache::schedule_file_sync(File* f, bool ref_cnt_already_set) { DiskSyncer* ds = new DiskSyncer(f); if ( ! ref_cnt_already_set) inc_ref_cnt(f, true); - if (isClient) ds->DoIt(); + if (m_isClient) ds->DoIt(); else if (schedP) schedP->Schedule(ds); else {pthread_t tid; XrdSysThread::Run(&tid, callDoIt, ds, 0, "DiskSyncer"); diff --git a/src/XrdFileCache/XrdFileCache.hh b/src/XrdFileCache/XrdFileCache.hh index d76303cba71..006eeffd57c 100644 --- a/src/XrdFileCache/XrdFileCache.hh +++ b/src/XrdFileCache/XrdFileCache.hh @@ -241,7 +241,7 @@ private: XrdSysMutex m_RAMblock_mutex; //!< central lock for this class int m_RAMblocks_used; - bool isClient; //!< True if running as client + bool m_isClient; //!< True if running as client struct WriteQ { diff --git a/src/XrdFileCache/XrdFileCacheConfiguration.cc b/src/XrdFileCache/XrdFileCacheConfiguration.cc index c40c6e367ae..6aabbdccdb1 100644 --- a/src/XrdFileCache/XrdFileCacheConfiguration.cc +++ b/src/XrdFileCache/XrdFileCacheConfiguration.cc @@ -110,7 +110,7 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char // Indicate whether or not we are a client instance // - isClient = (strncmp("*client ", theINS, 8) != 0); + m_isClient = (strncmp("*client ", theINS, 8) != 0); XrdOucEnv myEnv; XrdOucStream Config(&m_log, theINS, &myEnv, "=====> "); @@ -148,6 +148,11 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char return false; } + // minimize buffersize in case of client caching + if ( m_isClient) { + m_configuration.m_bufferSize = 256 * 1024 * 124; + } + // Actual parsing of the config file. bool retval = true; @@ -241,12 +246,13 @@ bool Cache::Config(XrdSysLogger *logger, const char *config_filename, const char // get number of available RAM blocks after process configuration if (m_configuration.m_RamAbsAvailable == 0) { - TRACE(Error, "RAM usage not specified. pfc.ram is a required configuration directive since release 4.6.\n" - " As a temporary measure default of 8 GB is being used. This will be discontinued in release 5."); - m_configuration.m_RamAbsAvailable = 8ll * 1024 * 1024 * 1024; - // return false; + m_configuration.m_RamAbsAvailable = m_isClient ? 256ll * 1024 * 1024 : 1024 * 1024 * 1024; + char buff2[1024]; + snprintf(buff2, sizeof(buff2), "RAM usage is not specified. Default value %s is used.", m_isClient ? "256m" : "8g"); + TRACE(Warning, buff2); } m_configuration.m_NRamBuffers = static_cast(m_configuration.m_RamAbsAvailable/ m_configuration.m_bufferSize); + // Set tracing to debug if this is set in environment char* cenv = getenv("XRDDEBUG"); @@ -263,7 +269,7 @@ 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\n" + " pfc.trace ooo %d\n" " pfc.flush %lld", config_filename, m_configuration.m_bufferSize, @@ -382,7 +388,7 @@ bool Cache::ConfigParameters(std::string part, XrdOucStream& config, TmpConfigur } else if ( part == "ram" ) { - long long minRAM = 1024 * 1024 * 1024; + long long minRAM = m_isClient ? 256 * 1024 * 1024 : 1024 * 1024 * 1024; long long maxRAM = 256 * minRAM; if ( XrdOuca2x::a2sz(m_log, "get RAM available", config.GetWord(), &m_configuration.m_RamAbsAvailable, minRAM, maxRAM)) {