From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#65491: [PATCH] Improve performance allocating vectors Date: Sat, 26 Aug 2023 07:47:34 +0000 Message-ID: <87r0nq9re1.fsf@localhost> References: <87y1i0iwvu.fsf@localhost> <83bkeumg17.fsf@gnu.org> <87ttsm9sbk.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26060"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65491@debbugs.gnu.org, Stefan Monnier To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 26 09:48:21 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qZo1t-0006bI-6T for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Aug 2023 09:48:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZo1X-0007sP-Gx; Sat, 26 Aug 2023 03:47:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZo1W-0007sG-0C for bug-gnu-emacs@gnu.org; Sat, 26 Aug 2023 03:47:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qZo1V-0002Ul-OH for bug-gnu-emacs@gnu.org; Sat, 26 Aug 2023 03:47:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qZo1a-0003dC-BV for bug-gnu-emacs@gnu.org; Sat, 26 Aug 2023 03:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 26 Aug 2023 07:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65491 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 65491-submit@debbugs.gnu.org id=B65491.169303604213763 (code B ref 65491); Sat, 26 Aug 2023 07:48:02 +0000 Original-Received: (at 65491) by debbugs.gnu.org; 26 Aug 2023 07:47:22 +0000 Original-Received: from localhost ([127.0.0.1]:41659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZo0v-0003Zt-0D for submit@debbugs.gnu.org; Sat, 26 Aug 2023 03:47:22 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:47651) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZo0q-0003Zd-12 for 65491@debbugs.gnu.org; Sat, 26 Aug 2023 03:47:19 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id B2885240028 for <65491@debbugs.gnu.org>; Sat, 26 Aug 2023 09:47:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1693036024; bh=ldBFpx03w3NCpZMFhP9hdFXOss02ObsT0JjzIf/Lfgk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=OLg6efkjUoiTM1YVf7lW6igOjVABAOauWl8dNPZuSeSymA8Gm1fzpWRB80rR0eomE P60ZwfvlcHrM0P4vWRlE/RxzxkXNLueHyQzMky0PbP6yCwTFX+xYjqt7YnLV2CH50J 08yJwarv+YWxR+4DpP8brHSdhX1g9H/6p1w8OcNR5MSqcYjRKLSF15sJDshvDO4Cc+ nT/IUDExiwXaRlIf5Oq1DPaeA3gfID0y3G+aH++TB6NzWhd60WzLun5EeiOgsT7wTG RynZ2yNWlu2fCOtFiG5Rdw+mR1wLJwaCeI2TYH0U/tQsiO8FyAB9BB8qQI7kjOlRpN rXoFRgUoWeIIQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RXpn36zH5z9s4T; Sat, 26 Aug 2023 09:47:03 +0200 (CEST) In-Reply-To: <87ttsm9sbk.fsf@localhost> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:268479 Archived-At: Ihor Radchenko 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 . Support Org development at , or support my work at