GNU bug report logs - #65491
[PATCH] Improve performance allocating vectors

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Thu, 24 Aug 2023 10:00:02 UTC

Severity: wishlist

Tags: patch

Full log


Message #17 received at 65491 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 65491 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#65491: [PATCH] Improve performance allocating vectors
Date: Sat, 26 Aug 2023 07:47:34 +0000
Ihor Radchenko <yantar92 <at> posteo.net> writes:

> If you know any useful code that makes heavy use of vector allocation, I
> can also benchmark it.

One example is the newer versions of Org parser, where I know for sure
that vector allocation is used. Although the code is mostly doing regexp
search for parsing, so a better real world example would be still useful.

I ran a quick parser run on a large Org file using

(let ((large-file-warning-threshold nil)
      (gc-cons-threshold most-positive-fixnum)
      (org-inhibit-startup t)
      (org-element-cache-persistent nil))
  (with-current-buffer (find-file-noselect "~/Org/notes.org")
    (message "%s" (benchmark-call (lambda () (org-element-parse-buffer nil nil 'defer))))))

Without the patch:

$ perf record ./src/emacs -Q -batch -L ~/Git/org-mode/lisp -L ~/.emacs.d/eln-cache/30.0.50-17ebec90/ -l org-element -l /tmp/test.el
(15.724130802000001 1 0.429624333)

without the patch:

    26.60%  emacs    emacs                           [.] exec_byte_code
    12.40%  emacs    emacs                           [.] re_match_2_internal
     8.70%  emacs    emacs                           [.] re_search_2
     8.19%  emacs    emacs                           [.] re_compile_pattern
     3.73%  emacs    emacs                           [.] re_iswctype
     3.60%  emacs    emacs                           [.] funcall_subr
     3.08%  emacs    emacs                           [.] allocate_vectorlike
     2.70%  emacs    emacs                           [.] plist_get
     1.80%  emacs    emacs                           [.] buf_charpos_to_bytepos

Vector allocation takes about 3% of the time.

-----------
with the patch, vector allocation contributions drops to 0.42% - 6x
decrease.
-----------

$ perf record ./src/emacs -Q -batch -L ~/Git/org-mode/lisp -L ~/.emacs.d/eln-cache/30.0.50-17ebec90/ -l org-element -l /tmp/test.el
(15.100695088 1 0.43508134400000004)

    27.06%  emacs    emacs                                [.] exec_byte_code
    12.96%  emacs    emacs                                [.] re_match_2_internal
     8.90%  emacs    emacs                                [.] re_search_2
     8.55%  emacs    emacs                                [.] re_compile_pattern
     3.68%  emacs    emacs                                [.] re_iswctype
     3.57%  emacs    emacs                                [.] funcall_subr
     2.80%  emacs    emacs                                [.] plist_get
...
     0.42%  emacs    emacs                                [.] allocate_vectorlike

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>




This bug report was last modified 1 year and 263 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.