From xemacs-m  Mon Sep 22 07:15:55 1997
Received: from jagor.srce.hr (hniksic@jagor.srce.hr [161.53.2.130])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id HAA02294
	for <xemacs-beta@xemacs.org>; Mon, 22 Sep 1997 07:15:28 -0500 (CDT)
Received: (from hniksic@localhost)
	by jagor.srce.hr (8.8.7/8.8.6) id OAA21854;
	Mon, 22 Sep 1997 14:15:18 +0200 (MET DST)
To: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: Re: Emacs/XEmacs benchmarking (wot Kyle needs)
References: <m27mcame88.fsf@altair.xemacs.org>
X-Attribution: Hrvoje
X-Face: Mie8:rOV<\c/~z{s.X4A{!?vY7{drJ([U]0O=W/<W*SMo/Mv:58:*_y~ki>xDi&N7XG
        KV^$k0m3Oe/)'e%3=$PCR&3ITUXH,cK>]bci&<qQ>Ff%x_>1`T(+M2Gg/fgndU%k*ft
        [(7._6e0n-V%|%'[c|q:;}td$#INd+;?!-V=c8Pqf}3J
From: Hrvoje Niksic <hniksic@srce.hr>
Date: 22 Sep 1997 14:15:17 +0200
In-Reply-To: SL Baur's message of "21 Sep 1997 16:36:23 -0700"
Message-ID: <kig7mc91r56.fsf@jagor.srce.hr>
Lines: 129
X-Mailer: Quassia Gnus v0.8/XEmacs 20.3(beta23) - "Sarajevo"

SL Baur <steve@xemacs.org> writes:

> 3. Except for redisplay, which Joel Peterson is presently working on,
>    the two worst benchmarks now are the byte compiler and sort-words.

I would add insert-into-empty-buffer, too (1.1 -> 2.9).

> 2. Note the dramatic difference in the small-list benchmark between
>    19.34 and 20.1.  Is there an optimization there we can use?

I don't see any.  The `make-list' functions are pretty much the same
in 19.34, 20.1 and XEmacs.  Maybe there is some speedup in Fcons?
They look pretty similar too.  Hmm... on the second glance, it seems
that Emacs 20 seems to take advantage of modern malloc's.

Here are the relevant parts of the patch between 19.34 and 20.1:

    @@ -37,6 +37,10 @@

     extern char *sbrk ();

    +#ifdef DOUG_LEA_MALLOC
    +#include <malloc.h>
    +#define __malloc_size_t int
    +#else
     /* The following come from gmalloc.c.  */

     #if defined (__STDC__) && __STDC__
    @@ -47,6 +51,9 @@
     #endif
     extern __malloc_size_t _bytes_used;
     extern int __malloc_extra_blocks;
    +#endif /* !defined(DOUG_LEA_MALLOC) */
    +
    +extern Lisp_Object Vhistory_length;

     #define max(A,B) ((A) > (B) ? (A) : (B))
     #define min(A,B) ((A) < (B) ? (A) : (B))
    @@ -206,12 +219,18 @@
       internal_with_output_to_temp_buffer (" *Danger*", malloc_warning_1, val);
     }

    +#ifdef DOUG_LEA_MALLOC
    +#  define BYTES_USED (mallinfo ().arena)
    +#else
    +#  define BYTES_USED _bytes_used
    +#endif
    +
     /* Called if malloc returns zero */

     memory_full ()
     {
     #ifndef SYSTEM_MALLOC
    -  bytes_used_when_full = _bytes_used;
    +  bytes_used_when_full = BYTES_USED;
     #endif

       /* The first time we get here, free the spare memory.  */
    @@ -361,7 +380,11 @@

       BLOCK_INPUT;
       __malloc_hook = old_malloc_hook;
    -  __malloc_extra_blocks = malloc_hysteresis;
    +#ifdef DOUG_LEA_MALLOC
    +    mallopt (M_TOP_PAD, malloc_hysteresis * 4096);
    +#else
    +    __malloc_extra_blocks = malloc_hysteresis;
    +#endif
       value = (void *) malloc (size);
       __malloc_hook = emacs_blocked_malloc;
       UNBLOCK_INPUT;
    @@ -729,8 +756,16 @@
       struct Lisp_Vector *p;

       allocating_for_lisp = 1;
    +#ifdef DOUG_LEA_MALLOC
    +  /* Prevent mmap'ing the chunk (which is potentially very large). */
    +  mallopt (M_MMAP_MAX, 0);
    +#endif
       p = (struct Lisp_Vector *)xmalloc (sizeof (struct Lisp_Vector)
					 + (len - 1) * sizeof (Lisp_Object));
    +#ifdef DOUG_LEA_MALLOC
    +  /* Back to a reasonable maximum of mmap'ed areas. */
    +  mallopt (M_MMAP_MAX, 64);
    +#endif
       allocating_for_lisp = 0;
       VALIDATE_LISP_STORAGE (p, 0);
       consing_since_gc += (sizeof (struct Lisp_Vector)
    @@ -1158,7 +1227,15 @@
	 {
	   register struct string_block *new;
	   allocating_for_lisp = 1;
    +#ifdef DOUG_LEA_MALLOC
    +      /* Prevent mmap'ing the chunk (which is potentially very large).  */
    +      mallopt (M_MMAP_MAX, 0);
    +#endif
	   new = (struct string_block *) xmalloc (sizeof (struct string_block_head) + fullsize);
    +#ifdef DOUG_LEA_MALLOC
    +      /* Back to a reasonable maximum of mmap'ed areas. */
    +      mallopt (M_MMAP_MAX, 64);
    +#endif
	   allocating_for_lisp = 0;
	   VALIDATE_LISP_STORAGE (new, 0);
	   consing_since_gc += sizeof (struct string_block_head) + fullsize;
    @@ -2549,6 +2628,11 @@
     #endif
       all_vectors = 0;
       ignore_warnings = 1;
    +#ifdef DOUG_LEA_MALLOC
    +  mallopt (M_TRIM_THRESHOLD, 128*1024); /* trim threshold */
    +  mallopt (M_MMAP_THRESHOLD, 64*1024); /* mmap threshold */
    +  mallopt (M_MMAP_MAX, 64); /* max. number of mmap'ed areas */
    +#endif
       init_strings ();
       init_cons ();
       init_symbol ();


Should we add the same stuff to XEmacs?  What *is* DOUG_LEA_MALLOC
anyway?  We need a malloc guru here.

Interestingly enough, our garbage-collector (the work of jwz and mly)
seems to be much faster.

-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
`VI' - An editor used by those heretics that don't subscribe to
       the Emacs religion.

