From xemacs-m  Fri Dec 20 01:39:10 1996
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 BAA12873 for <xemacs-beta@xemacs.org>; Fri, 20 Dec 1996 01:39:09 -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 XAA25645 for <xemacs-beta@xemacs.org>; Thu, 19 Dec 1996 23:31:52 -0800 (PST)
Received: by sdnp5.ucsd.edu (SMI-8.6/SMI-SVR4)
	id XAA20979; Thu, 19 Dec 1996 23:30:05 -0800
Sender: dmoore@sdnp5.ucsd.edu
To: XEmacs Beta Mailing List <xemacs-beta@xemacs.org>
Subject: Re: Inserting into a buffer.
References: <Pine.SGI.3.95.961219034733.22578D-100000@shellx.best.com>
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
From: David Moore <dmoore@UCSD.EDU>
Date: 19 Dec 1996 23:30:04 -0800
In-Reply-To: Ben Wing's message of Thu, 19 Dec 1996 03:49:07 -0800 (PST)
Message-ID: <rvn2v965c3.fsf@sdnp5.ucsd.edu>
Lines: 278
X-Mailer: Red Gnus v0.76/XEmacs 19.15

Ben Wing <wing@best.com> writes:

> The culprit is surely silly.  Similar problems have happened before.
> 
> Someone please run Quantify or the like (Martin?) on this to find the
> culprit.

	The culprits seem multiple, and at least one is very strange
(munmap).  Profiling with -pg (except in the x and system libraries)
under solaris 2.5 on an unloaded sparcserver 5 with 64M of physical
memory, compiled with gcc -pg -O4.  Placed Hrvoje's benchmark and
wrapper to call it 20 times in a file, bytecompiled and loaded it into
an xemacs -q, and ran it.

	Other benchmarks put a large strain on do_symval_forwarding
and Fset also.  I'm not sure why munmap is so expensive relative to mmap
under solaris, or it may just be that a resizing mmap is showing up as
munmap.  This mmap cost isn't seen in Shane's benchmarks typically.

	Parent-child profile is ellided to show just some of the problem
routines from the flat profile.

Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
  9.85    115.71    31.56  6005492     0.01     0.01  map_extents_bytind
  8.55    143.11    27.40  2000391     0.01     0.04  buffer_insert_string_1
  5.96    162.21    19.10      722    26.45    26.45  _munmap
  5.57    180.05    17.84     9315     1.92     4.29  Fbyte_code
  4.18    193.45    13.40                             w4cp
  2.05    200.01     6.56  2000114     0.00     0.00  Finsert
  1.98    206.35     6.34  8047623     0.00     0.00  do_symval_forwarding
  1.95    212.61     6.26  8015468     0.00     0.00  symbol_value_in_buffer
  1.93    218.79     6.18  2001575     0.00     0.00  set_buffer_point
  1.86    224.76     5.97  6016466     0.00     0.00  extent_list_locate
  1.84    230.64     5.88  2004994     0.00     0.00  arithcompare
  1.83    236.50     5.86  8059188     0.00     0.00  find_symbol_value_1
  1.81    242.30     5.80  4003975     0.00     0.00  soe_move
  1.81    248.10     5.80  2085218     0.00     0.00  store_symval_forwarding
  1.73    253.64     5.54  2000547     0.00     0.00  extent_list_delete_marker
  1.52    258.52     4.88  2000474     0.00     0.00  barf_if_buffer_read_only
  1.38    262.93     4.41  2000474     0.00     0.00  verify_extent_modification
  1.35    267.27     4.34  2000153     0.00     0.00  buffer_insert_lisp_string_1
  1.32    271.51     4.24  2081933     0.00     0.01  Fset
  1.30    275.69     4.18  2057890     0.00     0.00  _memcpy
  1.12    279.29     3.60  8010894     0.00     0.00  buffer_or_string_extent_info_force
  0.95    282.34     3.05  2000153     0.00     0.00  splice_in_string_extents
  0.92    285.28     2.94  2000466     0.00     0.01  signal_before_change
  0.86    288.04     2.76  2082241     0.00     0.00  reject_constant_symbols
  0.86    290.79     2.75  2000391     0.00     0.00  record_insert
  0.80    293.36     2.57  2001395     0.00     0.00  Fgtr
  *** Flat Profile Cut here ***


Ellided all graph profile:

-----------------------------------------------
                                  10             buffer_insert_raw_string_1 <cycle 1> [1342]
                                  17             output_string <cycle 1> [553]
                                 211             buffer_insert_emacs_char_1 <cycle 1> [351]
                             2000153             buffer_insert_lisp_string_1 <cycle 1> [34]
[2]     27.1   27.40   58.89 2000391         buffer_insert_string_1 <cycle 1> [2]
                0.00   19.03     747/747         make_gap [13]
                1.80   10.56 2000391/2000468     signal_after_change [18]
                2.94    9.19 2000391/2000466     signal_before_change [20]
                6.18    0.00 2000389/2001575     set_buffer_point [26]
                2.75    1.91 2000391/2000391     record_insert [32]
                4.06    0.00 2000391/2057890     _memcpy [35]
                0.46    0.00 2000391/4001735     make_buffer [66]
                0.00    0.00       2/749         gap_left [298]
                0.00    0.00       2/3           gap_right [907]
                             2000391             barf_if_buffer_read_only <cycle 1> [31]
                             2000391             process_extents_for_insertion <cycle 1> [52]
                             2000153             splice_in_string_extents <cycle 1> [38]
                                   1             lock_file <cycle 1> [82]
-----------------------------------------------
                                  11             get_text_property_bytind <cycle 1> [1321]
                                  67             add_string_extents <cycle 1> [840]
                                  70             Fextent_at <cycle 1> [348]
                                  75             adjust_extents_for_deletion <cycle 1> [521]
                                  75             process_extents_for_deletion <cycle 1> [355]
                                4176             copy_string_extents <cycle 1> [336]
                             2000153             splice_in_string_extents <cycle 1> [38]
                             2000391             process_extents_for_insertion <cycle 1> [52]
                             2000474             verify_extent_modification <cycle 1> [33]
[8]     16.5   31.56   20.90 6005492         map_extents_bytind <cycle 1> [8]
                5.80    3.79 4001163/4003975     soe_move [22]
                5.54    0.00 2000480/2000547     extent_list_delete_marker [30]
                3.97    0.01 4001163/6016466     extent_list_locate [28]
                1.80    0.00 4001272/8010894     buffer_or_string_extent_info_force [36]
                0.00    0.00      67/2331        extent_attach [175]
                0.00    0.00      26/27          allocate_soe [533]
                0.00    0.00      67/5736        make_opaque_ptr [232]
                0.00    0.00      67/93          allocate_extent [605]
                0.00    0.00     135/44180       .umul [195]
                0.00    0.00      14/14          process_extents_for_deletion_mapper [670]
                0.00    0.00      67/38398       specpdl_depth [329]
                0.00    0.00      68/68          extent_in_region_p [1195]
                0.00    0.00      67/6339        record_unwind_protect [994]
                0.00    0.00      15/15          verify_extent_mapper [1312]
                0.00    0.00      14/14          add_string_extents_mapper [1316]
                0.00    0.00       1/1           process_extents_for_insertion_mapper [1607]
                                  67             unbind_to <cycle 1> [99]
-----------------------------------------------
                                 231             primitive_funcall <cycle 1> [56]
                                9084             funcall_lambda <cycle 1> [95]
[9]     12.5   17.84   22.09    9315         Fbyte_code <cycle 1> [9]
                4.10    9.35 2010780/2081933     Fset [16]
                2.57    5.87 2001393/2001395     Fgtr [23]
                0.01    0.12   11965/35528       specbind [93]
                0.02    0.00    9315/29821       _memset [157]
                0.00    0.01    3586/4183        Fsymbol_value [373]
                0.00    0.01    2549/2550        Flss [383]
                0.00    0.01     127/368         Fset_buffer [244]
                0.01    0.00   25363/38398       specpdl_depth [329]
                0.00    0.00     137/159         save_excursion_save [405]
                0.00    0.00     768/768         Fgeq [432]
                0.00    0.00      98/98          Fmember [434]
                0.00    0.00    1292/20557       Flength [220]
                0.00    0.00      19/303         check_what_happened [221]
                0.00    0.00    1422/24727       Fcons [210]
                0.00    0.00     541/10530       Fget [213]
                0.00    0.00    1072/1072        Fplus [479]
                0.00    0.00     281/281         Fleq [505]
                0.00    0.00      46/589         Fnconc [363]
                0.00    0.00     387/7503        Fequal [283]
                0.00    0.00     131/142         Fgoto_char [516]
                0.00    0.00     489/489         Fquo [538]
                0.00    0.00       1/25          Fcurrent_window_configuration [311]
                0.00    0.00     311/311         Fminus [568]
                0.00    0.00     468/2053465     make_int [54]
                0.00    0.00     240/240         Ftimes [596]
                0.00    0.00      12/12          save_restriction_save [601]
                0.00    0.00      57/73          Fforward_line [583]
                0.00    0.00      30/30          Fskip_chars_forward [666]
                0.00    0.00      14/15          Finteractive_p [689]
                0.00    0.00      75/76          Fmax [706]
                0.00    0.00      23/23          Fforward_char [718]
                0.00    0.00     118/911         Flist [535]
                0.00    0.00      45/45          Fchar_after [748]
                0.00    0.00       6/8           Fend_of_line [778]
                0.00    0.00      27/8584        Fstring_equal [388]
                0.00    0.00      26/25378       Fnreverse [331]
                0.00    0.00      17/17          Fmatch_end [876]
                0.00    0.00      12/12          Fmatch_beginning [897]
                0.00    0.00       2/2           Fforward_word [912]
                0.00    0.00       1/308         Ffset [500]
                0.00    0.00       2/2           Fmin [953]
                0.00    0.00       1/5787        Fset_marker [319]
                0.00    0.00    2261/2262        Fmemq [1018]
                0.00    0.00    2095/2095        Faref [1020]
                0.00    0.00     662/1089        Fcurrent_buffer [1037]
                0.00    0.00     539/6339        record_unwind_protect [994]
                0.00    0.00      63/85          Felt [1184]
                0.00    0.00      61/169         Fassq [1146]
                0.00    0.00      46/4631        Fsetcdr [1001]
                0.00    0.00      38/38          current_column [1235]
                0.00    0.00      30/57          Fsetcar [1211]
                0.00    0.00      24/24          Fbolp [1266]
                0.00    0.00      23/23          Fsymbol_function [1269]
                0.00    0.00      18/18          Fbobp [1292]
                0.00    0.00      12/12          Feobp [1325]
                0.00    0.00      11/82062       make_char [981]
                0.00    0.00      11/11          Fnarrow_to_region [1336]
                0.00    0.00       8/8           Fnthcdr [1361]
                0.00    0.00       5/5           Fpreceding_char [1395]
                0.00    0.00       2/2           Faset [1468]
                0.00    0.00       1/1           Fwiden [1553]
                             2000114             Finsert <cycle 1> [24]
                               21844             Ffuncall <cycle 1> [253]
                                6802             unbind_to <cycle 1> [99]
                                1303             Fconcat <cycle 1> [1029]
                                 254             Fdowncase <cycle 1> [1119]
                                  72             Fcondition_case_3 <cycle 1> [356]
                                  70             internal_catch <cycle 1> [316]
                                  29             Fsubstring <cycle 1> [564]
                                  10             Fdelete_region <cycle 1> [1340]
                                   8             Findent_to <cycle 1> [709]
                                   7             Fbuffer_substring <cycle 1> [1259]
                                   1             Fprogn <cycle 1> [1084]
-----------------------------------------------
                0.00   30.96       3/3           EmacsFrameResize [7]
[10]     9.7    0.00   30.96       3         pixel_to_char_size [10]
               14.82   16.14       3/21          frame_conversion_internal <cycle 1> [729]
-----------------------------------------------
                0.58    0.00      22/722         r_alloc_free [80]
               18.52    0.00     700/722         r_re_alloc [14]
[12]     6.0   19.10    0.00     722         _munmap [12]
-----------------------------------------------
                0.00   19.03     747/747         buffer_insert_string_1 <cycle 1> [2]
[13]     6.0    0.00   19.03     747         make_gap [13]
                0.01   19.01     747/747         r_re_alloc [14]
                0.01    0.00     747/749         gap_left [298]
-----------------------------------------------
                0.01   19.01     747/747         make_gap [13]
[14]     6.0    0.01   19.01     747         r_re_alloc [14]
               18.52    0.00     700/722         _munmap [12]
                0.48    0.00     700/725         _mmap [84]
                0.01    0.00     747/769         find_mmap_handle [315]
                0.00    0.00    1400/17991       .urem [305]
                0.00    0.00     747/44180       .umul [195]
                0.00    0.00     700/15540       _memmove [477]
                0.00    0.00       2/1107        realloc [384]
                0.00    0.00    2847/7282        .udiv [991]
-----------------------------------------------
                0.00    0.00       5/8015468     Fsymbol_value_in_buffer [858]
                0.00    0.00       7/8015468     x_output_blank <cycle 1> [720]
                0.00    0.00      23/8015468     set_frame_menubar <cycle 1> [642]
                0.00    0.00      27/8015468     barf_if_buffer_read_only <cycle 1> [31]
                0.00    0.00      45/8015468     update_toolbar_button [638]
                0.00    0.00     219/8015468     x_output_eol_cursor <cycle 1> [436]
                0.00    0.00     314/8015468     update_frame_title <cycle 1> [460]
                0.00    0.00     334/8015468     run_hook_with_args_in_buffer <cycle 1> [503]
                0.00    0.00     383/8015468     x_output_string <cycle 1> [408]
                0.00    0.00    1107/8015468     get_relevant_minor_maps [296]
                0.00    0.00    2476/8015468     create_text_block <cycle 1> [111]
                0.01    0.01    8625/8015468     generate_fstring_runes <cycle 1> [119]
                3.12    6.07 4000932/8015468     signal_after_change [18]
                3.12    6.07 4000971/8015468     signal_before_change [20]
[15]     5.8    6.26   12.15 8015468         symbol_value_in_buffer [15]
                5.83    6.32 8015468/8059188     find_symbol_value_1 [19]
-----------------------------------------------
                0.00    0.00       2/2081933     Fsetq <cycle 1> [843]
                0.00    0.00       4/2081933     Fmake_local_variable [551]
                0.00    0.00       7/2081933     primitive_funcall <cycle 1> [56]
                0.00    0.00      35/2081933     specbind_unwind_local [510]
                0.00    0.00      88/2081933     Fset_default [527]
                0.07    0.17   35489/2081933     unbind_to <cycle 1> [99]
                0.07    0.17   35528/2081933     specbind [93]
                4.10    9.35 2010780/2081933     Fbyte_code <cycle 1> [9]
[16]     4.4    4.24    9.68 2081933         Fset [16]
                5.79    0.31 2081933/2085218     store_symval_forwarding [27]
                2.76    0.82 2081933/2082241     reject_constant_symbols [37]
                0.00    0.00      50/20251       assq_no_quit [211]
                0.00    0.00      22/24727       Fcons [210]
                0.00    0.00      22/8047623     do_symval_forwarding [25]
-----------------------------------------------
                                                 <spontaneous>
[17]     4.2   13.40    0.00                 w4cp [17]
-----------------------------------------------
                0.00    0.00       2/2000468     multiple_change_finish_up [854]
                0.00    0.00      75/2000468     buffer_delete_range <cycle 1> [492]
                1.80   10.56 2000391/2000468     buffer_insert_string_1 <cycle 1> [2]
[18]     3.9    1.80   10.56 2000468         signal_after_change [18]
                3.12    6.07 4000932/8015468     symbol_value_in_buffer [15]
                1.37    0.00 2000468/2000468     font_lock_maybe_update_syntactic_caches [51]
-----------------------------------------------
                0.03    0.03   43720/8059188     find_symbol_value [145]
                5.83    6.32 8015468/8059188     symbol_value_in_buffer [15]
[19]     3.8    5.86    6.36 8059188         find_symbol_value_1 [19]
                6.34    0.00 8047559/8047623     do_symval_forwarding [25]
                0.01    0.00    3221/2085218     store_symval_forwarding [27]
                0.01    0.00    5159/20251       assq_no_quit [211]
                0.00    0.00    1825/94961       Fcdr [980]
                0.00    0.00    1699/4631        Fsetcdr [1001]
-----------------------------------------------
                0.00    0.00      75/2000466     buffer_delete_range <cycle 1> [492]
                2.94    9.19 2000391/2000466     buffer_insert_string_1 <cycle 1> [2]
[20]     3.8    2.94    9.19 2000466         signal_before_change [20]
                3.12    6.07 4000971/8015468     symbol_value_in_buffer [15]
-----------------------------------------------
                0.00    0.00       1/4003975     extent_find_beginning_of_run [924]
                0.00    0.00    2811/4003975     extent_find_end_of_run [204]
                5.80    3.79 4001163/4003975     map_extents_bytind <cycle 1> [8]
[22]     3.0    5.80    3.79 4003975         soe_move [22]
                1.99    0.00 2003013/6016466     extent_list_locate [28]
                1.80    0.00 4003975/8010894     buffer_or_string_extent_info_force [36]
                0.00    0.00      46/4854        gap_array_insert_els [205]
                0.00    0.00     115/44180       .umul [195]
                0.00    0.00      28/177         extent_list_delete [562]
-----------------------------------------------
                0.00    0.00       2/2001395     primitive_funcall <cycle 1> [56]
                2.57    5.87 2001393/2001395     Fbyte_code <cycle 1> [9]
[23]     2.6    2.57    5.87 2001395         Fgtr [23]
                5.87    0.00 2001395/2004994     arithcompare [29]
-----------------------------------------------

