|
From: | Dmitry Gutov |
Subject: | Re: Automatic (e)tags generation and incremental updates |
Date: | Tue, 12 Jan 2021 18:48:24 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 12.01.2021 17:08, Eli Zaretskii wrote:
Cc: tom@tromey.com, john@yates-sheets.org, philipk@posteo.net, emacs-devel@gnu.org From: Dmitry Gutov <dgutov@yandex.ru> Date: Tue, 12 Jan 2021 03:33:10 +0200(write-region (point-min) (point-max) buffer-file-name nil 'silent) I wonder if *that* could be done asynchronously.What kind of asynchronicity did you have in mind?One where the Lisp code doesn't have to wait for the disk write to complete.Wed don't have such facilities, because they would need locking the region (actually, probably the entire buffer) for changes while it runs.
I'd be fine with that (or if this feature required the use of a separate thread, with the buffer locked to it in the meantime).
But perhaps we could go with something simpler.
And I'm probbaly missing something, because I don't understand how Emacs is involved in updating the tags table.It's part of the secret sauce for the quick incremental updates: if etags writes to disk, even just to update one file's index, we'll have to revert-buffer, and the bigger the tags file is, the longer the revert will take. Basically, N(project-size).But still faster than write-region, no? Did you try it the other way around: let etags write to a file, and then revert, or even just replace some region that you wanted updated (with insert-file-contents)?
With a 45 MB tags file visited: ;; If visited normally: (benchmark 1 '(revert-buffer t t)) ; => 1.49 s (benchmark 1 '(write-region 1 (point-max) buffer-file-name)) ; => 0.45 s ;; If visited literally: (benchmark 1 '(revert-buffer t t)) ; => 1.37 s (benchmark 1 '(write-region 1 (point-max) buffer-file-name)) ; => 0.06 s(insert-file-contents "...") takes 0.15 in this example, which would make it possible to use if etags implemented the same logic that we do in Elisp currently (I tried bringing Tom's etags branch up to date, but the performance wasn't good). Also, we can choose not to synchronize to disk, or do it much less often, whereas we'd have to call insert-file-contents during every update.
Anyway, TAGS and etags.el were designed to be very tolerant to changes, so you shouldn't need to update very often.
I want it to update reliably; maybe not too often (depending on a project), but if a user switches to a different Git branch, they should be confident that they'll see the changes reflected in the index soon. Even (and especially) if those are big changes.
Right now only the update-on-save feature is in there, but I have to tell you, having a newly written function in the index right away (without having to invoke any commands or switch to the terminal) is pretty nice.
[Prev in Thread] | Current Thread | [Next in Thread] |