From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Markers in a gap array Date: Thu, 04 Jul 2024 18:24:47 -0400 Message-ID: References: <87ikxlqwu6.fsf@localhost> <87le2hp6ug.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="34362"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jul 05 00:25:51 2024 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 1sPUtj-0008j0-4E for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Jul 2024 00:25:51 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sPUst-0000Cb-HE; Thu, 04 Jul 2024 18:24: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 1sPUsr-0000C9-8N for emacs-devel@gnu.org; Thu, 04 Jul 2024 18:24:57 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sPUsp-0001IV-Hg for emacs-devel@gnu.org; Thu, 04 Jul 2024 18:24:56 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 9649B801C2; Thu, 4 Jul 2024 18:24:53 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1720131888; bh=RLpQ+xdPfvr3Gm8SbNm72tXQpVdOlu0Uqw7Bp1MN8bw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Nx1Vgb2QW22SBsl59yJI6klkiLML90XY+ndRaJM6rwD/Mn85Wg3JRNwdpyKNQ84UU nZhlVwku1PIgXOTXmpHFAKHyBku1rFcX3w1K+CmtLzXTLGLAese+7xd3aq31DnWzr6 4Y8ZOEF4+qmj1VzRmA/rORzL7sb95mSF4r0LcAcfwS695P1zx7vzEWjGHDfKhF0BEI b2zX4Al1fYniiWMhZlxdAfo3bk4JJtXNNLW36qU0zuH176K3ThnuqWfETKINz8WDtA ir0kxhaIUllVA97f8ZqCD497riyxhQ4qNG640eqI2KTqsxg+qSzT+RRH1bNWQzss+e JGjBzIceA49RQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 2143B802A8; Thu, 4 Jul 2024 18:24:48 -0400 (EDT) Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0F32612026C; Thu, 4 Jul 2024 18:24:48 -0400 (EDT) In-Reply-To: (Stefan Monnier's message of "Thu, 04 Jul 2024 16:11:28 -0400") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:321361 Archived-At: BTW, I just pushed to `scratch/gl-state-bytepos` an orthogonal patch which intends to reduce the use of `bytepos_to_charpos` by changing the `gl_state` cache so it keeps track of the byteposition of the boundaries of the current "chunk of `syntax-table` property". This way RE_UPDATE_SYNTAX_TABLE can take a bytepos rather than an charpos and convert it to charpos only when moving into a different "chunk of `syntax-table` property". On that previous benchmark, it works wonderfully (the implementation of markers has basically no impact any more in that benchmark): | test | non-gc avg (s) | gc avg (s) | gcs avg | tot avg (s) | tot avg err (s) | |------------------------+----------------+------------+---------+-------------+-----------------| | bytechar | 6.25 | 0.00 | 0 | 6.25 | 0.85 | | bytechar-100k | 6.41 | 0.00 | 0 | 6.41 | 0.65 | | bytechar-100k-nolookup | 6.61 | 0.00 | 0 | 6.61 | 0.17 | | bytechar-100k-random | 8.63 | 0.00 | 0 | 8.63 | 0.06 | | bytechar-100k-rev | 7.64 | 0.00 | 0 | 7.64 | 1.48 | | bytechar-10k-random | 6.79 | 0.00 | 0 | 6.79 | 0.10 | | bytechar-1k-random | 6.64 | 0.00 | 0 | 6.64 | 0.15 | | bytechar-nolookup | 6.63 | 0.00 | 0 | 6.63 | 0.23 | |------------------------+----------------+------------+---------+-------------+-----------------| | total | 55.61 | 0.00 | 0 | 55.61 | 1.86 | Of course, that's the ideal case: that buffer has no `syntax-table` text properties, so there's only one chunk. In buffers with many uses of the `syntax-table` text property, the patch may end up slowing things down because the update from one chunk to another requires not just a bytepos->charpos but also two additional charpos->bytepos conversions. Still, I suspect it will usually be beneficial (the cost of going from one chunk to another is itself significant so the extra charpos->bytepos conversions should not slow it down unduly). The patch has a significant FIXME that needs invesitgating (it passes all tests, but I'm not sure it's doing the right thing). Stefan