[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to add pseudo vector types

From: Clément Pit-Claudel
Subject: Re: How to add pseudo vector types
Date: Fri, 16 Jul 2021 22:23:26 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

On 7/16/21 10:05 PM, Yuan Fu wrote:
> My conclusion is that after-change-hook is pretty insignificant, and the 
> initial parse is a bit slow (on large files).

I have no idea if it makes sense, but: does the initial parse need to be 
synchronous, or could you instead run the parsing in one thread, and the rest 
of Emacs in another? (I'm talking about concurrent execution, not cooperative 

In most cases there should be very limited contention, if at at all: in large 
buffers most of Emacs' activity will be focused on the (relatively few) 
characters around the gap, and most of the parser's activity will be reading 
from the buffer at other positions.  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.

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).

Alternatively, maybe you could even do a full parse with minimal concurrency 
control: you'd make sure that the Emacs thread records not just changes to the 
buffer text but also movements of the gap, and then you could use that list of 
changes for the next parse?

Anyway, thanks for working on this!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]