Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
901 stars 98 forks source link

Possible performance issue related to `flycheck-relevant-error-p` #506

Open ikirill opened 5 years ago

ikirill commented 5 years ago

The following output I got from profiler-report (Emacs's profiler in cpu profiling mode) looks suspicious, because it spends a lot of time in flycheck-relevant-error-p, which I didn't expect.

It causes noticeable pauses when typing, which makes it pretty annoying.

I only get this with irony-mode, I haven't had this problem with flycheck in general, which is why I submitted it here. I'm not actually very sure about that.

To reproduce I opened this file and just edited it.

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <fstream>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/mean.hpp>
using namespace std;

int main() {
  using boost::accumulators::extract_result;
  using boost::accumulators::accumulator_set;
  using boost::accumulators::features;
  namespace tag = boost::accumulators::tag;
  accumulator_set<double, features<tag::mean>> acc;
  acc(1.0);
  acc(2.0);
  cout << "Hello" << endl;
  cout << extract_result<tag::mean>(acc) << endl;
  cout << "Hello" << endl;
  return 0;
}

Compilation database:

$ cat .clang_complete
-std=c++11
-I/opt/brew/include
-Wall
-Wextra
-Weverything

CPU profiler output:

- ...                                                            4786  92%
 - progn                                                         4587  88%
  - condition-case                                               4587  88%
   - save-current-buffer                                         4587  88%
    - funcall                                                    4584  88%
     - #<lambda 0x5d23ec69>                                      4584  88%
      - apply                                                    4584  88%
       - #<lambda 0xfbd9da07f>                                   4584  88%
        - condition-case                                         4584  88%
         - funcall                                               4584  88%
          - #<compiled 0x417cac49>                               4584  88%
           - #<compiled 0x417cac11>                              4584  88%
            - apply                                              4584  88%
             - flycheck-report-buffer-checker-status               4584  88%
              - flycheck-finish-current-syntax-check               4584  88%
               - flycheck-relevant-errors                        4583  88%
                - seq-filter                                     4583  88%
                 - seq-map                                       4583  88%
                  - apply                                        4583  88%
                   - #<compiled 0x40a79bd3>                      4583  88%
                    - mapcar                                     4583  88%
                     - #<compiled 0x407d1cd5>                    4583  88%
                      - flycheck-relevant-error-p                4583  88%
                       + flycheck-same-files-p                   2299  44%
                       + flycheck-relevant-error-other-file-p               2284  44%
               + flycheck-fill-and-expand-error-file-names                  1   0%
    + let                                                           3   0%
   Automatic GC                                                   199   3%
+ command-execute                                                 302   5%
+ redisplay_internal (C function)                                  87   1%
+ timer-event-handler                                               2   0%
$ clang++ --version
clang version 7.0.0 (tags/RELEASE_700/rc3)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /opt/brew/opt/llvm/bin
GNU Emacs 26.1 (build 2, x86_64-apple-darwin17.7.0, NS appkit-1561.60 Version 10.13.6 (Build 17G65)) of 2018-10-13
liulk commented 4 years ago

This should address your performance issue problem. https://github.com/flycheck/flycheck/pull/1606