Subject: Re: bug#20285: 25.0.50; blink-cursor-mode sometimes stops blinking

From: Tassilo Horn <[email-masked]>
Date: Sat, 11 Apr 2015 21:24:18 +0200

Eli Zaretskii <[email-masked]> writes:

>> In general, I've been amazed how often redisplay is performed even
>> though nothing has changed in neither the single window containing the
>> buffer with my latex doc nor the minibuffer.  Ten times a second is very
>> likely, maybe even more.
>
> Really?  Is that in "emacs -Q"?  I get only 20 entries to redisplay,
> every 0.5 sec, one each for every toggle of the blinking cursor, and
> after those it stops.

No, its emacs as I use it daily, that is, with a lot of timers from Gnus
and rcirc, and process filters from AUCTeX, etc.  With emacs -Q I
haven't been able to reproduce the issue.

> I can only understand a much more frequent redisplay if you have a lot
> of timers, or a high-frequency timer.  When a timer fires, we call
> redisplay, AFAIR.

I have a lot of timers but they aren't too high frequency.  But I think
Stefan's explanation (which is the same as you write below) is correct,
i.e., a redisplay is triggered by new output received from the async
latex compile process.

>> Then I compiled my latex doc to generate some stress.  Every compile
>> takes about a good minute.  That used to work without blinking
>> interruption at least four times, but with the fifth time, out of
>> sudden, it stuck after
>> 
>>   redisplay_internal 0
>
> I'm guessing that your LaTeX compilation is via "M-x compile" or a
> similar async subprocess.

Yes, AUCTeX starts it with `start-process' and puts a process filter on
it.

> If so, whether or not redisplay is called depends on the speed the
> compilation process emits stuff that Emacs reads.  If the subprocess
> outputs a lot of stuff,

Yes, with the document I'm using for testing, the latex process emits
4000 lines of text in about a 40 seconds.

> it will have the same effect as high-speed keyboard input -- in both
> cases Emacs will not enter redisplay until it's idle.

It seems that up to some point, the frequent arrival of input triggers a
lot of redisplays, just as you explain in your other mail:

,----
| The arrival of subprocess output causes the pselect call to return,
| marking the file descriptor for that process ready to be read.  Emacs
| then reads from the descriptor, and returns to the idle loop.  If by
| that time no additional process output arrived, Emacs will enter
| redisplay.
| 
| IOW, arrival of process output is an event that causes the main loop
| to crank one more time, and that includes redisplay.
`----

But under some circumstances which aren't completely clear to me, the
subprocess output paired with timers etc can cause a redisplay pause.
The even default interval of 0.5 of b-c-m seems to play its role
thereby.

>> and would not start anymore until my latex document was compiled and
>> AUCTeX echoed "LaTeX: successfully formatted {293} pages".  That
>> seems to have triggered the resume of redisplay.
>
> Displaying an echo area message triggers redisplay.
>
>> The redisplay pause was at least 20 to 30 seconds.
>
> If there's no redisplay, you won't see the cursor blink.

Of course.

Bye,
Tassilo