Subject: Re: bug#49261: 28.0.50; File Locking Breaks Presumptuous Toolchains

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 07 Jul 2021 20:58:29 +0200

Eli Zaretskii <[email-masked]> writes:

> Even if it currently works, it's unsafe, IMO, to not have any
> protection there.  No one will remember that we rely on this not being
> called early enough.

Right.  My reasoning was that it seemed unlikely to be a problem here,
since the same function also (possibly) calls the Lisp functions
userlock--ask-user-about-supersession-threat and ask-user-about-lock.
But those are only called in some cases, so we're calling out to Lisp
more now than before, and that may indeed be a problem.

I can add a check to whether the Lisp function is defined before calling
(and then not do locking if it isn't) to be more defensive here?

> My point is that this simplicity comes at a price.  We've been
> consistently moving code from C primitives to Lisp, and by doing that
> significantly increase the consing during even the simplest editing
> operations.  All this consing adds up, with the result that Emacs
> nowadays produces much more garbage, which then triggers frequent GC
> cycles, which slow down Emacs.  It's a small wonder we see so many
> people out there raising the GC threshold to dangerous levels.
>
> So I'm asking whether the simplicity justifies the costs, here and
> elsewhere.

I agree with you 100% that it's important to take this into
consideration when moving things from C to Lisp.  In this particular
case, I think the cost is justified, because this isn't a function
that's called in a loop, and the other things it does (calling
Fverify_visited_file_modtime and Ffile_exists_p, and actually creating
the lock file) totally swamps any extra string consing, I think.  (That
is, it won't take measurably longer.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no