Skip to content

Conversation

@Axel-Naumann
Copy link
Member

With the upgrade to llvm-13, the JIT lost the ability to re-use existing weak symbols that the JIT had already emitted, instead only looking at dlsym. This causes a significant increase in JITted symbols, and thus a significant slow-down of cling / its JIT.

This restores the old behavior, with an identical set of symbols that jet jitted.

This Pull request:

Changes or fixes:

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-ubuntu18.04/nortcxxmod.
Running on sft-ubuntu-1804-2.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T15:24:25.554Z] FAILED: interpreter/cling/lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/IncrementalJIT.cpp.o
  • [2023-01-12T15:24:25.810Z] /mnt/build/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp:589:29: error: ‘jit’ was not declared in this scope

@phsft-bot
Copy link

Build failed on mac12/noimt.
Running on macphsft18.dyndns.cern.ch:/Users/sftnight/build/jenkins/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T15:24:38.584Z] FAILED: interpreter/cling/lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/IncrementalJIT.cpp.o
  • [2023-01-12T15:24:38.842Z] /Users/sftnight/build/jenkins/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp:589:29: error: use of undeclared identifier 'jit'

@phsft-bot
Copy link

Build failed on ROOT-performance-centos8-multicore/cxx17.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T15:26:20.342Z] /data/sftnight/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp:589:29: error: ‘jit’ was not declared in this scope

@Axel-Naumann Axel-Naumann force-pushed the cling-JIT-reuse-weak-JIT-syms branch from 5c7cf42 to fc5fe41 Compare January 12, 2023 15:29
@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@Axel-Naumann Axel-Naumann marked this pull request as draft January 12, 2023 15:29
@phsft-bot
Copy link

Build failed on ROOT-ubuntu18.04/nortcxxmod.
Running on sft-ubuntu-1804-2.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T15:32:00.639Z] FAILED: interpreter/cling/lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/IncrementalJIT.cpp.o
  • [2023-01-12T15:32:00.639Z] /mnt/build/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp:589:55: error: no matching function for call to ‘llvm::DenseMap<llvm::orc::SymbolStringPtr, llvm::JITEvaluatedSymbol>::count(std::__cxx11::string)’

@phsft-bot
Copy link

Build failed on mac12/noimt.
Running on macphsft18.dyndns.cern.ch:/Users/sftnight/build/jenkins/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T15:31:38.481Z] FAILED: interpreter/cling/lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/IncrementalJIT.cpp.o
  • [2023-01-12T15:31:38.737Z] /Users/sftnight/build/jenkins/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp:589:29: error: no viable conversion from 'std::string' (aka 'basic_string<char, char_traits<char>, allocator<char>>') to 'const llvm::orc::SymbolStringPtr'

@phsft-bot
Copy link

Build failed on ROOT-debian10-i386/soversion.
Running on pcepsft10.dyndns.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T15:33:50.687Z] /home/sftnight/build/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp:589:55: error: no matching function for call to ‘llvm::DenseMap<llvm::orc::SymbolStringPtr, llvm::JITEvaluatedSymbol>::count(std::__cxx11::string)’

@Axel-Naumann
Copy link
Member Author

Axel-Naumann commented Jan 12, 2023

With this we go from 141 Billion instructions (pre-llvm-13, i.e. llvm-9) to 134B instr with llvm13, for valgrind --tool=callgrind --fn-skip=_dl_runtime_resolve_avx ./root/tree/dataframe/RDFBenchmarks --benchmark_filter=BM_RDataFrame_JitLargeGraphs/10000

@Axel-Naumann Axel-Naumann marked this pull request as ready for review January 12, 2023 15:36
@phsft-bot
Copy link

Build failed on ROOT-performance-centos8-multicore/cxx17.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T15:36:19.075Z] /data/sftnight/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp:589:55: error: no matching function for call to ‘llvm::DenseMap<llvm::orc::SymbolStringPtr, llvm::JITEvaluatedSymbol>::count(std::__cxx11::string)’

@phsft-bot
Copy link

Build failed on windows10/cxx14.
Running on null:C:\build\workspace\root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T15:36:46.052Z] C:\build\workspace\root-pullrequests-build\root\interpreter\cling\lib\Interpreter\IncrementalJIT.cpp(589,5): error C2664: 'llvm::DenseMapBase<llvm::DenseMap<llvm::orc::SymbolStringPtr,llvm::JITEvaluatedSymbol,llvm::DenseMapInfo<llvm::orc::SymbolStringPtr>,llvm::detail::DenseMapPair<KeyT,ValueT>>,KeyT,ValueT,KeyInfoT,BucketT>::size_type llvm::DenseMapBase<llvm::DenseMap<KeyT,ValueT,KeyInfoT,BucketT>,KeyT,ValueT,KeyInfoT,BucketT>::count(const T &) const': cannot convert argument 1 from 'std::string' to 'const T &' [C:\build\workspace\root-pullrequests-build\build\interpreter\cling\lib\Interpreter\obj.clingInterpreter.vcxproj]

@phsft-bot
Copy link

Build failed on mac11/cxx14.
Running on macphsft20.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T16:24:33.039Z] FAILED: interpreter/cling/lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/IncrementalJIT.cpp.o
  • [2023-01-12T16:24:33.296Z] /Users/sftnight/build/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp:589:29: error: no viable conversion from 'std::string' (aka 'basic_string<char>') to 'const llvm::orc::SymbolStringPtr'

@phsft-bot
Copy link

Build failed on ROOT-ubuntu2004/python3.
Running on root-ubuntu-2004-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T16:24:28.528Z] FAILED: interpreter/cling/lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/IncrementalJIT.cpp.o
  • [2023-01-12T16:24:28.529Z] /home/sftnight/build/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp:589:40: error: cannot convert ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘llvm::DenseMapBase<llvm::DenseMap<llvm::orc::SymbolStringPtr, llvm::JITEvaluatedSymbol>, llvm::orc::SymbolStringPtr, llvm::JITEvaluatedSymbol, llvm::DenseMapInfo<llvm::orc::SymbolStringPtr>, llvm::detail::DenseMapPair<llvm::orc::SymbolStringPtr, llvm::JITEvaluatedSymbol> >::const_arg_type_t<llvm::orc::SymbolStringPtr>’ {aka ‘const llvm::orc::SymbolStringPtr&’}

@Axel-Naumann Axel-Naumann force-pushed the cling-JIT-reuse-weak-JIT-syms branch from fc5fe41 to c313072 Compare January 12, 2023 16:40
@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@Axel-Naumann Axel-Naumann force-pushed the cling-JIT-reuse-weak-JIT-syms branch from c313072 to a465470 Compare January 12, 2023 16:43
@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on ROOT-ubuntu18.04/nortcxxmod.
Running on sft-ubuntu-1804-3.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T16:46:31.971Z] FAILED: interpreter/cling/lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/IncrementalJIT.cpp.o
  • [2023-01-12T16:46:32.226Z] /mnt/build/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp:589:45: error: expected primary-expression before ‘.’ token

@phsft-bot
Copy link

Build failed on ROOT-debian10-i386/soversion.
Running on pcepsft11.dyndns.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T18:11:41.259Z] FAILED: interpreter/cling/lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/IncrementalJIT.cpp.o
  • [2023-01-12T18:11:41.259Z] /home/sftnight/build/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp:589:43: error: no matching function for call to ‘llvm::DenseMap<llvm::orc::SymbolStringPtr, llvm::JITEvaluatedSymbol>::count(std::pair<llvm::orc::SymbolStringPtr, llvm::orc::SymbolLookupFlags>&)’

@phsft-bot
Copy link

Build failed on mac11/cxx14.
Running on macphsft20.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T18:17:06.038Z] FAILED: interpreter/cling/lib/Interpreter/CMakeFiles/obj.clingInterpreter.dir/IncrementalJIT.cpp.o
  • [2023-01-12T18:17:06.641Z] /Users/sftnight/build/workspace/root-pullrequests-build/root/interpreter/cling/lib/Interpreter/IncrementalJIT.cpp:589:29: error: no viable conversion from 'std::__1::pair<llvm::orc::SymbolStringPtr, llvm::orc::SymbolLookupFlags>' to 'const llvm::orc::SymbolStringPtr'

@Axel-Naumann Axel-Naumann force-pushed the cling-JIT-reuse-weak-JIT-syms branch from 259d703 to f47e127 Compare January 12, 2023 18:26
@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@phsft-bot
Copy link

Build failed on windows10/cxx14.
Running on null:C:\build\workspace\root-pullrequests-build
See console output.

Errors:

  • [2023-01-12T18:33:54.758Z] LINK : fatal error LNK1104: cannot open file 'C:\build\workspace\root-pullrequests-build\build\bin\libCore.dll' [C:\build\workspace\root-pullrequests-build\build\core\Core.vcxproj]

@phsft-bot
Copy link

Build failed on mac12/noimt.
Running on macphsft17.dyndns.cern.ch:/Users/sftnight/build/jenkins/workspace/root-pullrequests-build
See console output.

Warnings:

  • [2023-01-12T18:34:18.641Z] /Users/sftnight/build/jenkins/workspace/root-pullrequests-build/root/core/base/src/TDirectory.cxx:1245:7: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]

Failing tests:

And 331 more

@phsft-bot
Copy link

@phsft-bot
Copy link

With the upgrade to llvm-13, the JIT lost the ability to re-use existing weak
symbols that the JIT had already emitted, instead only looking at dlsym. This
causes a significant increase in JITted symbols, and thus a significant slow-down
of cling / its JIT.

This restores the old behavior, with an identical set of symbols that jet jitted.
Small functions might get inlined, and hiding their definition prevents
the inliner from doing its job.
m_JIT.getSymbolAddress() invokes the symbol materializers, which compile (which
is sort of okay) but also try autoloading (which totally is not okay).

Instead, implement a function to search existing JIT symbols.

This can be accelerated by looking up the whole set of symbols, instead of doing it
symbol by symbol. I leave that refactoring for later...
@Axel-Naumann Axel-Naumann force-pushed the cling-JIT-reuse-weak-JIT-syms branch from f47e127 to ba2f10e Compare January 13, 2023 16:22
@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

@Axel-Naumann
Copy link
Member Author

Update on #12018 (comment) : currently 141B instr => 130B instr

@phsft-bot
Copy link

Build failed on mac12/noimt.
Running on macphsft17.dyndns.cern.ch:/Users/sftnight/build/jenkins/workspace/root-pullrequests-build
See console output.

Warnings:

  • [2023-01-13T16:30:21.184Z] /Users/sftnight/build/jenkins/workspace/root-pullrequests-build/root/core/base/src/TDirectory.cxx:1245:7: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]

Failing tests:

And 63 more

@phsft-bot
Copy link

@Axel-Naumann
Copy link
Member Author

@phsft-bot build just on windows10/cxx14, mac12/noimt

@phsft-bot
Copy link

Starting build on windows10/cxx14, mac12/noimt
How to customize builds

@phsft-bot
Copy link

Without, the JIT fails to compile roottest/root/aclic/misc/assertROOT7027.C
correctly.
@phsft-bot
Copy link

Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac12/noimt, mac11/cxx14, windows10/cxx14
How to customize builds

Copy link
Member

@hahnjo hahnjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and seems to pass tests on Linux and macOS. IMO it would be fantastic to reorder / squash the commits to make all intermediate states work fine (especially the last commit is fixing failures and also "find existing weak symbol without materializer:" seems important), but up to you.

@Axel-Naumann
Copy link
Member Author

IMO it would be fantastic to reorder / squash the commits to make all intermediate states work fine

The main reason why I like the current small-ish steps (even if it breaks intermediate commits at the cost of more fragile bijection) is that I will certainly be asking myself, "why did I not do this differently" in some months, and having the commit that explains why e.g. I switched from "just ask the JIT for symbols" to "look for symbol names" is extra information. Same for the final Windows "fix", for instance - it's a very distinct / separate step.

Does that make sense?

@Axel-Naumann
Copy link
Member Author

Axel-Naumann commented Jan 17, 2023

Merged by hand, leaving a --no-ff merge commit / branch to signal that this is a set of commits.

@Axel-Naumann
Copy link
Member Author

v6-28: #12163

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