CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BlockWipedAllocatorService.cc
Go to the documentation of this file.
4 
6 #include <iostream>
7 
8 
10 
11 
12 namespace {
13  struct Dumper {
14  void visit(BlockWipedAllocator const& alloc) const {
15  BlockWipedAllocator::Stat sa1 = alloc.stat();
16  std::cout << "Alloc for size " << sa1.typeSize
17  << ": " << sa1.blockSize
18  << ", " << sa1.currentOccupancy
19  << "/" << sa1.currentAvailable
20  << ", " << sa1.totalAvailable
21  << "/" << sa1.nBlocks
22  << ", " << sa1.alive
23  << std::endl;
24  }
25 
26  };
27 
28 }
29 
33 private:
34  bool m_useAlloc;
35  bool m_silent;
36  bool m_dump;
39 public:
41  edm::ActivityRegistry & iAR ) :
42  pool( std::max(256,iConfig.getUntrackedParameter<int>("blockSize",1024)),
43  std::max(256,iConfig.getUntrackedParameter<int>("recyclerSize",4096))
44  ) {
45 
46  m_useAlloc = iConfig.getUntrackedParameter<bool>("usePoolAllocator",false);
47  m_silent = iConfig.getUntrackedParameter<bool>("silent",true);
48  m_dump = iConfig.getUntrackedParameter<bool>("dumpEachModule",false);
49  m_clearFreq = std::max(1,iConfig.getUntrackedParameter<int>("clearFrequency",20));
50 
58  }
59 
60  // wipe the workspace before each event
62 
63  // nope event-principal deleted in source
64  void preSource() {
65  // wiper();
66  }
67 
68  void dump() {
69  if (m_silent) return;
70  std::cout << "ReferenceCounted stat"<< std::endl;
71  std::cout << "still alive/referenced "
74  << std::endl;
75 
76  std::cout << "BlockAllocator stat"<< std::endl;
77  std::cout << "still alive " << BlockWipedPoolAllocated::s_alive << std::endl;
78  Dumper dumper;
79  blockWipedPool().visit(dumper);
80  }
81 
82 
83  void wiper() {
84  dump();
85  blockWipedPool().wipe();
86  // blockWipedPool().clear(); // try to crash
87  {
88  static int c=0;
89  c++;
90  if (m_clearFreq==c) {
92  c=0;
93  }
94  }
95 
96  }
97 
98  // wipe before each module (no, obj in event....)
99  void preModule(const edm::ModuleDescription& desc){
100  blockWipedPool().wipe(false);
101  }
102 
104  if (m_dump) dump();
105  }
106 
107  // final stat
108  void postEndJob() {
109  wiper();
110  }
111 
112 };
113 
114 
115 
T getUntrackedParameter(std::string const &, T const &) const
void preModule(const edm::ModuleDescription &desc)
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
void watchPostModule(PostModule::slot_type const &iSlot)
void watchPreProcessEvent(PreProcessEvent::slot_type const &iSlot)
BlockWipedPool & blockWipedPool(BlockWipedPool *p=0)
def visit
Retrieve data from a perf suite output (sub) directory, only examines TimeSize at the moment...
void watchPreModule(PreModule::slot_type const &iSlot)
void preEventProcessing(const edm::EventID &, const edm::Timestamp &)
const T & max(const T &a, const T &b)
void watchPreSource(PreSource::slot_type const &iSlot)
#define DEFINE_FWK_SERVICE(type)
Definition: ServiceMaker.h:113
void visit(Visitor &visitor) const
void wipe(bool force=true)
void postModule(const edm::ModuleDescription &desc)
BlockWipedAllocatorService(const edm::ParameterSet &iConfig, edm::ActivityRegistry &iAR)
tuple cout
Definition: gather_cfg.py:121