CLion 2018.3 EAP: profiling tools on Linux and macOS and multiline TODO

Anastasia Kazakova

Hi,

The new CLion 2018.3 EAP (build 183.3647.14) is now available for download!

As usual, a patch-update will be available shortly for those using the previous EAP build, and you can also use Toolbox app or snap packages (in the case of Ubuntu) to get this build. No license is required and the build is free to use, but it will expire within 30 days of the build date.

Download CLion 2018.3 EAP

CPU Profiler

Starting from this EAP, CLion comes with the CPU Profiler integration on Linux and macOS. With Perf on Linux and DTrace on macOS you can now analyze the performance of your application (both, kernel and user’s code) right in the IDE.

To run the profiler use a new button in the navigation toolbar or a new action in the run menu, which appears when you click on a run icon in the left gutter:
run_profiler

The results of the profiling is shown in the CPU Profiler tool window (View | Tool Windows | CPU Profiler):
profiler_toolwindow

How to start profiling the code?

Before you start profiling your app, please check and install, if missing, the following tools:

  • On Linux:
    1. Perf is required to run profiling in CLion. Mind, you should install perf for the particular kernel version you have. For example, on Ubuntu you can check the kernel version via uname command and then install the linux-tools package for the particular kernel version:
      anastasiak2512@ubuntu:~$ uname -a
      Linux ubuntu 4.15.0-34-generic #37-Ubuntu SMP Mon Aug 27 15:21:48 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
      anastasiak2512@ubuntu:~$ sudo apt-get install linux-tools-4.15.0-34-generic
      
    2. Besides, you have to allow perf collect information without root privileges. For that you have to tweak `/proc/sys/kernel/perf_event_paranoid` and update `/etc/sysctl.d/local.conf` if you want to keep the setting across system reboots:
      sudo sh -c 'echo 1 >/proc/sys/kernel/perf_event_paranoid'
      sudo sh -c 'echo kernel.perf_event_paranoid=1 > /etc/sysctl.d/local.conf'
      
    3. addr2line tool is also required to show human-readable (demangled) names in the output and to navigate to the source code. It’s part of the binutils package, so you likely have it by default. Otherwise, install binutils.
  • On macOS:
    • DTrace is required to profile on macOS. Most likely, you have it installed by default with your macOS. You can call `dtrace` command in the terminal to check it.

Perf and DTrace executables will be detected automatically by CLion. Or you can set the path in Settings/Preferences | Build, Execution, Deployment | Dynamic Analysis Tools | Profiler. Besides, you can configure sampling frequency there.

In order to get meaningful profiler data and ability to navigate through it properly, the application need to be build with debug info and without any optimizations, so we recommend using the Debug configuration with `-O0` compilation flag.

CPU Profiler tool window

When you start profiling the app, CLion notifies you if the profiler is successfully attached. When the profiling data is ready, CLion shows a balloon with a link to the CPU Profiler tool window with the results. Alternatively, you can open it via View | Tool Windows | CPU Profiler.
profiler_data_ready

In the tool window you can find several useful tabs with the profiling information collected: flame chart, call tree and method lists.
profiler_tabs

Known issues and limitations

CPU profiler integration in CLion is implemented on Linux and macOS platforms. We’ll consider possible tools on Windows later in 2019. Besides, there are a few limitations in the current implementation:

  • By default CLion runs the profiler with quite high sampling frequency, which might require a lot of disk space for long-running programs. Decrease this value in Settings/Preferences | Build, Execution, Deployment | Dynamic Analysis Tools | Profiler to avoid such situations.
  • Profiler integration in CLion currently doesn’t support WSL toolchain or remote mode.
  • Currently profiling works for CMake and Gradle projects. Projects with compilation database project model are not supported.

Multiline TODO comments

With this EAP we bring you multiline TODO comments, which means the first and all subsequent todo comment lines can be highlighted in the editor and listed in the TODO Tool Window (it was only the first line previously). Just add an indent starting from the second line of your multiline TODO comment so the IDE will differentiate it from an ordinary comment:
Multiline TODO comments

That’s it! Give this new CLion EAP a try and let us know what you think! Full release notes are available by the link.

Download CLion 2018.3 EAP

Your CLion Team
JetBrains
The Drive to Develop

Comments below can no longer be edited.

31 Responses to CLion 2018.3 EAP: profiling tools on Linux and macOS and multiline TODO

  1. Tano says:

    October 10, 2018

    Still hoping that IDEA-199656 will be available in final 2018.3. 🙂

    • Anastasia Kazakova says:

      October 10, 2018

      I can’t promise you any particular estimations. This is not the top priority in this area.

      • Tano says:

        October 11, 2018

        So you added new bugs in 2018.3 EAP but it’s not your top priority to fix them? 🙂

        I really appreciate adding new features, but if you introduce new bugs, I think it’s normal to fix them immediately in the next release.
        And we are talking about a simple stupid bug (some window expanding).

        So should we use 2018.2 without bugs and without new features or use 2018.3 WITH bugs and new features? Tough question.

        • Anastasia Kazakova says:

          October 11, 2018

          I understand you and will chat with the team about it.

          • Tano says:

            October 11, 2018

            Thank you very much for your understanding and your help, Anastasia.

      • Danylo says:

        October 17, 2018

        Where I can see top priority issues list?

        • Anastasia Kazakova says:

          October 17, 2018

          In general there is open issue tracker and we do rely on votes there, so you can sort by votes. But there are other factors, so we publish road maps here https://confluence.jetbrains.com/display/CLION/CLion+development+roadmap and in this blog (tag #roadmap)

          • Danylo says:

            October 17, 2018

            Can your team implement sorting by votes?
            How CLion team picks items to do if you don’t have sorting by votes?

          • Danylo says:

            October 17, 2018

            Oops. misread. Don’t mind.

            • Anastasia Kazakova says:

              October 17, 2018

              Votes are important, however they are not the only thing that matters. We have major directions for the product outlined, for example remote and embedded, thus moving into these directions is important.

  2. Alexander Zaitsev says:

    October 10, 2018

    Great news! Do you think about integration Valgrind (Callgrind, Cachegrind) profiler into CLion? What about other profilers?

    • Anastasia Kazakova says:

      October 10, 2018

      We’ll consider other options when finalize our work with perf/dtrace. There is still some issues to be resolved first.

  3. Alexander Zaitsev says:

    October 11, 2018

    CLion already has support for Clang Tidy. But what about integrating Clang Static Analyzer into CLion?

    • Anastasia Kazakova says:

      October 11, 2018

      Clang-Tidy includes Clang Analyzer checks. You can enable it in Clang-Tidy settings in inspections.

  4. okMan says:

    October 13, 2018

    Hi, gay, Can you use Valgrind in the MacOs Majava?

  5. Michael Klatt says:

    October 15, 2018

    I’m still using EAP 183.2940.13 because of https://youtrack.jetbrains.com/issue/IDEA-199986, and it looks like this update still has that issue. What can I do if my build expires before this is fixed?

    • Anastasia Kazakova says:

      October 15, 2018

      The ticket is under investigation, we hope it to be fixed soon. As this is EAP program, we can’t promise you an improved build ready before your current one expires, but we’ll do our best to fix the issue asap and provide a EAP build with the fix as soon as possible.

  6. kert says:

    October 17, 2018

    Profiling is nice, but can we finally get code coverage support ? It’s available in every other Jetbrains IDE, but for Clion even the plugin api for coverage is not exposed.

    • Anastasia Kazakova says:

      October 17, 2018

      Code coverage is also in our plans for one of the upcoming versions.

  7. Peter says:

    October 25, 2018

    I briefly checked the profiler window in 2018.2.5. via the ‘Experimental features’ option.
    I use perf as my preferred profiling tool, so having a decent UI for this would be really great.
    I noticed there is a ‘Choose dump file’ option in the ‘CPU Profiler’ tool window. However despite CLion claims to use ‘perf’ internally it seams to be unable to load data recorded via ‘perf record’ outside of CLion. It refuses to do so with: “Can’t read dump file: Not an Intellij Profiler Dump”. I understand there might be reasons to have your own file format or wrapper format, but if perf is used inside anyways it would be much more useful if it would be possible to also be able read/import the native perf format. This gives much more options to profile in a certain environment and conditions and have full control about perf options while still use a great UI for analyzing and browsing call graphs and code.

    • Anastasia Kazakova says:

      October 25, 2018

      Please check the profiler functionality in 2018.3 EAP. 2018.2.5 has a very limited version, not intended for public use.
      Dump files functionality is not yet there.

  8. Peter says:

    November 7, 2018

    Do you know hotspot? https://github.com/KDAB/hotspot
    This is a nice example of how this can be done right.
    Btw.: Is there a issue in the tracker to follow the development for this?

  9. Ernest says:

    November 14, 2018

    Anastasia, is there any ability to load `perf.data` file with data which was previously collected, for example on another machine and I want to open it in CLion to see the hotspots and navigate to the code?

  10. Florian says:

    January 29, 2019

    This question is bit more general than just for CLion, but I dare ask:

    Anastasia you write “to get meaningful profiler data […] build with debug info and without any optimizations”.

    Given that performance of optimized code is matters most in most situations, and optimizations may change speed quite dramatically, this is a huge disadvantage of perf. Making me directly want to stay with hand-written profiling/timers etc.

    Or am I missing something?

    Thanks.

    • Anastasia Kazakova says:

      January 30, 2019

      I partially agree. But I don’t know a good profiling tool that can deal with that. Can you recommend smth?

      • Florian says:

        January 30, 2019

        Unfortunately I’m newbie. My friend explains to me -O3 optimization etc. would not necessarily have to be a problem for perf; instead, mainly keeping in the debug flags would be important.

        • Anastasia Kazakova says:

          January 31, 2019

          Optimizations might cut some information that perf and related tools are using to show the trace correctly. So you can profile with -O3, but some info might lack.

Subscribe

Subscribe for updates