From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Reliable after-change-functions (via: Using incremental parsing in Emacs) Date: Wed, 01 Apr 2020 18:59:31 +0300 Message-ID: <838sjfyz6k.fsf@gnu.org> References: <83o8sf3r7i.fsf@gnu.org> <2E218879-0F24-4A20-B210-263C8D0BEEA4@gmail.com> <838sjh2red.fsf@gnu.org> <83369o3bvb.fsf@gnu.org> <83imik1qbq.fsf@gnu.org> <835zek1kpv.fsf@gnu.org> <83v9mkz5oo.fsf@gnu.org> <83pncsym6l.fsf@gnu.org> <4a9d6bb2-458d-89b0-5389-d1f883ef24a1@yandex.ru> <74f34b72-725d-2390-faea-c61daad43350@yandex.ru> <83eet7z4if.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="10173"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, akrl@sdf.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Apr 01 18:02:22 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJfor-0002X2-BT for ged-emacs-devel@m.gmane-mx.org; Wed, 01 Apr 2020 18:02:21 +0200 Original-Received: from localhost ([::1]:33974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJfoq-0004MN-B4 for ged-emacs-devel@m.gmane-mx.org; Wed, 01 Apr 2020 12:02:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55205) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJfmF-0002jP-Gs for emacs-devel@gnu.org; Wed, 01 Apr 2020 11:59:42 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:35265) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jJfmD-0004z1-S1; Wed, 01 Apr 2020 11:59:37 -0400 Original-Received: from [176.228.60.248] (port=3684 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jJfmB-00055I-De; Wed, 01 Apr 2020 11:59:36 -0400 In-Reply-To: (message from Dmitry Gutov on Wed, 1 Apr 2020 18:16:04 +0300) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:246207 Archived-At: > Cc: emacs-devel@gnu.org, casouri@gmail.com, monnier@iro.umontreal.ca, > akrl@sdf.org > From: Dmitry Gutov > Date: Wed, 1 Apr 2020 18:16:04 +0300 > > > I see a very different picture here: the above takes something like > > 15%. Most of the time is spent in functions called by jit-lock. > > What are your measurements, though? My full profile is below. This is from Emacs 27.0.90 compiled with the -Og optimization and with wide-int (which slows down Emacs by about 30%). > Again, what does this print out? > > (benchmark 1 '(progn (find-file "src/xdisp.c"))) Elapsed time: 1.733853s (0.140584s in 6 GCs) > No 'goto-char'. As we've established, it only affects the time taken by > redisplay, and I can't measure that. So I'm not profiling it either, > otherwise I'd be comparing apples to oranges. See the second profile below. > Yes. The numbers can be different, but there is definitely some up-front > computation there. One that's not present with e.g. js-mode. So you are saying that we should do that up-front computation just because CC mode currently does it? That we shouldn't try to eliminate such preprocessing? I don't think so. Here's the profile from visiting xdisp.c and going to end of the buffer: - redisplay_internal (C function) 65 41% - jit-lock-function 65 41% - jit-lock-fontify-now 65 41% - jit-lock--run-functions 65 41% - run-hook-wrapped 65 41% - # 65 41% - font-lock-fontify-region 65 41% - c-font-lock-fontify-region 65 41% - font-lock-default-fontify-region 50 31% - font-lock-fontify-keywords-region 35 22% - c-font-lock-declarations 34 21% - c-find-decl-spots 34 21% - c-bs-at-toplevel-p 32 20% - c-brace-stack-at 32 20% - c-update-brace-stack 31 19% - c-syntactic-re-search-forward 27 17% - c-beginning-of-macro 6 3% back-to-indentation 2 1% # 1 0% c-forward-sws 1 0% - c-font-lock-complex-decl-prepare 1 0% - c-parse-state 1 0% - c-parse-state-1 1 0% - c-parse-state-get-strategy 1 0% - c-get-fallback-scan-pos 1 0% - beginning-of-defun 1 0% - beginning-of-defun-raw 1 0% syntax-ppss 1 0% - font-lock-fontify-syntactically-region 15 9% syntax-ppss 15 9% - c-before-context-fl-expand-region 15 9% - mapc 15 9% - # 15 9% - c-context-expand-fl-region 15 9% - c-fl-decl-start 15 9% - c-literal-start 14 8% - c-semi-pp-to-literal 14 8% c-parse-ps-state-below 14 8% c-determine-limit 1 0% - command-execute 64 40% - call-interactively 64 40% - funcall-interactively 63 40% - eval-last-sexp 63 40% - elisp--eval-last-sexp 63 40% - eval 63 40% - progn 63 40% - progn 63 40% - find-file 63 40% - find-file-noselect 63 40% - find-file-noselect-1 63 40% - after-find-file 63 40% - normal-mode 61 38% - set-auto-mode 61 38% - set-auto-mode-0 61 38% - c-mode 61 38% - c-common-init 57 36% - mapc 57 36% - # 37 23% - c-neutralize-syntax-in-CPP 20 12% - c-beginning-of-macro 4 2% c-backward-single-comment 2 1% back-to-indentation 1 0% c-no-comment-end-of-macro 3 1% c-after-change-mark-abnormal-strings 15 9% c-parse-quotes-after-change 1 0% - # 20 12% - c-before-change-check-unbalanced-strings 15 9% - c-literal-limits 15 9% - c-full-pp-to-literal 15 9% c-parse-ps-state-below 15 9% c-depropertize-CPP 4 2% - byte-code 2 1% require 1 0% - run-mode-hooks 1 0% - hack-local-variables 1 0% - hack-dir-local-variables 1 0% dir-locals-read-from-dir 1 0% - run-hooks 2 1% - vc-refresh-state 2 1% - vc-backend 2 1% - vc-registered 2 1% - mapc 2 1% - # 2 1% - vc-call-backend 2 1% - apply 2 1% - vc-git-registered 2 1% - if 2 1% - progn 2 1% - load 1 0% require 1 0% - byte-code 1 0% - read-extended-command 1 0% - completing-read 1 0% completing-read-default 1 0% - ... 28 17% Automatic GC 27 17% - substitute-key-definition-key 1 0% - substitute-key-definition 1 0% - map-keymap 1 0% - # 1 0% - substitute-key-definition-key 1 0% - substitute-key-definition 1 0% - map-keymap 1 0% - # 1 0% - substitute-key-definition-key 1 0% - substitute-key-definition 1 0% - map-keymap 1 0% - # 1 0% - substitute-key-definition-key 1 0% - substitute-key-definition 1 0% - map-keymap 1 0% # 1 0% Here's the profile from just visiting xdisp.c: - command-execute 67 82% - call-interactively 67 82% - funcall-interactively 67 82% - eval-expression 67 82% - eval 67 82% - progn 67 82% - find-file 67 82% - find-file-noselect 67 82% - find-file-noselect-1 66 81% - after-find-file 66 81% - normal-mode 62 76% - set-auto-mode 62 76% - set-auto-mode-0 62 76% - c-mode 62 76% - c-common-init 55 67% - mapc 55 67% - # 36 44% - c-neutralize-syntax-in-CPP 21 25% - c-beginning-of-macro 2 2% c-backward-single-comment 1 1% c-after-change-mark-abnormal-strings 14 17% - # 19 23% - c-before-change-check-unbalanced-strings 14 17% - c-literal-limits 14 17% - c-full-pp-to-literal 14 17% c-parse-ps-state-below 14 17% - c-depropertize-CPP 4 4% c-end-of-macro 1 1% - byte-code 6 7% require 4 4% - substitute-key-definition 1 1% - map-keymap 1 1% - # 1 1% - substitute-key-definition-key 1 1% - substitute-key-definition 1 1% map-keymap 1 1% - run-hooks 4 4% - vc-refresh-state 4 4% - vc-backend 4 4% - vc-registered 4 4% - mapc 3 3% - # 3 3% - vc-call-backend 3 3% - apply 3 3% - vc-git-registered 2 2% - if 2 2% - progn 2 2% - load 1 1% - require 1 1% - defconst 1 1% byte-code 1 1% - vc-git-registered 1 1% - vc-git--out-ok 1 1% - apply 1 1% - vc-git--call 1 1% - apply 1 1% - process-file 1 1% apply 1 1% - vc-git-find-file-hook 1 1% - vc-state 1 1% - vc-state-refresh 1 1% - vc-call-backend 1 1% - apply 1 1% - vc-git-state 1 1% - apply 1 1% - vc-git--run-command-string 1 1% - apply 1 1% - vc-git--out-ok 1 1% - apply 1 1% - vc-git--call 1 1% - apply 1 1% - process-file 1 1% apply 1 1% vc-file-getprop 1 1% - find-buffer-visiting 1 1% - file-truename 1 1% - file-truename 1 1% - file-truename 1 1% - file-truename 1 1% - file-truename 1 1% file-truename 1 1% - ... 14 17% Automatic GC 14 17%