From xemacs-m  Fri Jan 10 01:41:45 1997
Received: from UCSD.EDU (mailbox2.ucsd.edu [132.239.1.54])
          by xemacs.cs.uiuc.edu (8.8.4/8.8.4) with ESMTP
	  id BAA22697 for <xemacs-beta@xemacs.org>; Fri, 10 Jan 1997 01:41:44 -0600 (CST)
Received: from sdnp5.ucsd.edu (sdnp5.ucsd.edu [132.239.79.10]) by UCSD.EDU (8.8.3/8.6.9) with SMTP id XAA18937 for <xemacs-beta@xemacs.org>; Thu, 9 Jan 1997 23:41:43 -0800 (PST)
Received: by sdnp5.ucsd.edu (SMI-8.6/SMI-SVR4)
	id XAA01573; Thu, 9 Jan 1997 23:39:31 -0800
Sender: dmoore@sdnp5.ucsd.edu
To: xemacs-beta@xemacs.org
Subject: Re: Inserting into a buffer.
References: <Pine.SGI.3.95.961219034733.22578D-100000@shellx.best.com> <rvn2v965c3.fsf@sdnp5.ucsd.edu> <m24thhawcp.fsf@altair.xemacs.org>
X-Face: "oX;zS#-JU$-,WKSzG.1gGE]x^cIg!hW.dq>.f6pzS^A+(k!T|M:}5{_%>Io<>L&{hO7W4cicOQ|>/lZ1G(m%7iaCf,6Qgk0%%Bz7b2-W3jd0m_UG\Y;?]}4s0O-U)uox>P3JN)9cm]O\@,vy2e{`3pb!"pqmRy3peB90*2L
Mail-Copies-To: never
From: David Moore <dmoore@UCSD.EDU>
Date: 09 Jan 1997 23:39:30 -0800
In-Reply-To: Steven L Baur's message of 20 Dec 1996 10:45:10 -0800
Message-ID: <rvvi96m11p.fsf@sdnp5.ucsd.edu>
Lines: 94
X-Mailer: Red Gnus v0.80/XEmacs 19.15

Steven L Baur <steve@miranova.com> writes:

> David> The culprits seem multiple, and at least one is very strange
> David> (munmap).
>
> That must be coming from the relocating allocator.  Try running the
> same test with it disabled from configure.

	Results on Hrvoje's benchmark are improved under solaris if the
relocating allocator is turned off.  (180sec->150sec with -O4 on 19.15b7
for sparcserver5 with 64M).  I may look into the code, because I don't
see why mmap should be costing that much more.

> David> Flat profile:
> 
> David> Each sample counts as 0.01 seconds.
> David>   %   cumulative   self              self     total           
> David>  time   seconds   seconds    calls  ms/call  ms/call  name    
> David>   9.85    115.71    31.56  6005492     0.01     0.01  map_extents_bytind
> David>   8.55    143.11    27.40  2000391     0.01     0.04  buffer_insert_string_1


> I thought extents were supposed to be fast?

	The patch below speeds up inserts and other operaations on
buffers with no extents in them.  On Hrvoje's benchmark: 180sec->120sec.
Combined with disabling the mmap memory cut the time in half.  The patch
quick exits routines which will do a bunch of costly function calls
before failing all of their various checks and returning default values.

	map_extents_bytind is slower than it should be, but I'm
concerned about really playing with it.  Certainly I think the readonly
checks done for string inserting might be well served if
map_extents_bytind had a special case for 0 length extents, such as
those generated by verify_extent_modification when called by
barf_if_buffer_read_only working on the behalf of
buffer_insert_string_1.  Since the extent is 0 length, and
verify_extent_modification doesn't do any insertions or modifications as
it proceeds.  And you should only need to scan the SOE and not go on to
also do the range scan (which it seems to, although I need to stare at
the code another 20 times or more. :)


diff --unified extents.c.orig extents.c
--- extents.c.orig	Thu Jan  9 23:37:29 1997
+++ extents.c	Thu Jan  9 23:37:34 1997
@@ -1968,8 +1968,10 @@
       assert (!extent_detached_p (after));
     }
 
-  if (!buffer_or_string_extent_list (obj))
+  el = buffer_or_string_extent_list (obj);
+  if (!el || !extent_list_num_els(el))
     return;
+  el = 0;
 
   st = buffer_or_string_bytind_to_memind (obj, from);
   en = buffer_or_string_bytind_to_memind (obj, to);
@@ -2315,8 +2317,9 @@
 #endif
   el = buffer_or_string_extent_list (obj);
 
-  if (!el)
+  if (!el || !extent_list_num_els(el))
     return;
+
   /* IMPORTANT! Compute the starting positions of the extents to
      modify BEFORE doing any modification!  Otherwise the starting
      position for the second time through the loop might get
@@ -2516,7 +2519,7 @@
     buffer_or_string_absolute_end_byte (obj) :
       buffer_or_string_accessible_end_byte (obj);
 
-  if (!bel)
+  if (!bel || !extent_list_num_els(bel))
     return limit;
 
   sel = buffer_or_string_stack_of_extents_force (obj)->extents;
@@ -2556,7 +2559,7 @@
     buffer_or_string_absolute_begin_byte (obj) :
       buffer_or_string_accessible_begin_byte (obj);
 
-  if (!bel)
+  if (!bel || !extent_list_num_els(bel))
     return limit;
 
   sel = buffer_or_string_stack_of_extents_force (obj)->extents;


-- 
David Moore <dmoore@ucsd.edu>       | Computer Systems Lab      __o
UCSD Dept. Computer Science - 0114  | Work: (619) 534-8604    _ \<,_
La Jolla, CA 92093-0114             | Fax:  (619) 534-1445   (_)/ (_)
<URL:http://oj.egbt.org/dmoore/>    |

