Cling - The Interactive C++ Interpreter
Go to file
Yuka Takahashi 230031c4cb Implement parsing cache for the LookupHelper.
The operations done by the LookupHelper are costly in both memory and
performance. Almost every operation requires memory allocation and parsing
of often non-trivial C++ code.

Unfortunately, the LookupHelper is used very intensively by rootcling and
ROOT. The callers usually do not use any caching mechanisms and redo the
expensive operations over and over even though the answer is known to be
the same as before. For instance, building the dictionary of shows:

```
MathCore:
  Cached entries: 217
  Total parse requests: 54051
  Cache hits: 53834
TreePlayer:
  Cached entries: 183
  Total parse requests: 57697
  Cache hits: 57514
```

This patch introduces the first set of caching functionality. In
particular, each LookupHelper::find* function allocates a memory buffer
which is then stored in the clang::SourceManager. We hash the buffer
content and keep a mapping between a hash and FileID and next time we
encounter the same content we do not allocate a new FileID but reuse the
old one. We see decrease in memory footprint by 7% for non-cxxmodules ROOT.

For cxxmodules we see significant reduction of the pcm sizes (by half)
which translates into rss improvements:

```
  master before:
    cpu  time = 0.291462 seconds
    sys  time = 0.064409 seconds
    res  memory = 345.816 Mbytes
    vir  memory = 573.508 Mbytes
  master after:
   cpu  time = 0.235828 seconds
   sys  time = 0.098327 seconds
   res  memory = 260.012 Mbytes
   vir  memory = 377.945 Mbytes
```

Patch by Yuka Takahashi and me.
2018-08-24 23:59:47 +02:00
cmake/modules fix Clang name in cmake file 2017-07-23 22:59:34 +02:00
demo Remove trailing spaces 2014-08-13 16:08:36 +02:00
docs Bump version to 0.6~dev. 2017-11-02 17:44:11 +01:00
include/cling Implement parsing cache for the LookupHelper. 2018-08-24 23:59:47 +02:00
lib Implement parsing cache for the LookupHelper. 2018-08-24 23:59:47 +02:00
patches Remove old file. 2016-07-22 20:54:47 +02:00
test Implement clang plugin support. 2018-07-28 13:17:44 +02:00
tools Specify where the clang header files are. 2018-08-22 20:14:52 +02:00
www Prepare for releasing cling v0.5. 2017-11-02 17:29:12 +01:00
.clang-format Intent cling namespace content. 2017-10-05 17:59:08 +02:00
.travis.yml cling travis: create a new log section when *running*... 2018-06-13 17:44:09 +02:00
appveyor.yml Appveyor: Build with Ninja on Windows. 2017-03-09 08:29:28 +01:00
CMakeLists.txt Enable ROOT to be built with prebuilt clang and llvm. 2018-03-28 19:29:10 +02:00
CREDITS.txt Improvements for Pull Request #240 2018-06-25 08:29:07 +02:00
LastKnownGoodLLVMSVNRevision.txt Bump the last known good llvm revision to point to release 5.0 2017-11-02 17:59:25 +01:00
LICENSE.TXT Remove trailing spaces 2014-08-13 16:08:36 +02:00
README.md cling README: typo. Thanks, Damien L-G! 2018-06-14 09:38:52 +02:00
VERSION Bump version to 0.6~dev. 2017-11-02 17:44:11 +01:00

Travis status

Cling - The Interactive C++ Interpreter

The main repository is at https://github.com/root-project/cling

Overview

Cling is an interactive C++ interpreter, built on top of Clang and LLVM compiler infrastructure. Cling realizes the read-eval-print loop (REPL) concept, in order to leverage rapid application development. Implemented as a small extension to LLVM and Clang, the interpreter reuses their strengths such as the praised concise and expressive compiler diagnostics.

See also cling's web page.

Please note that some of the resources are rather old and most of the stated limitations are outdated.

Installation

Release Notes

See our release notes to find what's new.

Binaries

Our nightly binary snapshots can be found here.

Building from Source with Cling Packaging Tool

Cling's tree has a user-friendly, command-line utility written in Python called Cling Packaging Tool (CPT) which can build Cling from source and generate installer bundles for a wide range of platforms. CPT requires Python 2.7 or later.

If you have Cling's source cloned locally, you can find the tool in tools/packaging directory. Alternatively, you can download the script manually, or by using wget:

wget https://raw.githubusercontent.com/root-project/cling/master/tools/packaging/cpt.py
chmod +x cpt.py
./cpt.py --check-requirements && ./cpt.py --create-dev-env Debug --with-workdir=./cling-build/

Full documentation of CPT can be found in tools/packaging.

Usage

./cling '#include <stdio.h>' 'printf("Hello World!\n")'

To get started run:

./cling --help

or type

./cling
[cling]$ .help

Jupyter

Cling comes with a Jupyter kernel. After building cling, install Jupyter and cling's kernel by following the README.md in tools/Jupyter. Make sure cling is in your PATH when you start jupyter!

Developers' Corner

Cling's latest doxygen documentation

Contributions

Every contribution is considered a donation and its copyright and any other related rights become exclusive ownership of the person who merged the code or in any other case the main developers of the "Cling Project".

We warmly welcome external contributions to the Cling! By providing code, you agree to transfer your copyright on the code to the "Cling project". Of course you will be duly credited and your name will appear on the contributors page, the release notes, and in the CREDITS file shipped with every binary and source distribution. The copyright transfer is necessary for us to be able to effectively defend the project in case of litigation.

License

Please see our LICENSE.

Releases

Our release steps to follow when cutting a new release:

  1. Update release notes
  2. Remove ~dev suffix from VERSION
  3. Add a new entry in the news section of our website
  4. Commit the changes.
  5. git tag -a v0.x -m "Tagging release v0.x"
  6. Create a draft release in github and copy the contents of the release notes.
  7. Wait for green builds.
  8. Upload binaries to github (Travis should do this automatically).
  9. Publish the tag and announce it on the mailing list.
  10. Increment the current version and append ~dev.