ROOT start up time and memory optimization

There are some codes compiled at the start up time. For example,
    - #include \"cling/Interpreter/RuntimeUniverse.h\"
    - #include \"cling/Interpreter/DynamicLookupRuntimeUniverse.h\"
    - namespace cling { class Interpreter; namespace runtime { Interpreter* gCling }}}
    - PrintValue
  These are passed to Cling as string and initialized at the start up time.  So I think it makes sense to reduce top-level global variables, #includes and virtual functions.

  1. Global variables
    If we break at emitModule, we can get a list of global variables and functions which are actually deserialized. These include functions, variables, STL classes and all the functions derives from them.
 I tried to change them to for example constexpr, so that it's processed at compile time.
  2. Eagerly Deserialized decls
    Thanks to @Axel 's hint and tip, we could minimize eagerly deserialized decls deserialized in ASTReader::PassInterestingDeclsToConsumer. We already removed most of eagerly deserialized decls (Some are remaining to be removed, some are hard to remove and some don't cost a lot).

  So far, we got 9.2% of cpu time improvement and 8.8% of memory improvement at start up time in release build.

  - root.exe -q -l
    - master
      cpu time = 0.09186914285714286 sec (average of 7 times)
      res  memory = 142.008 Mbytes

    - HEAD
      cpu time = 0.08337842857142856 sec
      res  memory = 129.508 Mbytes

  - hsimple.C
  Improved by 13% of cpu time and 8.5% of memory
    - master
      cpu time = 0.0954708 sec (average)
      res  memory = 142.891 Mbytes

    - HEAD
      cpu time = 0.0833258 sec
      res  memory = 130.73 Mbytes

  With modules
    - Improvement by 17.7% in cputime and 2% in memory on root.exe -q -l
    (For memory, small improvement is because most of the memory is taken by LoadModules)
    - With this patch, modules is 11.2% slower in cpu time and 6% better in residential memory.
This commit is contained in:
Yuka Takahashi 2018-03-26 21:45:52 +02:00 committed by sftnight
parent 5367e13c15
commit 638e5969d8
3 changed files with 2 additions and 4 deletions

View File

@ -13,7 +13,7 @@
#error "This file must not be included by compiled programs."
#endif
#include "cling/Interpreter/DynamicExprInfo.h"
class DynamicExprInfo;
#include "cling/Interpreter/DynamicLookupLifetimeHandler.h"
#include "cling/Interpreter/Value.h"

View File

@ -12,8 +12,6 @@
#include "cling/Interpreter/InvocationOptions.h"
#include "llvm/ADT/StringRef.h"
#include <cstdlib>
#include <memory>
#include <string>

View File

@ -10,7 +10,7 @@
#ifndef CLING_VALUE_H
#define CLING_VALUE_H
#include <stddef.h>
#include <cstddef>
#include <stdint.h>
#include <type_traits>