Subject: Re: bug#70216: 30.0.50; self-insert-command doesn't respect create-lockfiles

From: Theodor Thornhill <[email-masked]>
Date: Sun, 07 Apr 2024 08:40:58 +0200

On Apr 7, 2024 08:31, Eli Zaretskii <[email-masked]> wrote:

> From: Theodor Thornhill <[email-masked]>
> Cc: [email-masked]
> Date: Sat, 06 Apr 2024 23:29:56 +0200
>
> >> The documentation states:
> >> ```
> >> If the option `create-lockfiles' is nil, this does nothing.
> >> ```
> >
> > I guess we need to fix the documentation, then.
> >
>
> Sure ;)

Done on the emacs-29 branch.

Thanks!

> > Lock files and file-change detection are Emacs safety measures that
> > are important on any modern OS.  Disabling them because they eat up
> > CPU cycles is wrong, from where I stand.  That said, hundreds of
> > milliseconds for 2 calls to 'stat' sounds excessive to me, so please
> > tell more details and try to show the breakdown of this long time.
> >
>
> Sure! So it all starts in prepare_to_modify_buffer, where we run the
> verify_internal_modification. This is pretty fast, in the order of ~10
> microseconds. Next up is the Flock_file, which delegates to
> lock_file. Before jumping into lock_file we run Ffind_file_name_handler,
> which takes between 50 and 200 microseconds on my system, depending on
> general load, I assume. now we jump into lock_file, from which we inside
> Fverify_visited_file_modtime run Ffind_file_name_handler for good
> measure, for another 50-200microseconds.
>
> This to me looks like _at least_ one too many calls to
> Ffind_file_name_handler causing almost half a millisecond on keypress,
> which sounds very excessive.

The extra call is only when the file is local.  And losing 50 to 200
microseconds doesn't sound bad to me.

Also, we don't call lock-file on each keystroke, only on the first one
that makes the buffer modified when it was previously unmodified.  So
when you type several characters in sequence, the net slowdown will be
very small.

In any case, you originally said this took hundreds of milliseconds,
not hundreds of microseconds.  Was that a typo, and you really meant
microseconds?

Hmm, I believe I said microseconds, but if I did, then yes, that was a typo.

> If you're interested, take this trace file and plop it into
> https://magic-trace.org and search for self_insert_command and move
> around with wasd.

Hmm... you just sent a 15MB file, uncompressed, to everyone who is
subscribed to bug-gnu-emacs...

Yeah... Though it was stopped by the admins and gzipped for me. I believe you were the only one getting the full file. Apologies.

I think we can close this if you don't think this is worth it, at least the docs got fixed :)

Theo