ATLAS Offline Software
Loading...
Searching...
No Matches
PerfMonCompsConfig.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4
5from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6from AthenaConfiguration.ComponentFactory import CompFactory
7from AthenaCommon.Logging import logging
8
9
10def PerfMonMTSvcCfg(flags, **kwargs):
11 """ Configuring PerfMonMTSvc """
12
13 # Get the logger
14 log = logging.getLogger("PerfMonMTSvcCfg")
15 log.info("Configuring PerfMonMTSvc with flags:")
16 log.info(" >> doFastMonMT {}".format(flags.PerfMon.doFastMonMT))
17 log.info(" >> doFullMonMT {}".format(flags.PerfMon.doFullMonMT))
18
19 # Check if basic monitoring is asked for
20 if not flags.PerfMon.doFastMonMT and not flags.PerfMon.doFullMonMT:
21 log.info("Nothing to be done...")
22 return ComponentAccumulator()
23
24 # Hook to PerfMonMTSvc
25 PerfMonMTSvc = CompFactory.PerfMonMTSvc
26
27 # Set the main properties for the service
28 import os,psutil
29 kwargs.setdefault("wallTimeOffset",
30 psutil.Process(os.getpid()).create_time() * 1000)
31 kwargs.setdefault("numberOfThreads",
32 max(1,flags.Concurrency.NumThreads))
33 kwargs.setdefault("numberOfSlots",
34 max(1,flags.Concurrency.NumConcurrentEvents))
35 kwargs.setdefault("doComponentLevelMonitoring",
36 flags.PerfMon.doFullMonMT)
37 kwargs.setdefault("jsonFileName", flags.PerfMon.OutputJSON)
38
39 # Get CA and add the service
40 acc = ComponentAccumulator()
41 acc.addService(PerfMonMTSvc(**kwargs), create=True)
42
43 # Enable the auditors that are necessarry for the service
44 acc.addService(CompFactory.AuditorSvc(), create=True)
45 acc.setAppProperty("AuditAlgorithms", True)
46 acc.setAppProperty("AuditTools", True)
47 acc.setAppProperty("AuditServices", True)
48
49 # Return the CA
50 return acc
51
52# A minimal job that demonstrates what PerfMonMTSvc does
53if __name__ == '__main__':
54
55 # Import the common flags/services
56 from AthenaConfiguration.AllConfigFlags import initConfigFlags
57 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
58
59 # Set the necessary configuration flags
60 # Process 100 events in 1 thread/slot and do fast monitoring
61 flags = initConfigFlags()
62 flags.Exec.MaxEvents = 100
63 flags.Concurrency.NumThreads = 1
64 flags.PerfMon.doFastMonMT = True
65 flags.PerfMon.OutputJSON = 'perfmonmt_test.json'
66 flags.fillFromArgs()
67 flags.lock()
68
69 # Set up the configuration and add the relevant services
70 cfg = MainServicesCfg(flags)
71 cfg.merge(PerfMonMTSvcCfg(flags))
72
73 # Burn 100 +/- 1 ms per event
74 CpuCruncherAlg = CompFactory.getComp('PerfMonTest::CpuCruncherAlg')
75 cfg.addEventAlgo(CpuCruncherAlg('CpuCruncherAlg', MeanCpu = 100, RmsCpu = 1), sequenceName = 'AthAlgSeq')
76
77 # Leak 10k ints per event, i.e. 40 KB
78 LeakyAlg = CompFactory.getComp('PerfMonTest::LeakyAlg')
79 cfg.addEventAlgo(LeakyAlg("LeakyAlg", LeakSize = 10000), sequenceName = 'AthAlgSeq')
80
81 # Print the configuration and dump the flags
82 cfg.printConfig(withDetails = True, summariseProps = True)
83 flags.dump()
84
85 # Run the job
86 sc = cfg.run()
87
88 # Exit as appropriate
89 import sys
90 sys.exit(not sc.isSuccess())
#define max(a, b)
Definition cfImp.cxx:41
PerfMonMTSvcCfg(flags, **kwargs)
A minimal new-style configuration for PerfMonMTSvc.