emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#51631: closed (29.0.50; cc-mode fontification makes CPU at 100%)


From: GNU bug Tracking System
Subject: bug#51631: closed (29.0.50; cc-mode fontification makes CPU at 100%)
Date: Sat, 13 Nov 2021 12:11:02 +0000

Your message dated Sat, 13 Nov 2021 12:10:07 +0000
with message-id <YY+rH+KsiCZtwNHT@ACM>
and subject line Re: bug#51692: 29.0.50; High CPU in c++ mode. Type finder?
has caused the debbugs.gnu.org bug report #51692,
regarding 29.0.50; cc-mode fontification makes CPU at 100%
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
51692: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=51692
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: 29.0.50; cc-mode fontification makes CPU at 100% Date: Sat, 06 Nov 2021 19:02:03 +0800
In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo 
version 1.17.4)
 of 2021-11-06 built on lilydjwg
Repository revision: 5a013838746c160cb296e0bc80a11795d2538f9a
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Arch Linux

It's originally reported at emacs-china.org [1].

emacs -Q, then open the following c++ snippet.

#+begin_src C++
#include <iostream>
#include <vector>

#define MAX 10000

void merge(std::vector<int> array, int p, int q, int r) {
  int len_1 = q - p + 1;
  int len_2 = r - q;
  int a = 0;
  int b = 0;
  std::vector<int> left_array(len_1 + 2, 0);
  std::vector<int> right_array(len_2 + 2, 0);
  for (int i = 0; i < len_1; ++i) {
    left_array[i] = array[p + i - 1];
  }
  for (int i = 0; i < len_2; ++i) {
    right_array[i] = array[q + i];
  }
  left_array[len_1 + 1] = MAX;
  right_array[len_2 + 1] = MAX;
  for (int i = p; i < r + 1; ++i) {
    if (left_array[a] <= right_array[b]) {
      array[i] = left_array[a];
      ++a;
    } else {
      array[i] = right_array[b];
      ++b;
    }
  }
}

void merge_sort(std::vector<int> array, int p, int r) {
  if (p < r) {
    int q = (p + r) / 2;
    merge_sort(array, p, q);
    merge_sort(array, q + 1, r);
    merge(array, p, q, r);
  }
}

int main() {
  std::vector<int> array = {3, 1, 2, 6, 4, 5};
  merge_sort(array, 0, array.size() - 1);
  for (auto i : array) {
    std::cout << i << "\n";
  }
  return 0;
}
#+end_src

The profiler shows `jit-lock-function' costs 62% CPU time.

#+begin_src text
2952  62% - redisplay_internal (C function)
        2936  62%  - jit-lock-function
        2936  62%   - jit-lock-fontify-now
        2920  62%    - jit-lock--run-functions
        2920  62%     - run-hook-wrapped
        2920  62%      - #<compiled 0x19b62a583670403d>
        2920  62%       - font-lock-fontify-region
        2920  62%        - c-font-lock-fontify-region
        2605  55%         - font-lock-default-fontify-region
        2534  53%          - font-lock-fontify-keywords-region
        1339  28%           - c-font-lock-declarations
        1317  27%            - c-find-decl-spots
         593  12%             + #<compiled 0x62f8c10afa44432>
         582  12%             + c-bs-at-toplevel-p
#+end_src

[1]: https://emacs-china.org/t/emacs-c/18814

-- 
Zhiwei Chen



--- End Message ---
--- Begin Message --- Subject: Re: bug#51692: 29.0.50; High CPU in c++ mode. Type finder? Date: Sat, 13 Nov 2021 12:10:07 +0000
Hello, Zhiwei, David, Yuri, and Lars.

On Sat, Nov 13, 2021 at 17:24:22 +0800, Zhiwei Chen wrote:
> Alan Mackenzie <acm@muc.de> writes:

> > Thanks!  That's good to hear.  I'll just give Zhiwei Chen a little time
> > to reply, and assuming (s)he doesn't find problems, I'll commit the fix.

> It solves the issue after applied the patch on Emacs trunk. Thanks.

Thanks to everybody for the testing.  I have now committed the fix to
the master branch, and am closing the bug with this post.

> -- 
> Zhiwei Chen

-- 
Alan Mackenzie (Nuremberg, Germany).


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]