Skip to content

Conversation

@vgvassilev
Copy link
Member

@vgvassilev vgvassilev commented Jun 30, 2019

The global module index represents an efficient on-disk hash table which stores identifier->module mapping. Every time clang finds a unknown identifier we are informed and we can load the corresponding module on demand.

This way we can provide minimal set of loaded modules. Currently, we see that for hsimple.C only the half of the modules are loaded. This can be further improved because we currently load all modules which have an identifier, that is when looking for (for example TPad) we will load all modules which have the identifier TPad, including modules which contain only a forward declaration of it.

Kudos Arpitha Raghunandan (@arpi-r)!

We still need some performance measurements but the preliminary results are promising.

Performance

Methodology

We have a forwarding root.exe which essentially calls /usr/bin/time -v root.exe $@. We have processed and stored this information in csv files. We have run in three modes:

  1. root master without modules (modulesoff)
  2. root master with modules (moduleson)
  3. root master with this PR with modules (gmi)

Run on Ubuntu 18.10 on Intel® Core™ i5-8250U CPU @ 1.60GHz × 8

Results Interpretation

A general comparison between 2) and 3) show that this PR makes ROOT about 3% faster and 25% more memory efficient.

A general comparison between 1) and 3) shows that modules are still less efficient in a few cases which is expected because the PR loads more modules than it should. This will be addressed in subsequent PRs. A good trend is that some test already show that 3) is better than 1).

The raw data could be found here. [work was done by Arpitha Raghunandan (@arpi-r)]

Depends on #4005.

@phsft-bot
Copy link

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-ubuntu16/rtcxxmod, mac1014/cxx17, windows10/default
How to customize builds

@phsft-bot
Copy link

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-ubuntu16/rtcxxmod, mac1014/cxx17, windows10/default
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-ubuntu16/rtcxxmod.
See console output.

Errors:

  • FAILED: cd /mnt/build/workspace/root-pullrequests-build/build/math/mathcore/test && /usr/local/bin/cmake -E env LD_LIBRARY_PATH=/mnt/build/workspace/root-pullrequests-build/build/lib: ROOTIGNOREPREFIX=1 /mnt/build/workspace/root-pullrequests-build/build/bin/rootcling -rootbuild -v2 -f G__TrackMathCoreUnitDict.cxx -cxxmodule -s /mnt/build/workspace/root-pullrequests-build/build/math/mathcore/test/libTrackMathCoreUnitDict.so -m libCore_rdict.pcm -m libMathCore_rdict.pcm -m libRIO_rdict.pcm -m libGenVector_rdict.pcm -excludePath /mnt/build/workspace/root-pullrequests-build/root -excludePath /mnt/build/workspace/root-pullrequests-build/build -I/mnt/build/workspace/root-pullrequests-build/root -I/mnt/build/workspace/root-pullrequests-build/build/etc/cling/ -I/mnt/build/workspace/root-pullrequests-build/build/include -I/mnt/build/workspace/root-pullrequests-build/root/math/mathcore/test -I/mnt/build/workspace/root-pullrequests-build/root/builtins/zlib -I/mnt/build/workspace/root-pullrequests-build/root/core/base/inc -I/mnt/build/workspace/root-pullrequests-build/root/core/clib/inc -I/mnt/build/workspace/root-pullrequests-build/root/core/cont/inc -I/mnt/build/workspace/root-pullrequests-build/root/core/foundation/inc -I/mnt/build/workspace/root-pullrequests-build/root/core/macosx/inc -I/mnt/build/workspace/root-pullrequests-build/root/core/unix/inc -I/mnt/build/workspace/root-pullrequests-build/root/core/winnt/inc -I/mnt/build/workspace/root-pullrequests-build/root/core/clingutils/inc -I/mnt/build/workspace/root-pullrequests-build/root/core/meta/inc -I/mnt/build/workspace/root-pullrequests-build/root/core/textinput/inc -I/mnt/build/workspace/root-pullrequests-build/root/math/mathcore/v7/inc -I/mnt/build/workspace/root-pullrequests-build/root/math/mathcore/inc -I/mnt/build/workspace/root-pullrequests-build/root/math/mathcore -I/mnt/build/workspace/root-pullrequests-build/root/io/io/inc -I/mnt/build/workspace/root-pullrequests-build/root/core/clib/res -I/mnt/build/workspace/root-pullrequests-build/root/io/io/res -I/mnt/build/workspace/root-pullrequests-build/root/math/genvector/inc /mnt/build/workspace/root-pullrequests-build/root/math/mathcore/test/stress/TrackMathCore.h /mnt/build/workspace/root-pullrequests-build/root/math/mathcore/test/stress/TrackMathCoreLinkDef.h
  • Error: Had to build non-system module Smatrix implicitly. You first need to

Warnings:

  • /mnt/build/workspace/root-pullrequests-build/root/core/metacling/src/TCling.cxx:1096:13: warning: ‘void RegisterCxxModules(cling::Interpreter&)’ defined but not used [-Wunused-function]

@phsft-bot
Copy link

@phsft-bot
Copy link

@phsft-bot
Copy link

@vgvassilev vgvassilev force-pushed the cxxmodules_global_index branch from 167d978 to 4363501 Compare June 30, 2019 18:58
@phsft-bot
Copy link

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-ubuntu16/rtcxxmod, mac1014/cxx17, windows10/default
How to customize builds

@phsft-bot
Copy link

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-ubuntu16/rtcxxmod, mac1014/cxx17, windows10/default
How to customize builds

@vgvassilev vgvassilev force-pushed the cxxmodules_global_index branch from 01c1356 to a2dea2b Compare June 30, 2019 20:09
@phsft-bot
Copy link

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-ubuntu16/rtcxxmod, mac1014/cxx17, windows10/default
How to customize builds

@vgvassilev
Copy link
Member Author

@phsft-bot build just on ROOT-ubuntu16/rtcxxmod with flags -DCTEST_TEST_EXCLUDE_NONE=On

@phsft-bot
Copy link

Starting build on ROOT-ubuntu16/rtcxxmod with flags -DCTEST_TEST_EXCLUDE_NONE=On
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-ubuntu16/rtcxxmod.
See console output.

Errors:

And 15 more

Failing tests:

And 119 more

@phsft-bot
Copy link

Starting build on ROOT-ubuntu16/rtcxxmod with flags -DCTEST_TEST_EXCLUDE_NONE=On
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-ubuntu16/rtcxxmod.
See console output.

Errors:

  • error: Failed to merge in the changes.
  • CMake Error at /mnt/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:861 (message):

@phsft-bot
Copy link

Build failed on ROOT-fedora30/cxx14.
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-ubuntu18.04-i386/cxx14.
See console output.

Failing tests:

vgvassilev and others added 20 commits February 24, 2020 10:51
The global module index represents an efficient on-disk hash table which stores
identifier->module mapping. Every time clang finds a unknown identifier we
are informed and we can load the corresponding module on demand.

This way we can provide minimal set of loaded modules. Currently, we see that
for hsimple.C only the half of the modules are loaded. This can be further
improved because we currently load all modules which have an identifier, that is
when looking for (for example TPad) we will load all modules which have the
identifier TPad, including modules which contain only a forward declaration of
it.

Kudos Arpitha Raghunandan (arpi-r)!
In cases where we have the module cache path and prebuilt module path pointing
to the same location, the FileManager should not cache the module file lookup
failure because it may currently be building the module.

This patch is necessary because the global module index is built from the
module cache path and it is loaded from the prebuilt module path.

In a full explicit or implicit module build infrastructure this is not a problem.
However, in a mixed scenario (where modules for third-party dependencies are
built implicitly) such as ours this is problematic. One of the reasons is that
we cannot configure the prebuilt modules paths or module cache paths externally.
This is because the interpreter (at construction time) #includes RuntimeUniverse
which may trigger module build.

This patch allows us to refactor some of the code working around this issue.
When we are generating code, CodeGen automatically tries to complete decl's
redeclaration chain. This ends up a call to the external sources, one of which
is our global module index (GMI).

The semantics of the GMI is to aid the frontend, that is to automatically
import missing modules based on the typed *by the user* identifiers. It does
not intend to aid the code generation by any means. Currently this happens
when completing chains for existing identifiers such as 'volume' which happens
to be an indentifier part of TMVA.pcm, too. Thus, CodeGen unintentionally loads
the module of TMVA. This is an overkill, but worse -- it brings recursiveness
to the identifier resolution system.

This patch disables looking in the GMI at codegen time.
All reasibility checks are done in the routine itself and we also call it,
when we need to complete type through LookupObject(TagDecl*).
The issue is that, it does not contain the identifier for TH1.
It does not contain identifier TFrame
Fixes some failing tests
This does not require resolving conflicts or bloating the history.
We do that to fix the:
+Warning in <TClass::Init>: no dictionary for class TLorentzVector is available

errors. This is due to the fact that TLorentzVector and such identifiers do not
get to the module.idx. They are read in ::readIndex and visited in ::writeIndex
however it seems that the on-disk writer trait is filtering somehow them out.
This is needed due to see this commit: fc24e98
By setting the ROOT_EXPERIMENTAL_GMI env variable. This is useful for comparing
performance results from both implementations.

ROOT_EXPERIMENTAL_GMI is temporary and will go away as soon as we switch to the
GMI by default.
@vgvassilev vgvassilev force-pushed the cxxmodules_global_index branch from 7d4aee1 to 774c08f Compare February 24, 2020 08:51
@phsft-bot
Copy link

Starting build on ROOT-performance-centos7-multicore/default, ROOT-fedora27/noimt, ROOT-fedora29/python3, ROOT-fedora30/cxx14, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu18.04-i386/cxx14, mac1014/cxx17, windows10/cxx14 with flags -DCTEST_TEST_EXCLUDE_NONE=On
How to customize builds

@phsft-bot
Copy link

Build failed on mac1014/cxx17.
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-fedora30/cxx14.
See console output.

Failing tests:

@phsft-bot
Copy link

Build failed on ROOT-fedora27/noimt.
See console output.

@phsft-bot
Copy link

Build failed on ROOT-ubuntu18.04-i386/cxx14.
See console output.

Failing tests:

@vgvassilev
Copy link
Member Author

The test failures are not related to this PR, they are present in the nightly builds.

@vgvassilev vgvassilev merged commit a98c539 into root-project:master Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants