unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Criticism of jit-lock--antiblink-post-command
@ 2019-11-26 19:52 Alan Mackenzie
  2019-11-26 20:51 ` Stefan Monnier
  2019-11-26 21:09 ` João Távora
  0 siblings, 2 replies; 9+ messages in thread
From: Alan Mackenzie @ 2019-11-26 19:52 UTC (permalink / raw)
  To: João Távora; +Cc: Eli Zaretskii, emacs-devel

Hello, João.

I've been taking a closer look at the jit-lock antiblink functionality,
and some things seem to want comment.

Firstly, jit-lock-antiblink-grace is tested for being nil, yet is
declared in its customization scheme only as a number.  Should it not
alternatively be customizable to nil instead of a number?  This would
enable a user to disable it without having to read the source code and
use a setq.  The variable's doc string should surely also document this
possibility.

You have mentioned that this antiblink is redundant when using things
like electric-pair-mode, in which case the mode merely slows down the
processing.  The same is true of CC Mode, where there are no
unterminated strings.  These are good reasons for making antiblink easy
to disable.

In jit-lock--antiblink-post-command, you create lots of markers, one per
command.  You don't do anything to get rid of them, beyond waiting for
the next garbage collection to do its work.  This could easily lead to
several hundred markers slowing down operations in a buffer.  Maybe.
Page "Overview of Markers" in the Elisp manual recommends making them
point nowhere when you have finished with them, using (set-marker m
nil).  Please consider doing this.

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Criticism of jit-lock--antiblink-post-command
  2019-11-26 19:52 Criticism of jit-lock--antiblink-post-command Alan Mackenzie
@ 2019-11-26 20:51 ` Stefan Monnier
  2019-11-27  4:45   ` Eli Zaretskii
  2019-11-26 21:09 ` João Távora
  1 sibling, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2019-11-26 20:51 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Eli Zaretskii, João Távora, emacs-devel

> You have mentioned that this antiblink is redundant when using things
> like electric-pair-mode, in which case the mode merely slows down the
> processing.  The same is true of CC Mode, where there are no
> unterminated strings.

There's are still the issues of unterminated comments.

> These are good reasons for making antiblink easy to disable.

The intention is that when it's not useful it's harmless.
IOW if there's a good reason to turn it off, it's probably a bug.


        Stefan




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Criticism of jit-lock--antiblink-post-command
  2019-11-26 19:52 Criticism of jit-lock--antiblink-post-command Alan Mackenzie
  2019-11-26 20:51 ` Stefan Monnier
@ 2019-11-26 21:09 ` João Távora
  2019-11-27  5:54   ` Phil Sainty
  1 sibling, 1 reply; 9+ messages in thread
From: João Távora @ 2019-11-26 21:09 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Eli Zaretskii, emacs-devel

Hi Alan,

Indeed it makes sense to let the customizer explicitly
choose nil.  I will fix that. Doesn't the docstring already
say it can be nil?  Maybe you missed it at the end
of such a long docstring (I will make it shorter per Eli's
request).

It's easy to toggle the variable to nil buffer-locally, but as
Stefan said, it should be harmless when left on.

Regarding the markers, I'll have a look. But it seems
premature optimization.  Remember that I benchmarked
this and it presented no real problem.

João



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Criticism of jit-lock--antiblink-post-command
  2019-11-26 20:51 ` Stefan Monnier
@ 2019-11-27  4:45   ` Eli Zaretskii
  2019-11-27 13:46     ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2019-11-27  4:45 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: acm, joaotavora, emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: João Távora <joaotavora@gmail.com>,  Eli
>  Zaretskii <eliz@gnu.org>,
>   emacs-devel@gnu.org
> Date: Tue, 26 Nov 2019 15:51:04 -0500
> 
> > These are good reasons for making antiblink easy to disable.
> 
> The intention is that when it's not useful it's harmless.
> IOW if there's a good reason to turn it off, it's probably a bug.

I don't think I agree.  A post-command-hook that is not useful just
takes CPU cycles, and likewise a timer which does nothing when its
function is invoked.

And in any case, a feature that changes behavior should have a knob to
disable it.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Criticism of jit-lock--antiblink-post-command
  2019-11-26 21:09 ` João Távora
@ 2019-11-27  5:54   ` Phil Sainty
  2019-11-27  9:30     ` João Távora
  0 siblings, 1 reply; 9+ messages in thread
From: Phil Sainty @ 2019-11-27  5:54 UTC (permalink / raw)
  To: João Távora; +Cc: Alan Mackenzie, Eli Zaretskii, emacs-devel

On 2019-11-27 10:09, João Távora wrote:
> Regarding the markers, I'll have a look. But it seems
> premature optimization.

AFAIK that one is standard best practice for working with
markers, even if you're not expecting it to make a noticeable
difference.


-Phil




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Criticism of jit-lock--antiblink-post-command
  2019-11-27  5:54   ` Phil Sainty
@ 2019-11-27  9:30     ` João Távora
  2019-11-27 13:38       ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: João Távora @ 2019-11-27  9:30 UTC (permalink / raw)
  To: Phil Sainty; +Cc: Alan Mackenzie, Eli Zaretskii, emacs-devel

On Wed, Nov 27, 2019 at 5:54 AM Phil Sainty <psainty@orcon.net.nz> wrote:
>
> On 2019-11-27 10:09, João Távora wrote:
> > Regarding the markers, I'll have a look. But it seems
> > premature optimization.
>
> AFAIK that one is standard best practice for working with
> markers,

I understand that, and I think I've seen cases where it
matters.  Just this one doesn't seem to (for now, at
least). But it's very easy to fix and doesn't introduce
particular complexity in this case, so consider it done.

> even if you're not expecting it to make a noticeable
> difference.

Hmm, I do expect best practices to make noticeable
differences, at least for some value of "noticeable".
Otherwise, it becomes cargo-culting, don't you
think?

João



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Criticism of jit-lock--antiblink-post-command
  2019-11-27  9:30     ` João Távora
@ 2019-11-27 13:38       ` Stefan Monnier
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2019-11-27 13:38 UTC (permalink / raw)
  To: João Távora
  Cc: Phil Sainty, Alan Mackenzie, Eli Zaretskii, emacs-devel

>> even if you're not expecting it to make a noticeable
>> difference.
> Hmm, I do expect best practices to make noticeable
> differences, at least for some value of "noticeable".

In the case of manually deleting markers, it tends to be negligible in
most cases, but it can and does become noticeable when pushed harder.

We arguably could/should replace the singly-linked-list of markers with
another data structure that doesn't suffer from those algorithmic
problems, but ...


        Stefan




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Criticism of jit-lock--antiblink-post-command
  2019-11-27  4:45   ` Eli Zaretskii
@ 2019-11-27 13:46     ` Stefan Monnier
  2019-11-27 16:10       ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2019-11-27 13:46 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: acm, joaotavora, emacs-devel

>> The intention is that when it's not useful it's harmless.
>> IOW if there's a good reason to turn it off, it's probably a bug.
> I don't think I agree.  A post-command-hook that is not useful just
> takes CPU cycles, and likewise a timer which does nothing when its
> function is invoked.

AFAIK we don't try very hard to avoid such waste.
E.g. every time we run redisplay, it will check at every position if
there is a `display` or `invisible` property, even in those buffers
where no code ever has nor ever will add one of those properties.
[ This is just a random example, we have loads more, of course.  ]

> And in any case, a feature that changes behavior should have a knob to
> disable it.

We like such knobs in Emacs, indeed.  My argument was not against having
such a knob (which is already present in the suggested patch, AFAIK) but
in favor of keeping the feature enabled by default and encouraging
people to report problems when the encounter them rather than just turn
off the feature.


        Stefan




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Criticism of jit-lock--antiblink-post-command
  2019-11-27 13:46     ` Stefan Monnier
@ 2019-11-27 16:10       ` Eli Zaretskii
  0 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2019-11-27 16:10 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: acm, joaotavora, emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: acm@muc.de,  joaotavora@gmail.com,  emacs-devel@gnu.org
> Date: Wed, 27 Nov 2019 08:46:41 -0500
> 
> >> The intention is that when it's not useful it's harmless.
> >> IOW if there's a good reason to turn it off, it's probably a bug.
> > I don't think I agree.  A post-command-hook that is not useful just
> > takes CPU cycles, and likewise a timer which does nothing when its
> > function is invoked.
> 
> AFAIK we don't try very hard to avoid such waste.

We should, though.

> E.g. every time we run redisplay, it will check at every position if
> there is a `display` or `invisible` property, even in those buffers
> where no code ever has nor ever will add one of those properties.

No, the display engine doesn't check for these properties at every
position, it only checks that at positions where some property
changes (by looking at the interval tree).

And properties can be added manually, not just by code, btw.

> > And in any case, a feature that changes behavior should have a knob to
> > disable it.
> 
> We like such knobs in Emacs, indeed.  My argument was not against having
> such a knob

Well, by saying "if it needs to be turned off, it's a bug", you seemed
to be saying that it doesn't need to be turned off.  Apologies for my
misunderstanding.



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-11-27 16:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26 19:52 Criticism of jit-lock--antiblink-post-command Alan Mackenzie
2019-11-26 20:51 ` Stefan Monnier
2019-11-27  4:45   ` Eli Zaretskii
2019-11-27 13:46     ` Stefan Monnier
2019-11-27 16:10       ` Eli Zaretskii
2019-11-26 21:09 ` João Távora
2019-11-27  5:54   ` Phil Sainty
2019-11-27  9:30     ` João Távora
2019-11-27 13:38       ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).