Subject: Re: bug#12463: 24.2; pos-visible-in-window-p gets slower over time

From: Eli Zaretskii <[email-masked]>
Date: Tue, 18 Sep 2012 10:46:35 +0300

> From: [email-masked] (Jörg Walter)
> Date: Tue, 18 Sep 2012 01:51:31 +0200
> 
> Emacs gets arbitrarily slow over time. I was able to narrow down the
> problem to `pos-visible-in-window-p', which is, unfortunately, called as
> part of lots of common commands. That function call is getting slower
> each time it is called, if two conditions are met.
> 
> The first condition I was able to pin is the value of
> `header-line-format'. The bug only occurs when it includes an image (as
> is common when using tabbar.el).
> 
> It also depends on buffer contents, although I was not able to determine
> a minimal condition. It happens with the fancy splash screen, but not
> with the scratch buffer. I've tried inserting an image and using face
> `variable-pitch', but those two aren't enough to trigger the bug.
> 
> This code sample demonstrates the bug. Run it in an "emacs -Q" instance
> via `eval-buffer' and be amazed at the unbounded (linear) growth of
> execution time for each iteration:
> 
> (defun bug ()
>   "trigger bug related to pos-visible-in-window-p"
>   (interactive)
>   (benchmark 1000 '(pos-visible-in-window-p t)))
> 
> (fancy-startup-screen)
> (setq header-line-format '((#("x" 0 1 (display (image :type pbm :data "P2 1 1 255\n"))))))
> (goto-char (point-min))
> (while t (bug))

I cannot reproduce the slow-down on my machine (Windows XP).  What I
see is constant time, give or take 2%, with no growth trend
whatsoever.

I don't have access to GUI sessions on any configuration close to this:

> In GNU Emacs 24.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
>  of 2012-09-17 on queen
> Windowing system distributor `The X.Org Foundation', version 11.0.11103000
> Configured using:
>  `configure '--with-gif=no''

Can anyone else reproduce this?

Jörg, does this happen with earlier versions of Emacs, like 24.1 or
23.3?