From xemacs-m  Sun Jan 12 13:16:06 1997
Received: from UCSD.EDU (mailbox1.ucsd.edu [132.239.1.53])
          by xemacs.org (8.8.4/8.8.4) with ESMTP
	  id NAA00986 for <xemacs-beta@xemacs.org>; Sun, 12 Jan 1997 13:16:05 -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 LAA11916 for <xemacs-beta@xemacs.org>; Sun, 12 Jan 1997 11:16:06 -0800 (PST)
Received: by sdnp5.ucsd.edu (SMI-8.6/SMI-SVR4)
	id LAA07767; Sun, 12 Jan 1997 11:13:51 -0800
Sender: dmoore@sdnp5.ucsd.edu
To: XEmacs Beta Mailing List <xemacs-beta@xemacs.org>
Subject: hanoi and other display slowness
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: 12 Jan 1997 11:13:50 -0800
Message-ID: <rvhgkmhfkh.fsf@sdnp5.ucsd.edu>
Lines: 80
X-Mailer: Red Gnus v0.80/XEmacs 19.15


	Hanoi seems to bring out the worst in the redisplay code, since
the line before and after each movement is of the same length and only a
couple of characters on the line of changed.  Because of this, the
display code works very dilligently trying to determine what subsets of
the line it needs to redraw, but these checks are extremely expensive.

	For example 'hanoi 3' calls compare_rune approx 268000 times
with only about 200 of those times it returning the runes as being
different.  And compare_rune is only fast path optimized for detecting
different runes.

	I haven't looked in the display code before... so is it possible
to make runes be a sharable item, such that every instance of the same
rune in a display shares the same structure?  Then the compare_runes
check could be short circuited with a simple == pointer check.
Currently the hanoi testing never calls compare_rune with two == values.
And maybe add_emchar_rune is just being called too much as well.


	Maybe this can help someone who is familiar with the code?


Some profling information from 20 runs of hanoi 4:

Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 15.85     64.67    64.67                             internal_mcount
 13.47    119.62    54.95 23409292     0.00     0.00  compare_runes
 12.34    169.97    50.35 24890189     0.00     0.00  add_emchar_rune
 11.40    216.46    46.49  1399220     0.03     0.03  _memcpy
 11.05    261.53    45.07   300530     0.15     0.19  create_text_block


Elided all graph profile info:

                              300534             output_display_line <cycle 1> [17]
[7]     14.8    5.22   54.95  300534         compare_display_blocks <cycle 1> [7]
               54.95    0.00 23409292/23409292     compare_runes [9]
                               10477             x_output_display_block <cycle 1> [76]
-----------------------------------------------
                              300530             generate_display_line <cycle 1> [65]
[8]     14.4   45.07   13.48  300530         create_text_block <cycle 1> [8]
                0.47    4.90  300530/300530      extent_fragment_new [39]
                0.12    4.04  300530/300530      extent_fragment_delete [42]
                0.49    0.62  300530/848513      symbol_value_in_buffer [53]
                1.07    0.00  300530/362695      window_truncation_on [75]
                0.84    0.00  316060/316060      get_display_table [88]
                0.54    0.00  300530/347810      get_display_block_from_line [108]
                0.25    0.00  300530/1661231     _memset [74]
                0.12    0.00  308366/339651      device_selected_frame [204]
                0.02    0.00  300530/300530      x_eol_cursor_width [382]
                0.01    0.00   15599/31259       echo_area_active [364]
                0.00    0.00       1/15517       add_blank_rune [238]
                0.00    0.00       2/104138      .div [202]
                0.00    0.00       2/397668      .umul [194]
                             23453685             add_emchar_rune <cycle 1> [10]
                              316060             extent_fragment_update <cycle 1> [44]
                                  96             default_face_font_info <cycle 1> [145]
                                   1             add_glyph_rune <cycle 1> [819]
-----------------------------------------------
               54.95    0.00 23409292/23409292     compare_display_blocks <cycle 1> [7]
[9]     13.6   54.95    0.00 23409292         compare_runes [9]
-----------------------------------------------
                             1436504             add_string_to_fstring_db_runes <cycle 1> [56]
                             23453685             create_text_block <cycle 1> [8]
[10]    12.4   50.35    0.05 24890189         add_emchar_rune <cycle 1> [10]
                0.04    0.00       2/1006        _setcontext [18]
                0.00    0.01     377/42558       Dynarr_resize [81]
                0.00    0.00       2/777         sigacthandler [1036]
                             24589659             ensure_face_cachel_contains_charset <cycle 1> [37]

-- 
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/>    |

