#include <MallocOpts.h>
Public Types | |
typedef MallocOpts::opt_type | opt_type |
Public Member Functions | |
void | adjustMallocParams () |
std::string | error_message () const |
MallocOpts | get () const |
bool | hasErrors () const |
MallocOptionSetter () | |
bool | retrieveFromCpuType () |
bool | retrieveFromEnv () |
void | set_mmap_max (opt_type mmap_max) |
void | set_mmap_thr (opt_type mmap_thr) |
void | set_top_pad (opt_type top_pad) |
void | set_trim_thr (opt_type trim_thr) |
Private Attributes | |
bool | changed_ |
std::string | error_message_ |
MallocOpts | values_ |
Definition at line 64 of file MallocOpts.h.
Definition at line 67 of file MallocOpts.h.
edm::MallocOptionSetter::MallocOptionSetter | ( | ) |
Definition at line 143 of file MallocOpts.cc.
References adjustMallocParams(), dtNoiseDBValidation_cfg::cerr, error_message_, hasErrors(), retrieveFromCpuType(), and retrieveFromEnv().
: changed_(false) { if(retrieveFromEnv() || retrieveFromCpuType()) { adjustMallocParams(); if(hasErrors()) { std::cerr << "ERROR: Reset of malloc options has fails:\n" << error_message_ << "\n"; } } }
void edm::MallocOptionSetter::adjustMallocParams | ( | ) |
Definition at line 157 of file MallocOpts.cc.
References changed_, error_message_, edm::MallocOpts::mmap_max_, edm::MallocOpts::mmap_thr_, edm::MallocOpts::top_pad_, edm::MallocOpts::trim_thr_, and values_.
Referenced by MallocOptionSetter(), and edm::service::SimpleMemoryCheck::SimpleMemoryCheck().
{ if(changed_==false) return; // only adjust if they changed error_message_.clear(); changed_ = false; #ifdef M_MMAP_MAX if(mallopt(M_MMAP_MAX,values_.mmap_max_)<0) error_message_ += "Could not set M_MMAP_MAX\n"; #endif #ifdef M_TRIM_THRESHOLD if(mallopt(M_TRIM_THRESHOLD,values_.trim_thr_)<0) error_message_ += "Could not set M_TRIM_THRESHOLD\n"; #endif #ifdef M_TOP_PAD if(mallopt(M_TOP_PAD,values_.top_pad_)<0) error_message_ += "ERROR: Could not set M_TOP_PAD\n"; #endif #ifdef M_MMAP_THRESHOLD if(mallopt(M_MMAP_THRESHOLD,values_.mmap_thr_)<0) error_message_ += "ERROR: Could not set M_MMAP_THRESHOLD\n"; #endif }
std::string edm::MallocOptionSetter::error_message | ( | ) | const [inline] |
Definition at line 74 of file MallocOpts.h.
References error_message_.
Referenced by edm::service::SimpleMemoryCheck::SimpleMemoryCheck().
{ return error_message_; }
MallocOpts edm::MallocOptionSetter::get | ( | void | ) | const [inline] |
Definition at line 85 of file MallocOpts.h.
References values_.
Referenced by edm::service::SimpleMemoryCheck::SimpleMemoryCheck().
{ return values_; }
bool edm::MallocOptionSetter::hasErrors | ( | ) | const [inline] |
Definition at line 73 of file MallocOpts.h.
References error_message_.
Referenced by MallocOptionSetter(), and edm::service::SimpleMemoryCheck::SimpleMemoryCheck().
{ return !error_message_.empty(); }
bool edm::MallocOptionSetter::retrieveFromCpuType | ( | ) |
Definition at line 117 of file MallocOpts.cc.
References changed_, and values_.
Referenced by MallocOptionSetter().
bool edm::MallocOptionSetter::retrieveFromEnv | ( | ) |
Definition at line 181 of file MallocOpts.cc.
References dtNoiseDBValidation_cfg::cerr, changed_, gather_cfg::cout, edm::MallocOpts::mmap_max_, edm::MallocOpts::mmap_thr_, edm::MallocOpts::top_pad_, edm::MallocOpts::trim_thr_, and values_.
Referenced by MallocOptionSetter().
{ const char* par = getenv("CMSRUN_MALLOC_RESET"); if(par==0) return false; // leave quickly here std::string spar(par); bool rc = false; // CMSRUN_MALLOC_RESET = "mmap_max trim_thres top_pad mmap_thres" if(spar.size()>1) { std::istringstream ist(spar); ist >> values_.mmap_max_ >> values_.trim_thr_ >> values_.top_pad_ >> values_.mmap_thr_; if(ist.bad()) { std::cerr << "bad malloc options in CMSRUN_MALLOC_RESET: " << spar << "\n" << "format is: " << "CMSRUN_MALLOC_RESET=\"mmap_max trim_thres top_pad mmap_thres\"\n"; } else { std::cout << "MALLOC_OPTIONS> Reset options: " << "CMSRUN_MALLOC_RESET=" << par << "\n"; } rc=true; changed_=true; } return rc; }
void edm::MallocOptionSetter::set_mmap_max | ( | opt_type | mmap_max | ) | [inline] |
Definition at line 76 of file MallocOpts.h.
References changed_, edm::MallocOpts::mmap_max_, and values_.
Referenced by edm::service::SimpleMemoryCheck::SimpleMemoryCheck().
void edm::MallocOptionSetter::set_mmap_thr | ( | opt_type | mmap_thr | ) | [inline] |
Definition at line 82 of file MallocOpts.h.
References changed_, edm::MallocOpts::mmap_thr_, and values_.
Referenced by edm::service::SimpleMemoryCheck::SimpleMemoryCheck().
void edm::MallocOptionSetter::set_top_pad | ( | opt_type | top_pad | ) | [inline] |
Definition at line 80 of file MallocOpts.h.
References changed_, edm::MallocOpts::top_pad_, and values_.
Referenced by edm::service::SimpleMemoryCheck::SimpleMemoryCheck().
void edm::MallocOptionSetter::set_trim_thr | ( | opt_type | trim_thr | ) | [inline] |
Definition at line 78 of file MallocOpts.h.
References changed_, edm::MallocOpts::trim_thr_, and values_.
Referenced by edm::service::SimpleMemoryCheck::SimpleMemoryCheck().
bool edm::MallocOptionSetter::changed_ [private] |
Definition at line 88 of file MallocOpts.h.
Referenced by adjustMallocParams(), retrieveFromCpuType(), retrieveFromEnv(), set_mmap_max(), set_mmap_thr(), set_top_pad(), and set_trim_thr().
std::string edm::MallocOptionSetter::error_message_ [private] |
Definition at line 91 of file MallocOpts.h.
Referenced by adjustMallocParams(), error_message(), hasErrors(), and MallocOptionSetter().
MallocOpts edm::MallocOptionSetter::values_ [private] |
Definition at line 89 of file MallocOpts.h.
Referenced by adjustMallocParams(), get(), retrieveFromCpuType(), retrieveFromEnv(), set_mmap_max(), set_mmap_thr(), set_top_pad(), and set_trim_thr().