ATLAS Offline Software
Classes | Namespaces | Typedefs | Functions
SemiDetMisc.h File Reference
#include "PerfMonEvent/mallinfo.h"
#include "CxxUtils/checker_macros.h"
#include <sys/time.h>
#include <fcntl.h>
#include <ctime>
#include <cassert>
#include <cstring>
#include <climits>
#include <limits>
#include <sstream>
#include <string>
#include <map>
#include <unordered_map>
#include <cmath>
#include <cstdlib>
#include <dlfcn.h>
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PMonSD::Meas
 
class  PMonSD::CompDataBasic
 
class  PMonSD::CompDataExtended
 
struct  PMonSD::CompDataStdSteps
 
class  PMonSD::FastStrCmp
 
class  PMonSD::StepWrapper
 
class  PMonSD::StepWrapperStd
 
class  PMonSD::StepWrapperOther
 

Namespaces

 PMonSD
 

Typedefs

typedef std::pair< std::string, std::string > PMonSD::OtherKey
 
typedef std::map< std::string, CompDataStdSteps, FastStrCmp > PMonSD::MapStdSteps
 
typedef std::map< OtherKey, CompDataBasic, FastStrCmp > PMonSD::MapOtherSteps
 

Functions

void PMonSD::get_vmem_rss_kb (double &vmem, double &rss, bool vmemonly=false)
 
double get_malloc_kb PMonSD::ATLAS_NOT_THREAD_SAFE ()
 
double PMonSD::get_vmem_kb ()
 
double PMonSD::get_rss_kb ()
 
double PMonSD::get_cpu_ms ()
 
double PMonSD::get_wall_ms ()
 
void PMonSD::setUTCTimeString (std::string &s, double offset_ms=0)
 
unsigned PMonSD::vmpeak ()
 
std::string PMonSD::get_field (const char *filename, const std::string &fieldname, char space='_')
 
int64_t PMonSD::clock_nooverflow ()
 
std::string PMonSD::cpu_model ()
 
int PMonSD::bogomips ()
 
const char * PMonSD::envvar (const char *e, const char *def="")
 
bool PMonSD::envvar_is_set (const char *e)
 
unsigned long PMonSD::system_boot_time_seconds ()
 
double PMonSD::get_absolute_wall_ms ()
 
double PMonSD::secs_per_jiffy ()
 
double PMonSD::jobstart_jiffy2unix_ms (const std::string &s)
 
const char * PMonSD::symb2lib (const char *symbol, const char *failstr="unknown")
 
double PMonSD::get_malloc_kb ATLAS_NOT_THREAD_SAFE ()
 Install fatal handler with default options. More...
 

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

double PMonSD::get_malloc_kb ATLAS_NOT_THREAD_SAFE ( )
inline

Install fatal handler with default options.

This is meant to be easy to call from python via ctypes.

Definition at line 474 of file SemiDetMisc.h.

474  {
475 #ifndef __linux
476  return 0.0;
477 #else
478  //~0.2microsec/call under libc malloc, 4microsec/call under tcmalloc (mallinfo() call dominates).
479  //NB: Bug in http://sourceware.org/bugzilla/show_bug.cgi?id=4349
480  //makes mallinfo quite slow for fragmented processes on libc<=2.5 (like on SLC5)
482  //mallinfo fields are always "int" which is pretty annoying. As long
483  //as the true amount of mallocs between two calls does not change
484  //more than 2GB, we can work around this with the following ugly
485  //code, repeated for each of the two fields we are looking at:
486  int64_t uordblks_raw = m.uordblks;
487  if (sizeof(m.uordblks)==sizeof(int32_t)) {
488  //assert(typeid(m.uordblks)==typeid(int32_t));
489  const int64_t half_range =std::numeric_limits<int32_t>::max();
490  static int64_t last_uordblks=m.uordblks;
491  static int64_t offset_uordblks=0;
492  if (uordblks_raw-last_uordblks>half_range) {
493  //underflow detected
494  offset_uordblks-=2*half_range;
495  } else if (last_uordblks-uordblks_raw>half_range) {
496  //overflow detected
497  offset_uordblks+=2*half_range;
498  }
499  last_uordblks=uordblks_raw;
500  uordblks_raw+=offset_uordblks;
501  }
502  //exact same code for hblkhd (a bit of code duplication...):
503  int64_t hblkhd_raw = m.hblkhd;
504  if (sizeof(m.hblkhd)==sizeof(int32_t)) {
505  //assert(typeid(m.hblkhd)==typeid(int32_t));
506  const int64_t half_range =std::numeric_limits<int32_t>::max();
507  static int64_t last_hblkhd=m.hblkhd;
508  static int64_t offset_hblkhd=0;
509  if (hblkhd_raw-last_hblkhd>half_range) {
510  //underflow detected
511  offset_hblkhd-=2*half_range;
512  } else if (last_hblkhd-hblkhd_raw>half_range) {
513  //overflow detected
514  offset_hblkhd+=2*half_range;
515  }
516  last_hblkhd=hblkhd_raw;
517  hblkhd_raw+=offset_hblkhd;
518  }
519  return (uordblks_raw+hblkhd_raw)/1024.0;
520 #endif
521 }
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
max
#define max(a, b)
Definition: cfImp.cxx:41
PerfMon::mallinfo
mallinfo_t mallinfo()
Definition: mallinfo.h:29
PerfMon::mallinfo_t
struct mallinfo mallinfo_t
Definition: mallinfo.h:28