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#63225: Compiling regexp patterns (and REGEXP_CACHE_SIZE in search.c) Date: Wed, 03 May 2023 15:05:06 +0000 Message-ID: <87zg6lfobh.fsf@localhost> References: <63882A45-BD02-40D5-92FA-70175267BA3B@acm.org> <874jou7lsf.fsf@localhost> <37EED5F9-F1FE-46B6-B4FA-0B268B945123@gmail.com> <87wn1qqvj0.fsf@localhost> <34F4849A-CB39-4C96-9CC1-11ED723706DA@gmail.com> <87wn1psqny.fsf@localhost> <6DAF37F9-B236-4C33-8E30-0FCA47CCBCC5@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35930"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 63225@debbugs.gnu.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 03 17:03:27 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 1puE0t-000995-AD for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 03 May 2023 17:03:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puE0X-0004rB-Lr; Wed, 03 May 2023 11:03:05 -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 1puE0V-0004qa-6l for bug-gnu-emacs@gnu.org; Wed, 03 May 2023 11:03:03 -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 1puE0U-000749-Gw for bug-gnu-emacs@gnu.org; Wed, 03 May 2023 11:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1puE0T-000761-TE for bug-gnu-emacs@gnu.org; Wed, 03 May 2023 11:03:01 -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, 03 May 2023 15:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63225 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 63225-submit@debbugs.gnu.org id=B63225.168312612827195 (code B ref 63225); Wed, 03 May 2023 15:03:01 +0000 Original-Received: (at 63225) by debbugs.gnu.org; 3 May 2023 15:02:08 +0000 Original-Received: from localhost ([127.0.0.1]:47497 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puDzc-00074Y-66 for submit@debbugs.gnu.org; Wed, 03 May 2023 11:02:08 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:34755) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puDzX-00073r-2f for 63225@debbugs.gnu.org; Wed, 03 May 2023 11:02:06 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 9E7292405ED for <63225@debbugs.gnu.org>; Wed, 3 May 2023 17:01:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1683126116; bh=aF1QTNAQuIfcJK3tWm+0fkYzvpkviA81ErBG3amTb1k=; h=From:To:Cc:Subject:Date:From; b=lVTk6yMp+s6jNOLTn8gH9/wxZhTUiCDmxB87PeXp4d8bP82m17YBoBgjHnqElqXZV hx+aVxaIEoRaAGqbBT16wIZZJmsBoszXf1bX567+MEEOL4rZwx0MfFwwZvGlwKMbY+ vxIicrAMKhmyMAZ9kBz1Tdw/24Cg6gh2IbjtePewInFqS5qAZBWUU1xQHNVCkguLml nEjWCL7N4NVIoCFO2BHXYhR3uaTfbTmvYb3lQkw7LF+5q0T2oDcNWJYXvxV+vpwavZ LZ2bJhEeWumm8eU4WG17wQgNLnEgLvKWLGT0RtIow+xxlmoIhWfYecljz1u8nKW8OT Yjedp2P0pdq5g== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QBKsv6LsTz9rxP; Wed, 3 May 2023 17:01:55 +0200 (CEST) In-Reply-To: <6DAF37F9-B236-4C33-8E30-0FCA47CCBCC5@gmail.com> 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:260980 Archived-At: Mattias Engdeg=C3=A5rd writes: > 3 maj 2023 kl. 11.36 skrev Ihor Radchenko : > >> Yet, in my tests, I am unable to see any improvement when I consolidate >> the regexps. > > That's odd, but do you get a better cache hit rate (assuming a cache size= of 20)? With the default cache size of 20, (benchmark-progn (setq regexp-cache-hit 0 regexp-cache-miss 0) (set-regexp-cache-size 20) (org-element-parse-buffer) nil) (cond ((looking-at-p ...) ...)) gives misses: 1493570 hits: 3225203 % misses from total: 31% giant rx + looking-at gives misses: 1177242 hits: 3233553 % misses from total: 27% >> The version with giant single rx form is actually slower overall (!), >> making no difference at all in `org-element--current-element'. > > Can't say what's going on here, really. Normally a combined regexp > shouldn't be slower. Are you sure you get the same parse? All the tests are passing... Note that I am using `looking-at-p' I now also tried replacing `looking-at-p' with `looking-at' and I get 4880 21% + org-element--current-element (previous data with `looking-at-p') 4160 21% + org-element--current-element=20 with total time increasing compared to the version with `looking-at-p' (21.743226s (1.364015s in 2 GCs) compared to 21.035765s (1.091127s in 2 GCs= )) --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at