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#58558: 29.0.50; re-search-forward is slow in some buffers Date: Wed, 12 Apr 2023 13:39:09 +0000 Message-ID: <87sfd5b4oy.fsf@localhost> References: <877d10r21x.fsf@localhost> <87wn8x9eqb.fsf@gnus.org> <87tu1zd2c6.fsf@localhost> <83h6xzphxm.fsf@gnu.org> <87wn6vbfaa.fsf@localhost> <838rjbpecw.fsf@gnu.org> <87fsdjwb4e.fsf@localhost> <874jtyuqax.fsf@localhost> <83zgbqm8q6.fsf@gnu.org> <87sfhit8ug.fsf@localhost> <83tu1ym6jo.fsf@gnu.org> <87h6xyt77x.fsf@localhost> <87h6ttkz6n.fsf@localhost> <838rf5qkpt.fsf@gnu.org> <87lej0zv92.fsf@localhost> <83ttxol6f5.fsf@gnu.org> <87h6tolybs.fsf@localhost> <87zg7e8xnt.fsf@localhost> <83ttxmab7x.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32275"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58558@debbugs.gnu.org, larsi@gnus.org, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 12 15:37:25 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 1pmaf7-0008Do-Ic for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 Apr 2023 15:37:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmaem-00021a-I2; Wed, 12 Apr 2023 09:37:04 -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 1pmaek-00020z-Ja for bug-gnu-emacs@gnu.org; Wed, 12 Apr 2023 09:37:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pmaek-0004ML-90 for bug-gnu-emacs@gnu.org; Wed, 12 Apr 2023 09:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pmaek-0000u3-2a for bug-gnu-emacs@gnu.org; Wed, 12 Apr 2023 09:37: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: Wed, 12 Apr 2023 13:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58558 X-GNU-PR-Package: emacs Original-Received: via spool by 58558-submit@debbugs.gnu.org id=B58558.16813066133456 (code B ref 58558); Wed, 12 Apr 2023 13:37:02 +0000 Original-Received: (at 58558) by debbugs.gnu.org; 12 Apr 2023 13:36:53 +0000 Original-Received: from localhost ([127.0.0.1]:39379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmaea-0000tg-Ea for submit@debbugs.gnu.org; Wed, 12 Apr 2023 09:36:52 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:49949) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmaeY-0000tM-5z for 58558@debbugs.gnu.org; Wed, 12 Apr 2023 09:36:51 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id F066124041E for <58558@debbugs.gnu.org>; Wed, 12 Apr 2023 15:36:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1681306604; bh=wTnmq5O6WIrK7fS/e0aTmrO4bgEEsjqHtYIai7Sh+Nk=; h=From:To:Cc:Subject:Date:From; b=LJYOQ7GQD6vTIpQdXf/C5dN5NuboFXxthJeWunOtX/jpMM+FmLHq0RuUXjpfuQ0M4 2/qBlROeSuowig5pjW+Q2cdlqIIbAKZsnS8/z1XrjkYZQom2lHQoHwsplLkP84DLCt lzGxR1/5I5taeK7JkulcuBo/3mL1aWNTNoKJbqT5P7Drw4ZKTE1ktwWmCd5ngXiDce m/06cYuKbdG1bAPediixyhHSywQb+YhxxHvoBrvNHOFBQFdZeTH1U+dvP4AX7EOuxM FR7miY5Bm9zet5jqrviqXGesCuZdL29F/UK0J5xRZQqvoUsrEMNymGsK+Knezp5sjI kxxKwfvc4xnCA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PxNzH29CQz9rxG; Wed, 12 Apr 2023 15:36:43 +0200 (CEST) In-Reply-To: <83ttxmab7x.fsf@gnu.org> 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:259740 Archived-At: Eli Zaretskii writes: >> Well. I just tried, but my Emacs-C foo is not good enough. >> The attached patch fails to compile. > > That's because you've put DEFVAR_INT outside of any function. They > should be inside one of the syms_of_* functions instead. > regex-emacs.c doesn't have such a function, but search.c does. So > just move those DEFVAR_INT lines to syms_of_search, and I think it > will work. Thanks! I now managed to define these variables + also a counter inside buf_bytepos_to_charpos. The results are interesting. The call count for each SYNTAX_TABLE_BYTE_TO_CHAR inside re_match_2_internal (there are 6 places where it is called): - master :: 28 5011460 20 96 285 539911 - Emacs 28 :: 68 5015326 26 397 1404 558585 Master has less calls... This was weird, so I also added a counter inside buf_bytepos_to_charpos: - master :: 6,304,522 - Emacs 28 :: 593,430 Now, it is clear that it is something in SYNTAX_TABLE_BYTE_TO_CHAR that triggers buf_bytepos_to_charpos more on master compared to Emacs 28. I looked into the code: INLINE ptrdiff_t SYNTAX_TABLE_BYTE_TO_CHAR (ptrdiff_t bytepos) { return (! parse_sexp_lookup_properties ? 0 ... } parse_sexp_lookup_properties looks suspicious, so I checked the value of parse-sexp-lookup-properties in Org files on master vs. Emacs 28. On master, the value is t, even though Org mode does not set this variable. On Emacs 28, the value is nil. I looked further and narrowed things down to helpful package in my config, where the culprit is (require 'cc-langs). It looks like for some reason cc-langs changes the default value of parse-sexp-lookup-properties globally! Recipe: 1. emacs -Q 2. M-: (require 'cc-langs) 3. C-x b asd 4. M-: parse-sexp-lookup-properties => t On Emacs 28, (4) yields nil. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at