From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: Re: How to add pseudo vector types Date: Wed, 21 Jul 2021 09:29:51 -0700 Message-ID: <86o8av4olc.fsf@stephe-leake.org> References: <83h7gw6pyj.fsf@gnu.org> <45EBF16A-C953-42C7-97D1-3A2BFEF7DD01@gmail.com> <83y2a764oy.fsf@gnu.org> <83v95b60fn.fsf@gnu.org> <00DD5BFE-D14E-449A-9319-E7B725DEBFB3@gmail.com> <83r1fz5xr9.fsf@gnu.org> <1AAB1BCC-362B-4249-B785-4E0530E15C60@gmail.com> <83czri67h0.fsf@gnu.org> <46BBFF88-76C3-4818-8805-5437409BEA93@gmail.com> <83wnpq46uk.fsf@gnu.org> <533BD53B-4E85-4E9E-B46A-346A5BBAD0F5@gmail.com> <258CB68D-1CC1-42C8-BDCD-2A8A8099B783@gmail.com> <1a776770-50b7-93cd-6591-c9a5b3a56eb8@gmail.com> <83lf654dhk.fsf@gnu.org> <2524265f-60c7-24f5-b9f4-98447c91acab@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="10954"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (windows-nt) Cc: Eli Zaretskii , emacs-devel@gnu.org To: =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 21 18:31:15 2021 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 1m6F7q-0002ez-Rs for ged-emacs-devel@m.gmane-mx.org; Wed, 21 Jul 2021 18:31:15 +0200 Original-Received: from localhost ([::1]:59674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m6F7p-0001Es-UR for ged-emacs-devel@m.gmane-mx.org; Wed, 21 Jul 2021 12:31:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6F6e-0000Oo-Nt for emacs-devel@gnu.org; Wed, 21 Jul 2021 12:30:00 -0400 Original-Received: from gateway31.websitewelcome.com ([192.185.144.94]:24788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m6F6c-0005WW-61 for emacs-devel@gnu.org; Wed, 21 Jul 2021 12:29:59 -0400 Original-Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway31.websitewelcome.com (Postfix) with ESMTP id D52AF2C2A8 for ; Wed, 21 Jul 2021 11:29:55 -0500 (CDT) Original-Received: from host2007.hostmonster.com ([67.20.76.71]) by cmsmtp with SMTP id 6F6Zmfvvm7sOi6F6ZmRz3i; Wed, 21 Jul 2021 11:29:55 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stephe-leake.org; s=default; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-ID:In-Reply-To:Date:References:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Fv/J0Jru+gf4xVNSSvZ9oGtA4ucgVs1F9aVxV5xxJjg=; b=fS/OgEzk9zsu7Cwh4pcgo4GyVu TYFSvipfzrnmgecino5PGmVHN9PaubJlujUKdkVi050npexUVN6mB8RDQyLS3cO9C/L5CyQ3VS+vM bW+xKeBGbqk7hvJyzDf2JSLsTkAvTR6rWd+s4cEdfk9fgNlNSVtdMFNuQFpdHL+6qWBPZ1PGplavr AcvvVh97vp3e8dGJNOxvo8eIr73C6ctPwFXKR9cL+iVmvLesfTtpYwUqRYhQN0AYxok70QCGTe2F4 iAr6DqUkIxmD6RQlIyhiwt7HgtSbYhEK94ve6qU6SxjsNiU8l96yJugljfkD3MXnnsKC+Ty2pTDaX UAu6FaLg==; Original-Received: from [76.77.182.20] (port=61909 helo=Takver4) by host2007.hostmonster.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1m6F6Z-000Uhd-3D; Wed, 21 Jul 2021 10:29:55 -0600 In-Reply-To: <2524265f-60c7-24f5-b9f4-98447c91acab@gmail.com> (=?utf-8?Q?=22Cl=C3=A9ment?= Pit-Claudel"'s message of "Tue, 20 Jul 2021 16:36:42 -0400") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host2007.hostmonster.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stephe-leake.org X-BWhitelist: no X-Source-IP: 76.77.182.20 X-Source-L: No X-Exim-ID: 1m6F6Z-000Uhd-3D X-Source-Sender: (Takver4) [76.77.182.20]:61909 X-Source-Auth: stephen_leake@stephe-leake.org X-Email-Count: 6 X-Source-Cap: c3RlcGhlbGU7c3RlcGhlbGU7aG9zdDIwMDcuaG9zdG1vbnN0ZXIuY29t X-Local-Domain: yes Received-SPF: permerror client-ip=192.185.144.94; envelope-from=stephen_leake@stephe-leake.org; helo=gateway31.websitewelcome.com X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_NEUTRAL=0.779 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.io gmane.emacs.devel:271419 Archived-At: Cl=C3=A9ment Pit-Claudel writes: > On 7/17/21 3:16 AM, Eli Zaretskii wrote: >>> You do need to be careful to not read the garbage data from the >>> gap, but otherwise seeing stale or even inconsistent data from the >>> parser thread shouldn't be an issue, since tree-sitter is supposed >>> to be robust to bad parses. >>=20 >> What would be the purpose of calling the parser if we know in advance >> it will fail when it gets to the "garbage" caused by async access to >> the buffer text? > > It won't fail, will it? I thought this was the point of TS, that it > would reuse the initial parse on the "good" parts in subsequent > parses. There are limits to the error recovery, and throwing garbage text at it is likely to encounter those limits. wisi is even more robust, but I still get "error recover fail" daily. >> So I don't see how this could be done without some inter-locking. > > Yes, there probably need to be some care around the gap area. But > that's what I was referring to re. "optimistic concurrency". > >> And what do you want the code which requested parsing do while the >> parse thread runs? The requesting code is in the main thread, so if >> it just waits, you don't gain anything. > > You'd have the parser running continuously in the background, every > time there is a change.=20 > When a piece of code requests a parse it blocks and waits, but > presumably for not too long because a very recent previous parse means > that the blocking parse is fast. If the parser is truly fast enough to keep up with typing, this does make sense. Good error correction is slower than non-so-good error correction, so there might be a trade-off here. On the other hand, in the typical case of the user typing characters, font-lock is triggered on every character, so the parser is effectively synchronous, and the inter-thread communication is wasted time. We need some metrics on a real implementation to decide this part of the design. >>> In fact, depending on how robust tree-sitter is, you might even be >>> able to do the concurrency-control optimistically (parse everything >>> up to close to the gap, check that the gap hasn't moved into the >>> region that you read, and then resume reading or rollback). >>=20 >> I don't understand what you suggest here. For starters, the gap could >> move (assuming you are still talking about a separate thread that does >> the parsing), and what do we do then? > > Nothing, we start the next parse when this one completes. By "nothing", I think you mean "abort the parse". >> Bottom line, I think what you are suggesting is premature >> optimization: we don't yet know that we will need this.=20 > > I thought we knew that a full parse of some files could take over a > second;=20 Yes, for both tree-sitter and wisi. wisi can take even longer if lots of error correction is required (I have a time-out set at 5 seconds). But that happens when the file is first opened; I doubt any user would start typing that fast. I know I typically take a while to just look at the text, and then navigate to the point of interest. > but yes, it will be nice if we can find a synchronous way to avoid > having to do a full parse. Hmm. "looking at the text" is better done after it is fontified, so doing a faster but possibly worse parse and fontification on just the initial visible region might be a good idea.=20 While the partial parse is running, we could also spawn a parser thread to run the full parse. And if the user scrolls before the full parse is done, do a second partial parse on the new visible region. I'll put that on my list of things to try in wisi. --=20 -- Stephe