<<

CHEP 2018, Sofia, Bulgaria Optimizing Frameworks’ Performance Using ++ Modules-Aware ROOT Yuka Takahashi, Vassil Vassilev, Raphael Isemann yuka.takahashi, vvasilev, raphael.isemann @cern.ch

1. Introduction PCH files are precompiled header files and modules, we can automatically resolve sym- We will present our results and challenges work similar to C++ modules. The advan- bols and cases like those are now correctly with C++ modules in ROOT. ROOT was ex- tage of modules over PCH is that they can handled. be used by experiments. Experiments are tended with experimental support for using 6. Implementation C++ modules during runtime, with aims to still using textual includes as PCH only cov- reduce it’s memory usage and improve its ers ROOT. PCH cannot be exported to ex- correctness. periments because of various technical limi- tations. 2. C++ Modules in a Nutshell • Header information is stored in precom- 5. Results piled PCM files 5.1 Perfomance • No more header during ROOT’s runtime In C/C++, the interface of a library is ac- cessed by including the appropriate header files: # include < s t d i o . h> Figure 5: Visualization of ROOT interpreter These textual includes cause well-known core. problems: As shown in Fig.5, we are developing and • Compile-time scalability: #include is copy- using LLVM/ implementation of C++ ing the contents to the includer’s code, so modules, collaborating with developers from the parser has to reparse the same common Google and Apple. Cling is a C++ interpreter header files multiple times, which is expen- developed by CERN, and rootcling is a dictio- sive. nary generator for ROOT. We are implement- Figure 3: CPU Time required to run se- • Fragility: Textual includes are influenced by ing runtime modules in these parts while in- lected tutorials. The first column is displaying previously defined macros. For example, tegrating ROOT with them. macro PI is #defined in Rcpp library. Includ- ROOT’s time to start into an empty shell. ing this library while using local variable PI 7. Roadmap will end up in a redefinition error. • Compile ROOT with C++ modules C++ modules is a mechanism to boost com- Status: Completed pilation time by precompiling headers into • Compile CMSSW with C++ modules PCM files, where AST information can be Status: Work in progress lazily loaded. • Use runtime C++ modules in ROOT 3. From C++ Modules to Runtime C++ Status: Mostly Done Modules • Use runtime C++ modules in experiments Status: Work in progress To summarize, runtime modules are mostly working, but need work to get better perfor- mance.

Figure 4: Residential memory used to run tu- 8. Conclusion Figure 1: Runtime Modules (pcms). Each torials. Here we briefly introduced our experimen- tal runtime C++ modules support in ROOT PCM file (E.g. Core.pcm) corresponds to a li- Fig.3 and Fig.4 are the performance results and how it will affect experiments’ software brary (E.g. libCore.so). we receive from modules, compared to tex- stacks. Modules are not yet competent com- C++ modules are able to reduce compilation tual headers. The results are coming from pared to PCH, but are more flexible and have times. However, the compilation scalability synthetic benchmarks close to the experiment clear advantage over texual includes. issues in C/C++ becomes runtime issues for software stacks and in particular CMSSW. an interpretative environment which ROOT 5.2 Correctness 9. Future work provides. They span from slow prompt to PCH: Runtime modules are still an experimental slow IO. $ bin/root.exe −l feature. Our ultimate goal is to make it de- 4. Advantages over the Status Quo root [0] gMinuit //Cannot load variable fault in ROOT and in experiments: IncrementalExecutor :: executeFunction : • Stabilize modules behavior and tests symbol ’gMinuit’ unresolved while linking [cling interface function]! • Adoption by experiments and other ROOT users Runtime Modules: $ bin/root.exe −l • Improve performance of loading modules root [0] gMinuit //Could load libMinuit Further Information ( TMinuit * ) n u l l p t r Runtime Modules are supporting more fea- • https://clang.llvm.org/docs/Modules.html tures than PCH. For example, gMinuit is an • https://root.cern.ch/ Figure 2: Precompiled Headers (PCH). Infor- extern variable which cannot be autoloaded • https://root.cern.ch/cling mation of the header is stored in one file. by ROOT at the moment. However, with