From xemacs-m  Sat Feb  8 16:35:35 1997
Received: from altair.xemacs.org (steve@xemacs.miranova.com [206.190.83.19])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id QAA09428
	for <xemacs-beta@xemacs.org>; Sat, 8 Feb 1997 16:35:33 -0600 (CST)
Received: (from steve@localhost)
	by altair.xemacs.org (8.8.5/8.8.5) id OAA03196;
	Sat, 8 Feb 1997 14:46:33 -0800
To: xemacs-beta@xemacs.org
Subject: Re: wot i need
References: <199702082135.AA176887731@martigny.ai.mit.edu>
X-Url: http://www.miranova.com/%7Esteve/
Mail-Copies-To: never
X-Face: #!T9!#9s-3o8)*uHlX{Ug[xW7E7Wr!*L46-OxqMu\xz23v|R9q}lH?cRS{rCNe^'[`^sr5"
 f8*@r4ipO6Jl!:Ccq<xoV[Qz2u8<8-+Vwf2gzJ44lf_/y9OaQ`@#Q65{U4/TC)i2`~/M&QI$X>p:9I
 OSS'2{-)-4wBnVeg0S\O4Al@)uC[pD|+
X-Attribution: sb
From: Steven L Baur <steve@miranova.com>
In-Reply-To: Bill Dubuque's message of Sat, 8 Feb 1997 16:35:30 -0500
Mime-Version: 1.0 (generated by tm-edit 7.101)
Content-Type: text/plain; charset=US-ASCII
Date: 08 Feb 1997 14:46:28 -0800
Message-ID: <m2bu9uuda3.fsf@altair.xemacs.org>
Lines: 94
X-Mailer: Gnus v5.4.11/XEmacs 20.0

Bill Dubuque writes:

> : From: Kyle Jones <kyle_jones@wonderworks.com>
> : 
> : This loop, uncompiled, runs about twice as fast under FSF Emacs
> : as it does under XEmacs 20.0.  Why?
> : 
> : (let ((i 0)) (while (< i 300000) (setq i (1+ i))))
> : 
> : If we can find out and solve it, I have a feeling we could go a
> : long way toward speeding up XEmacs.  Look at that loop.  No
> : consing, nothing but subrs called, no magic symbols, no buffer local
> : variables.  What is it that XEmacs is doing twice as much of to
> : get the same result?

> Perhaps QUIT is slower in XEmacs vs. FSF. 

It has to be.

QUIT in Emacs 19.34 is:
#define QUIT \
  if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
    { Vquit_flag = Qnil; Fsignal (Qquit, Qnil); }


QUIT in XEmacs 19.15 is:
#define QUIT do { if (INTERNAL_QUITP) signal_quit (); } while (0)

#define INTERNAL_QUITP                                                  \
  ((something_happened ? check_what_happened () : 0),                   \
   (!NILP (Vquit_flag) &&                                               \
    (NILP (Vinhibit_quit) || EQ (Vquit_flag, Qcritical))))

check_what_happened() is in signal.c and looks various signal-time
flags:


int
check_what_happened (void)		/* called from QUIT when
					   something_happened gets set */
{
  something_happened = 0;
  if (alarm_happened)
    {
      alarm_happened = 0;
      handle_alarm_going_off ();
    }
  return check_quit ();
}

I notice doing an strace, that XEmacs is dropping out of select
periodically and Emacs does not. :-(  Why is that?

> QUIT is executed each time eval is calle, hence during the eval
> of <, setq, 1+ in each loop iteration.  Additionally, XEmacs 
> will call QUIT one more time per loop because, unlike FSF,
> its setq calls length, which does a QUIT. I recall that Ben
> did a lot of work on QUIT, so it might be much hairer in XEmacs
> vs. FSF.

> Another possibility is that FSF doesn't have floating-point code
> compiled in, so arith ops are slightly faster. But this shouldn't
> make that much difference.

emacs-version
"19.34.1"
(+ 1.2 5.5)
6.7000000000000002
;;;;
emacs-version
"20.0 XEmacs Lucid"
(+ 1.2 5.5)
6.7

> Why don't you try the same test with less trival while bodies.

I have.  There is a slightly larger example in bench.el:
(defun bench-mark-loop ()
  "How long does it take to run through a loop."
  (let ((count bench-mark-loop-count))
    (let ((i 0) (gcount 0))
      (while (< i count)
	(increment)
	(setq i (1+ i)))
      (message "gcount = %d" gcount))))

(defun increment ()
  "Increment a variable for bench-mark-loop."
  (setq gcount (1+ gcount)))

I timed XEmacs *faster* than Emacs running this code.
-- 
steve@miranova.com baur
Unsolicited commercial e-mail will be billed at $250/message.

