From b121ddf1d00a413fa36be12a3fa7020a9f07eeca Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Tue, 29 Oct 2024 10:11:58 +0100 Subject: [PATCH] Pause MaxMemoryPreload for edmplugincache file reading in PluginManager In a local developer area with many packages checked out, the PluginManager cache can be tens of megabytes larger than in a developer area without packages being checked out. This difference can result in false positive warnings in MaxMemoryPreload monitoring in PR tests. An easy way (even if hacky) out is to exclude the PluginManager cache from the MaxMemoryPreload monitoring. --- .../src/PauseMaxMemoryPreloadSentry.cc | 11 +++++++++++ .../src/PauseMaxMemoryPreloadSentry.h | 17 +++++++++++++++++ FWCore/PluginManager/src/PluginManager.cc | 3 +++ 3 files changed, 31 insertions(+) create mode 100644 FWCore/PluginManager/src/PauseMaxMemoryPreloadSentry.cc create mode 100644 FWCore/PluginManager/src/PauseMaxMemoryPreloadSentry.h diff --git a/FWCore/PluginManager/src/PauseMaxMemoryPreloadSentry.cc b/FWCore/PluginManager/src/PauseMaxMemoryPreloadSentry.cc new file mode 100644 index 0000000000000..f80986f6c563a --- /dev/null +++ b/FWCore/PluginManager/src/PauseMaxMemoryPreloadSentry.cc @@ -0,0 +1,11 @@ +#include "PauseMaxMemoryPreloadSentry.h" + +// By default do nothing, but add "hooks" that MaxMemoryPreload can +// override with LD_PRELOAD +void pauseMaxMemoryPreload() {} +void unpauseMaxMemoryPreload() {} + +namespace edm { + PauseMaxMemoryPreloadSentry::PauseMaxMemoryPreloadSentry() { pauseMaxMemoryPreload(); } + PauseMaxMemoryPreloadSentry::~PauseMaxMemoryPreloadSentry() { unpauseMaxMemoryPreload(); } +} // namespace edm diff --git a/FWCore/PluginManager/src/PauseMaxMemoryPreloadSentry.h b/FWCore/PluginManager/src/PauseMaxMemoryPreloadSentry.h new file mode 100644 index 0000000000000..68c14bb52172e --- /dev/null +++ b/FWCore/PluginManager/src/PauseMaxMemoryPreloadSentry.h @@ -0,0 +1,17 @@ +#ifndef FWCore_PluginManager_src_PauseMaxMemoryPreloadSentry_h +#define FWCore_PluginManager_src_PauseMaxMemoryPreloadSentry_h + +namespace edm { + class PauseMaxMemoryPreloadSentry { + public: + PauseMaxMemoryPreloadSentry(); + ~PauseMaxMemoryPreloadSentry(); + + PauseMaxMemoryPreloadSentry(const PauseMaxMemoryPreloadSentry&) = delete; + PauseMaxMemoryPreloadSentry(PauseMaxMemoryPreloadSentry&&) = delete; + PauseMaxMemoryPreloadSentry& operator=(const PauseMaxMemoryPreloadSentry&) = delete; + PauseMaxMemoryPreloadSentry& operator=(PauseMaxMemoryPreloadSentry&&) = delete; + }; +} // namespace edm + +#endif diff --git a/FWCore/PluginManager/src/PluginManager.cc b/FWCore/PluginManager/src/PluginManager.cc index 66ad296d3ee15..2582acea16dc9 100644 --- a/FWCore/PluginManager/src/PluginManager.cc +++ b/FWCore/PluginManager/src/PluginManager.cc @@ -29,6 +29,8 @@ #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/Utilities/interface/thread_safety_macros.h" +#include "PauseMaxMemoryPreloadSentry.h" + namespace edmplugin { // // constants, enums and typedefs @@ -47,6 +49,7 @@ namespace edmplugin { throw cms::Exception("PluginMangerCacheProblem") << "Unable to open the cache file '" << cacheFile.string() << "'. Please check permissions on file"; } + edm::PauseMaxMemoryPreloadSentry pauseSentry; CacheParser::read(file, dir, categoryToInfos); return true; }