Subject: Compilation from within emacs becomes slower and slower until Emacs is restarted

From: Lars Hamren <[email-masked]>
Date: Sun, 19 Sep 2010 02:38:00 +0200

The first few compiles, using "compile" to invode  GNU make,
from within Emacs, run at "command-line speed" but then the overall
time increases. The first 10 compiles are OK, but after about 20 compiles,
a compilation that  "time make -k" reports as taking

	real	0m0.127s
	user	0m0.100s
	sys	0m0.016s

takes more than five seconds. Then I give up and restart Emacs, and
everything is fine for another 10 compiles. And so on.

Here is some output from "strace emacs"

	socket(PF_FILE, SOCK_STREAM, 0)         = 3 <0.000016>
	connect(3, {sa_family=AF_FILE, path=@"/tmp/.X11-unix/X0"}, 20) = 0 <0.000015>

Here I attach strace to a running emacs just before i start compilation
and detach as soon as the compilation is done. The first few selects are
probably from before the time I press enter to execute the compile command.

	select(4, [3], NULL, NULL, {0, 297904}) = 0 (Timeout) <0.298232>
	select(4, [3], NULL, NULL, {0, 498307}) = 0 (Timeout) <0.498832>
	select(4, [3], NULL, NULL, {0, 498294}) = 0 (Timeout) <0.498820>
	select(4, [3], NULL, NULL, {0, 498292}) = 0 (Timeout) <0.498818>
	select(4, [3], NULL, NULL, {0, 498250}) = 0 (Timeout) <0.498776>
	select(4, [3], NULL, NULL, {0, 498299}) = 1 (in [3], left {0, 444141}) <0.054181>
	select(4, [3], NULL, NULL, {0, 441524}) = 1 (in [3], left {0, 320780}) <0.120760>
	select(4, [3], NULL, NULL, {0, 312270}) = 1 (in [3], left {0, 311270}) <0.001084>
	select(4, [3], NULL, NULL, {0, 282200}) = 0 (Timeout) <0.282507>
	select(4, [3], NULL, NULL, {0, 498525}) = 1 (in [3], left {0, 21105}) <0.477438>
	select(4, [3], NULL, NULL, {0, 499408}) = 0 (Timeout) <0.499936>
	select(4, [3], NULL, NULL, {0, 498927}) = 1 (in [3], left {0, 272045}) <0.226897>
	select(5, [3 4], NULL, NULL, {0, 499323}) = 1 (in [4], left {0, 479747}) <0.019591>
	select(5, [3], NULL, NULL, {0, 20000})  = 0 (Timeout) <0.020070>
	select(5, [3 4], NULL, NULL, {0, 442695}) = 1 (in [4], left {0, 442690}) <0.000016>
	select(5, [3], NULL, NULL, {0, 0})      = 0 (Timeout) <0.000008>
	select(4, [3], NULL, NULL, {0, 494042}) = 0 (Timeout) <0.494564>        <---- Much waiting here
	select(4, [3], NULL, NULL, {0, 498322}) = 0 (Timeout) <0.498847>
	select(4, [3], NULL, NULL, {0, 498336}) = 0 (Timeout) <0.498862>
	select(4, [3], NULL, NULL, {0, 498261}) = 0 (Timeout) <0.498784>
	select(4, [3], NULL, NULL, {0, 498320}) = 0 (Timeout) <0.498847>
	select(4, [3], NULL, NULL, {0, 498260}) = 0 (Timeout) <0.498786>
	select(4, [3], NULL, NULL, {0, 498325}) = 0 (Timeout) <0.498853>
	select(4, [3], NULL, NULL, {0, 498215}) = 0 (Timeout) <0.498737>
	select(4, [3], NULL, NULL, {0, 498057}) = 1 (in [3], left {0, 445670}) <0.052400>
	select(4, [3], NULL, NULL, {0, 445001}) = 1 (in [3], left {0, 349721}) <0.095295>
	select(4, [3], NULL, NULL, {0, 347501}) = 1 (in [3], left {0, 345858}) <0.001656>
	select(4, [3], NULL, NULL, {0, 345151}) = 1 (in [3], left {0, 342229}) <0.002978>
	select(4, [3], NULL, NULL, {0, 340611}) = 1 (in [3], left {0, 268540}) <0.072088>
	select(4, [3], NULL, NULL, {0, 259972}) = 1 (in [3], left {0, 259075}) <0.000975>
	select(4, [3], NULL, NULL, {0, 228314}) = 0 (Timeout) <0.228570>
	select(4, [3], NULL, NULL, {0, 498550} <unfinished ...>

Environment

	Ubuntu 10.04 (and earlier, on 9.04)
	Linux: 2.6.32-24-generic
	Emacs 23.1.2 (my own emacs build)
         Emacs 22.2.1 (Ubuntu package)

Googling, I can find nothing about this problem.

/Lars
-------------------------------------------------------------------
Lars Hamrén              Tel...: +46(46)189090
Svensk Datorutveckling   e-post: [email-masked]
Vadmöllan 211            WWW...: www.sdu.se
S-225 94 Lund
Sweden