19 #error "This source file can be built only for Linux platforms." 56 using namespace string_literals;
109 static constexpr
bool service_handle_allowed{
false};
112 template <
typename T>
116 template <
typename T>
133 void recordEventData(
Event const&
e,
string const&
step);
136 bool checkMallocConfig_(
string const&,
bool);
137 void recordPeakUsages_();
143 unique_ptr<cet::sqlite::Connection>
const db_;
150 EventID currentEventID_{EventID::invalidEvent()};
153 {
"Step",
"ModuleLabel",
"ModuleType",
"Vsize",
"RSS"}};
155 {
"Step",
"Run",
"SubRun",
"Event",
"Vsize",
"RSS"}};
204 config().includeMallocInfo())}
212 make_unique<memEventHeap_t>(*
db_,
217 make_unique<memModuleHeap_t>(*
db_,
226 <<
"Since " << nthreads
227 <<
" threads have been configured, only process-level\n" 228 "memory usage will be recorded at the end of the job.";
231 if (!
fileName_.empty() && nthreads == 1u) {
232 iReg.sPreModuleConstruction.watch([
this](
auto const&
md) {
235 iReg.sPostModuleConstruction.watch([
this](
auto const&
md) {
238 iReg.sPreModuleBeginJob.watch(
240 iReg.sPostModuleBeginJob.watch(
242 iReg.sPreModuleBeginRun.watch(
244 iReg.sPostModuleBeginRun.watch(
245 [
this](
auto const& mc) { this->
recordOtherData(mc,
"PostBeginRun"); });
246 iReg.sPreModuleBeginSubRun.watch([
this](
auto const& mc) {
249 iReg.sPostModuleBeginSubRun.watch([
this](
auto const& mc) {
258 iReg.sPreModule.watch([
this](
auto const& mc) {
261 iReg.sPostModule.watch([
this](
auto const& mc) {
264 iReg.sPreWriteEvent.watch([
this](
auto const& mc) {
267 iReg.sPostWriteEvent.watch([
this](
auto const& mc) {
270 iReg.sPreModuleEndSubRun.watch(
271 [
this](
auto const& mc) { this->
recordOtherData(mc,
"PreEndSubRun"); });
272 iReg.sPreModuleEndRun.watch(
274 iReg.sPreModuleEndJob.watch(
276 iReg.sPostModuleEndSubRun.watch(
277 [
this](
auto const& mc) { this->
recordOtherData(mc,
"PostEndSubRun"); });
278 iReg.sPostModuleEndRun.watch(
280 iReg.sPostModuleEndJob.watch(
299 LinuxProcData::getValueInMB<vsize_t>(
data),
300 LinuxProcData::getValueInMB<rss_t>(
data));
312 LinuxProcData::getValueInMB<vsize_t>(currentMemory),
313 LinuxProcData::getValueInMB<rss_t>(currentMemory));
341 LinuxProcData::getValueInMB<vsize_t>(currentMemory),
342 LinuxProcData::getValueInMB<rss_t>(currentMemory));
374 if (include && dbfilename.empty()) {
375 string const errmsg =
376 "\n'includeMallocInfo : true' is valid only if a nonempty db filename is specified:\n\n"s +
377 " MemoryTracker: {\n" 378 " includeMallocInfo: true\n" 380 " filename: \"your_filename.db\"\n" 421 .where(
"Name='VmPeak'");
424 .where(
"Name='VmHWM'");
427 log <<
'\n' << rule(
'=') <<
'\n';
428 log <<
std::left <<
"MemoryTracker summary (base-10 MB units used)\n\n";
429 log <<
" Peak virtual memory usage (VmPeak) : " <<
unique_value(rVMax)
431 <<
" Peak resident set size usage (VmHWM): " <<
unique_value(rRMax)
434 log <<
" Details saved in: '" <<
fileName_ <<
"'\n";
void insert(Args const ...)
double getVmHWM() const noexcept(false)
name_array< 11u > eventHeapColumns_
bool const includeMallocInfo_
T unique_value(query_result< T > const &r)
double getVmPeak() const noexcept(false)
auto const & pathName() const
art::LinuxProcData::rss_t rss_t
std::string const & moduleLabel() const
name_array< 9u > moduleColumns_
ChannelGroupService::Name Name
cet::sqlite::name_array< N > name_array
peakUsage_t peakUsageTable_
unique_ptr< memEventHeap_t > eventHeapTable_
std::string const & name() const
LinuxProcData::proc_tuple getCurrentData() const noexcept(false)
ScheduleID::size_type nthreads() const
void recordEventData(Event const &e, string const &step)
std::string const & moduleName() const
auto const & moduleName() const
#define DECLARE_ART_SERVICE(svc, scope)
unique_ptr< cet::sqlite::Connection > const db_
name_array< 3u > peakUsageColumns_
struct mallinfo get() const
void include(std::istream &in, std::string &result)
bool checkMallocConfig_(string const &, bool)
name_array< 5u > otherInfoColumns_
auto select(T const &...t)
name_array< 6u > eventColumns_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
#define DEFINE_ART_SERVICE(svc)
art::LinuxProcData::vsize_t vsize_t
auto const & moduleDescription() const
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
auto const & moduleLabel() const
std::array< std::string, N > name_array
EventNumber_t event() const
name_array< 14u > moduleHeapColumns_
void recordModuleData(ModuleContext const &mc, string const &step)
static Globals * instance()
bool const overwriteContents_
void recordOtherData(ModuleDescription const &md, string const &step)
otherInfo_t otherInfoTable_
unique_ptr< memModuleHeap_t > moduleHeapTable_
SubRunNumber_t subRun() const
Table< DBoutput > dbOutput