From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Sebastian Sturm Newsgroups: gmane.emacs.devel Subject: Re: State of the overlay tree branch? Date: Wed, 21 Mar 2018 01:36:38 +0100 Message-ID: References: <834lldp18f.fsf@gnu.org> <9646341d-700b-4240-216b-8c0e753fa79f@arkona-technologies.de> <86d03e78-9984-f33e-a3f3-3faa4b34d78b@arkona-technologies.de> <83vadso9ad.fsf@gnu.org> <5155d5e2-6b5c-581e-89fe-4f3af717304f@arkona-technologies.de> <4c82fcbd-961a-c6ca-b1f0-6b85665cb339@arkona-technologies.de> <83po3zmf6o.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1521592549 24381 195.159.176.226 (21 Mar 2018 00:35:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 21 Mar 2018 00:35:49 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 21 01:35:45 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eyRjA-0006Ce-NY for ged-emacs-devel@m.gmane.org; Wed, 21 Mar 2018 01:35:41 +0100 Original-Received: from localhost ([::1]:52249 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyRlD-0000rH-Qi for ged-emacs-devel@m.gmane.org; Tue, 20 Mar 2018 20:37:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyRkB-0000pa-Uk for emacs-devel@gnu.org; Tue, 20 Mar 2018 20:36:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyRk8-0005yK-OT for emacs-devel@gnu.org; Tue, 20 Mar 2018 20:36:43 -0400 Original-Received: from smtp-out003.kontent.com ([81.88.40.217]:36499) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eyRk8-0005xW-AA for emacs-devel@gnu.org; Tue, 20 Mar 2018 20:36:40 -0400 Original-Received: from [192.168.0.102] (unknown [82.195.74.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: arkona-technologies_de_22@smtp-out003.kontent.com) by smtp-out003.kontent.com (Postfix) with ESMTPSA id A47A64001582 for ; Wed, 21 Mar 2018 01:36:38 +0100 (CET) In-Reply-To: <83po3zmf6o.fsf@gnu.org> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 81.88.40.217 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:223869 Archived-At: > So it's still a mystery why your original file produces such a large > slowdown with overlays. > > Can you show the results of "M-x profiler-report" for the slow test > with your original source file? It could have some clues. If that's > impossible, I can only repeat my suggestion to use perf to find the > code in Emacs that takes the lion's share of the processing time. this is the profiler report I get for the slow case (BTW, is there a way=20 to have the profiler resolve functions within line-number-at-pos? I=20 tried increasing profiler-max-stack-depth to 32, but the profiler still=20 didn't show anything below line-number-at-pos) - command-execute 20522 97= % - call-interactively 20522 9= 7% - funcall-interactively 20061 9= 4% - eval-expression 18609 8= 7% - eval 18609 8= 7% - benchmark-often 18609 8= 7% - let* 18609 8= 7% - while 18609 8= 7% - message 18388 8= 6% - format 18376 8= 6% - nth 18376 8= 6% - let 18376 8= 6% - list 18376 8= 6% - let 18368 8= 6% line-number-at-pos 18348 8= 6% ws-butler-after-change 4 = 0% + evil-open-below 614 = 2% + counsel-M-x 575 = 2% + undo-tree-undo 79 = 0% + next-line 68 = 0% + evil-normal-state 52 = 0% + evil-previous-line 48 = 0% + previous-line 7 = 0% + evil-emacs-state 6 = 0% + evil-insert 3 = 0% + byte-code 461 = 2% + redisplay_internal (C function) 254 1= % + timer-event-handler 116 0= % + evil-escape-pre-command-hook 82 0= % + ... 63 0= % + global-spacemacs-whitespace-cleanup-mode-check-buffers=20 47 0% + yas--post-command-handler 33 0= % + evil-repeat-post-hook 6 0= % + evil-visual-post-command 5 0= % + flycheck-handle-signal 4 0= % evil-snipe-mode-check-buffers 4 = 0% global-undo-tree-mode-check-buffers 4 = 0% + sp--save-pre-command-state 2 0= % + xselect-convert-to-string 2 0= % + evil-visual-pre-command 1 0= % + flycheck-pos-tip-hide-messages 1 0= % + which-key--hide-popup 1 0= % with perf, the ("self") time taken by buf_charpos_to_bytepos increases=20 from ~60% (fast case) to >98%. This is the diff generated by perf diff=20 : # Event 'cycles' # # Baseline Delta Shared Object Symbol=20 # ........ ....... ....................=20 .......................................... # 57.77% +40.30% emacs-27.0.50 [.] buf_charpos_to_bytepos 11.12% -10.70% libc-2.23.so [.] __memrchr 6.48% -6.19% emacs-27.0.50 [.] assq_no_quit 5.92% -5.62% emacs-27.0.50 [.] find_cache_boundary 4.26% -4.07% emacs-27.0.50 [.] set_buffer_internal_2 4.10% -3.73% emacs-27.0.50 [.] find_newline 3.54% libc-2.23.so [.] __memmove_avx_unaligned 1.25% -1.19% emacs-27.0.50 [.] region_cache_forward 0.46% -0.41% [kernel.kallsyms] [k] 0xffffffff83004eb0 0.26% -0.26% emacs-27.0.50 [.]=20 revalidate_region_cache.isra.1 0.25% -0.23% emacs-27.0.50 [.] find_interval 0.23% -0.23% emacs-27.0.50 [.] swap_in_symval_forwarding 0.19% -0.18% emacs-27.0.50 [.] do_symval_forwarding 0.16% -0.15% emacs-27.0.50 [.] eval_sub 0.16% -0.15% emacs-27.0.50 [.] x_produce_glyphs 0.13% libXft.so.2.3.2 [.] XftCharIndex 0.13% -0.12% libXft.so.2.3.2 [.] XftGlyphExtents 0.12% -0.12% emacs-27.0.50 [.] store_symval_forwarding 0.12% -0.11% emacs-27.0.50 [.] exec_byte_code 0.09% emacs-27.0.50 [.] Fsymbol_value 0.08% -0.08% emacs-27.0.50 [.] x_get_glyph_overhangs 0.07% emacs-27.0.50 [.] find_symbol_value 0.07% libc-2.23.so [.] __memcpy_avx_unaligned 0.07% emacs-27.0.50 [.] Fassq 0.07% emacs-27.0.50 [.] insert_1_both.part.9 0.06% emacs-27.0.50 [.] offset_intervals 0.06% libc-2.23.so [.] __memcmp_sse4_1 0.06% emacs-27.0.50 [.] next_element_from_buffer 0.05% -0.05% emacs-27.0.50 [.] move_it_in_display_line_t= o 0.05% -0.04% emacs-27.0.50 [.] get_next_display_element 0.05% -0.04% libXft.so.2.3.2 [.] XftFontCheckGlyph 0.05% -0.04% libX11.so.6.3.0 [.] _XSetClipRectangles 0.04% libc-2.23.so [.] __GI___printf_fp_l 0.04% emacs-27.0.50 [.] styled_format 0.04% -0.03% emacs-27.0.50 [.] xftfont_text_extents 0.04% -0.03% emacs-27.0.50 [.] draw_glyphs 0.04% emacs-27.0.50 [.] display_line 0.04% emacs-27.0.50 [.] validate_interval_range 0.04% emacs-27.0.50 [.] update_window_fringes 0.04% libX11.so.6.3.0 [.] 0x000000000001b65a 0.04% -0.03% emacs-27.0.50 [.] lookup_char_property 0.04% emacs-27.0.50 [.] balance_an_interval 0.03% emacs-27.0.50 [.] composition_compute_stop_= pos 0.03% libpthread-2.23.so [.] pthread_mutex_unlock 0.03% -0.03% emacs-27.0.50 [.] x_draw_glyph_string 0.03% -0.03% emacs-27.0.50 [.] mem_insert 0.03% -0.03% libpthread-2.23.so [.] pthread_mutex_lock 0.03% libc-2.23.so [.] malloc 0.03% emacs-27.0.50 [.] update_window_line 0.03% emacs-27.0.50 [.] Ffuncall 0.03% -0.03% emacs-27.0.50 [.] get_glyph_face_and_encodi= ng 0.03% -0.02% emacs-27.0.50 [.] set_internal 0.03% -0.02% emacs-27.0.50 [.] update_window 0.03% libXft.so.2.3.2 [.] XftDrawSrcPicture 0.03% libc-2.23.so [.] vfprintf 0.03% -0.02% emacs-27.0.50 [.] do_one_unbind.constprop.2= 0 0.03% emacs-27.0.50 [.] set_iterator_to_next 0.02% emacs-27.0.50 [.] specbind 0.02% libc-2.23.so [.] __memset_avx2 0.02% -0.02% libX11.so.6.3.0 [.] _XFlushGCCache 0.02% emacs-27.0.50 [.]=20 lookup_glyphless_char_display 0.02% libc-2.23.so [.] _int_malloc 0.02% emacs-27.0.50 [.] set_cursor_from_row.isra.= 40 0.02% -0.02% emacs-27.0.50 [.] message_dolog.part.60 0.02% emacs-27.0.50 [.] gap_left 0.02% -0.02% emacs-27.0.50 [.] unbind_to 0.02% -0.02% emacs-27.0.50 [.] init_iterator 0.02% emacs-27.0.50 [.] Fget_buffer 0.02% -0.01% emacs-27.0.50 [.] overlays_at 0.02% -0.01% [wl] [k] osl_readl 0.02% -0.01% emacs-27.0.50 [.] set_point_both 0.02% emacs-27.0.50 [.] message3_nolog 0.02% libX11.so.6.3.0 [.] _XGetRequest 0.02% libc-2.23.so [.] __sprintf_chk 0.02% emacs-27.0.50 [.] adjust_markers_for_insert 0.02% emacs-27.0.50 [.] adjust_suspend_auto_hscro= ll 0.02% emacs-27.0.50 [.]=20 get_char_property_and_overlay 0.01% emacs-27.0.50 [.] window_box_width 0.01% emacs-27.0.50 [.] Fcons 0.01% libxcb.so.1.1.0 [.] 0x0000000000009cca 0.01% -0.01% emacs-27.0.50 [.] arith_driver 0.01% -0.01% emacs-27.0.50 [.] resize_mini_window 0.01% emacs-27.0.50 [.] unchain_marker 0.01% emacs-27.0.50 [.] face_for_char 0.01% emacs-27.0.50 [.] unblock_input_to 0.01% emacs-27.0.50 [.] unblock_input 0.01% emacs-27.0.50 [.]=20 balance_possible_root_interval 0.01% emacs-27.0.50 [.] add_text_properties_1 0.01% emacs-27.0.50 [.] save_restriction_restore 0.01% emacs-27.0.50 [.] funcall_subr 0.01% emacs-27.0.50 [.] gap_right 0.01% -0.01% emacs-27.0.50 [.] Fcurrent_buffer 0.01% libXrender.so.1.3.0 [.] XRenderFillRectangle 0.01% libXext.so.6.4.0 [.] XdbeSwapBuffers 0.01% emacs-27.0.50 [.]=20 get_glyph_string_clip_rects.part.72 0.01% emacs-27.0.50 [.] Fwhile 0.01% emacs-27.0.50 [.] window_wants_mode_line 0.01% emacs-27.0.50 [.] display_echo_area_1 0.01% libXft.so.2.3.2 [.] XftDrawSetClipRectangles 0.01% emacs-27.0.50 [.] append_space_for_newline 0.01% emacs-27.0.50 [.] x_update_end 0.01% emacs-27.0.50 [.] Fforward_line 0.01% emacs-27.0.50 [.] memrchr@plt 0.01% emacs-27.0.50 [.] make_uninit_multibyte_str= ing 0.01% emacs-27.0.50 [.] prepare_to_modify_buffer_= 1 0.01% emacs-27.0.50 [.] Fstring_equal 0.01% emacs-27.0.50 [.] init_glyph_string 0.01% libc-2.23.so [.] _IO_old_init 0.01% libXrender.so.1.3.0 [.] XRenderFindDisplay 0.01% emacs-27.0.50 [.] Fnreverse 0.01% emacs-27.0.50 [.] arithcompare 0.01% emacs-27.0.50 [.] font_get_frame_data 0.01% emacs-27.0.50 [.] window_box_left 0.01% libX11.so.6.3.0 [.] XSetClipRectangles 0.01% -0.01% emacs-27.0.50 [.] Flength 0.01% emacs-27.0.50 [.] previous_interval 0.01% libXft.so.2.3.2 [.] 0x0000000000007294 0.01% emacs-27.0.50 [.]=20 x_compute_glyph_string_overhangs 0.01% emacs-27.0.50 [.] XftCharIndex@plt 0.01% libXrender.so.1.3.0 [.] XRenderCompositeString16 0.01% emacs-27.0.50 [.] message3 0.01% emacs-27.0.50 [.] xftfont_encode_char 0.01% emacs-27.0.50 [.] assign_row 0.01% emacs-27.0.50 [.] prepare_desired_row 0.01% emacs-27.0.50 [.] xftfont_draw 0.01% libXext.so.6.4.0 [.] XextFindDisplay 0.01% libpthread-2.23.so [.]=20 pthread_cond_broadcast@@GLIBC_2.3.2 0.01% libXft.so.2.3.2 [.] XftDrawGlyphs 0.01% emacs-27.0.50 [.] marker_position 0.01% emacs-27.0.50 [.] funcall_lambda 0.01% emacs-27.0.50 [.] gettime 0.01% libpthread-2.23.so [.] __GI___libc_recvmsg 0.01% emacs-27.0.50 [.] lisp_time_struct 0.01% emacs-27.0.50 [.] echo_area_display 0.01% emacs-27.0.50 [.] CHECK_MARKER 0.01% emacs-27.0.50 [.] del_range_2 0.01% emacs-27.0.50 [.] prepare_face_for_display 0.01% emacs-27.0.50 [.] interval_deletion_adjustm= ent 0.01% libc-2.23.so [.] strlen 0.01% emacs-27.0.50 [.] verify_interval_modificat= ion 0.01% emacs-27.0.50 [.] count_size_as_multibyte 0.01% emacs-27.0.50 [.] adjust_overlays_for_inser= t 0.01% libXrender.so.1.3.0 [.]=20 XRenderSetPictureClipRectangles 0.01% emacs-27.0.50 [.] buffer_local_value 0.01% emacs-27.0.50 [.] adjust_window_count 0.01% emacs-27.0.50 [.]=20 notice_overwritten_cursor.part.52 0.01% libc-2.23.so [.] __GI___writev 0.01% emacs-27.0.50 [.] record_in_backtrace 0.01% emacs-27.0.50 [.] save_restriction_save 0.01% emacs-27.0.50 [.] Fget_text_property 0.01% -0.00% [vdso] [.] __vdso_clock_gettime 0.01% emacs-27.0.50 [.] window_wants_header_line 0.01% emacs-27.0.50 [.] Fmessage 0.01% emacs-27.0.50 [.] FUNCTIONP 0.01% emacs-27.0.50 [.] window_display_table 0.01% emacs-27.0.50 [.] maybe_quit 0.01% emacs-27.0.50 [.] clear_glyph_matrix 0.01% -0.00% emacs-27.0.50 [.] with_echo_area_buffer 0.01% libc-2.23.so [.] __libc_enable_asynccancel 0.01% emacs-27.0.50 [.] should_produce_line_numbe= r 0.01% emacs-27.0.50 [.] x_set_glyph_string_clippi= ng 0.01% emacs-27.0.50 [.] set_message_1 0.01% emacs-27.0.50 [.] del_range_both 0.01% emacs-27.0.50 [.] record_insert 0.01% emacs-27.0.50 [.] adjust_overlays_for_delet= e 0.01% +0.00% libc-2.23.so [.] _int_free 0.01% libc-2.23.so [.] __strchrnul 0.01% emacs-27.0.50 [.] Fgoto_char 0.01% emacs-27.0.50 [.] free_misc 0.01% emacs-27.0.50 [.] draw_window_fringes 0.01% emacs-27.0.50 [.] x_flush.isra.37.part.38 0.01% libpthread-2.23.so [.] __errno_location 0.01% emacs-27.0.50 [.] make_float 0.01% emacs-27.0.50 [.] fill_glyph_string 0.01% emacs-27.0.50 [.] Fget 0.01% emacs-27.0.50 [.] Flocal_variable_p 0.01% emacs-27.0.50 [.] decode_time_components 0.01% emacs-27.0.50 [.] XftGlyphExtents@plt 0.01% emacs-27.0.50 [.] row_for_charpos_p 0.01% emacs-27.0.50 [.] load_overlay_strings 0.01% emacs-27.0.50 [.] allocate_misc 0.01% -0.00% libX11.so.6.3.0 [.] _XSend 0.01% libX11.so.6.3.0 [.] _XData32 0.01% -0.00% emacs-27.0.50 [.] buf_bytepos_to_charpos 0.01% emacs-27.0.50 [.] face_at_buffer_position 0.01% emacs-27.0.50 [.] invalidate_current_column 0.01% emacs-27.0.50 [.] find_composition 0.01% emacs-27.0.50 [.] x_draw_window_cursor 0.01% emacs-27.0.50 [.] x_flip_and_flush 0.01% libc-2.23.so [.] _IO_no_init 0.01% emacs-27.0.50 [.] Ftime_subtract 0.01% emacs-27.0.50 [.] row_hash 0.01% emacs-27.0.50 [.] lookup_basic_face 0.01% emacs-27.0.50 [.] memcpy@plt 0.01% emacs-27.0.50 [.] Fset_buffer 0.01% emacs-27.0.50 [.] produce_special_glyphs 0.00% emacs-27.0.50 [.]=20 x_draw_glyph_string_background.part.44 0.00% [vdso] [.] 0x0000000000000939 0.00% emacs-27.0.50 [.] make_save_obj_obj_obj_obj 0.00% libc-2.23.so [.] __GI___libc_poll 0.00% emacs-27.0.50 [.] do_specbind 0.00% libXft.so.2.3.2 [.] XftGlyphRender 0.00% emacs-27.0.50 [.] move_it_to 0.00% emacs-27.0.50 [.] make_current.isra.14 0.00% emacs-27.0.50 [.] Fnext_single_property_cha= nge 0.00% emacs-27.0.50 [.] handle_face_prop 0.00% libX11.so.6.3.0 [.] _XFlush 0.00% emacs-27.0.50 [.] unwind_with_echo_area_buf= fer 0.00% emacs-27.0.50 [.] evaporate_overlays 0.00% emacs-27.0.50 [.] sort_overlays 0.00% emacs-27.0.50 [.] del_range_1 0.00% libX11.so.6.3.0 [.] XFlush 0.00% emacs-27.0.50 [.] try_window 0.00% emacs-27.0.50 [.] x_set_glyph_string_gc 0.00% libc-2.23.so [.] malloc_consolidate 0.00% emacs-27.0.50 [.] handle_stop 0.00% emacs-27.0.50 [.] recenter_overlay_lists 0.00% libX11.so.6.3.0 [.] pthread_mutex_lock@plt 0.00% emacs-27.0.50 [.] modify_text_properties 0.00% emacs-27.0.50 [.] delete_interval 0.00% emacs-27.0.50 [.] window_text_bottom_y 0.00% +0.00% emacs-27.0.50 [.] copy_text 0.00% emacs-27.0.50 [.] set_default_internal 0.00% +0.00% libxcb.so.1.1.0 [.] xcb_writev 0.00% emacs-27.0.50 [.] temp_set_point_both 0.00% emacs-27.0.50 [.] insert_1_both 0.00% emacs-27.0.50 [.] record_property_change 0.00% emacs-27.0.50 [.] lisp_align_malloc 0.00% emacs-27.0.50 [.] x_mark_frame_dirty 0.00% +0.00% emacs-27.0.50 [.] text_quoting_style 0.00% libc-2.23.so [.] __GI___mempcpy 0.00% emacs-27.0.50 [.] Ffloat_time 0.00% emacs-27.0.50 [.] x_write_glyphs 0.00% +0.00% emacs-27.0.50 [.] insert_from_string_1 0.00% emacs-27.0.50 [.] Fpoint 0.00% libc-2.23.so [.] __vsprintf_chk 0.00% libc-2.23.so [.] hack_digit 0.00% emacs-27.0.50 [.] grow_specpdl 0.00% emacs-27.0.50 [.] time_arith 0.00% emacs-27.0.50 [.] update_end 0.00% emacs-27.0.50 [.] allocate_string_data 0.00% emacs-27.0.50 [.] save_excursion_restore 0.00% +0.00% emacs-27.0.50 [.] Flet 0.00% emacs-27.0.50 [.] mem_rotate_right 0.00% emacs-27.0.50 [.] fetch_buffer_markers 0.00% emacs-27.0.50 [.] move_gap_both 0.00% emacs-27.0.50 [.] xmalloc 0.00% emacs-27.0.50 [.] update_begin 0.00% emacs-27.0.50 [.] float_arith_driver 0.00% emacs-27.0.50 [.] make_specified_string 0.00% emacs-27.0.50 [.] handle_composition_prop 0.00% emacs-27.0.50 [.] display_and_set_cursor 0.00% emacs-27.0.50 [.] compute_line_metrics 0.00% emacs-27.0.50 [.] clock_gettime@plt 0.00% libc-2.23.so [.] free 0.00% emacs-27.0.50 [.] Fplist_get 0.00% libgdk-3.so.0.1800.9 [.] gdk_display_manager_get 0.00% emacs-27.0.50 [.] make_interval 0.00% libxcb.so.1.1.0 [.] xcb_poll_for_event 0.00% emacs-27.0.50 [.] adjust_markers_for_delete 0.00% emacs-27.0.50 [.] do_pending_window_change 0.00% emacs-27.0.50 [.] XftDrawGlyphs@plt 0.00% libc-2.23.so [.] _itoa_word 0.00% emacs-27.0.50 [.] disassemble_lisp_time 0.00% emacs-27.0.50 [.] Ftext_properties_at 0.00% emacs-27.0.50 [.] composition_reseat_it 0.00% libX11.so.6.3.0 [.] _XEventsQueued 0.00% emacs-27.0.50 [.] minmax_driver 0.00% emacs-27.0.50 [.] set_marker_restricted_bot= h 0.00% emacs-27.0.50 [.] graft_intervals_into_buff= er 0.00% emacs-27.0.50 [.] disp_char_vector 0.00% libc-2.23.so [.] __clock_gettime 0.00% emacs-27.0.50 [.] CHECK_STRING_OR_BUFFER 0.00% emacs-27.0.50 [.] intervals_equal 0.00% emacs-27.0.50 [.] ensure_echo_area_buffers 0.00% emacs-27.0.50 [.] invalidate_buffer_caches 0.00% emacs-27.0.50 [.] set_marker_both 0.00% +0.00% emacs-27.0.50 [.] record_unwind_protect 0.00% emacs-27.0.50 [.] run_hook_with_args 0.00% emacs-27.0.50 [.] set_point_from_marker 0.00% emacs-27.0.50 [.] list4 0.00% libX11.so.6.3.0 [.] XSetClipMask 0.00% emacs-27.0.50 [.] record_buffer_markers 0.00% emacs-27.0.50 [.] default_value +0.00% libXext.so.6.4.0 [.] 0x000000000000bf10 +0.00% emacs-27.0.50 [.] Fsetq +0.00% emacs-27.0.50 [.] reseat_1 +0.00% emacs-27.0.50 [.] update_compositions this is what perf annotate shows when invoked on buf_charpos_to_bytepos=20 (slow case): =E2=94=82 =E2=86=93 jle 438=20 =E2=96=92 4,39 =E2=94=82 mov 0x20(%rax),%r8=20 =E2=96=92 8,38 =E2=94=82 mov %rdx,%rbp=20 =E2=96=92 0,05 =E2=94=822f0: mov %rbp,%rdx=20 =E2=96=92 0,13 =E2=94=82 mov %r8,%rdi=20 =E2=96=92 2,70 =E2=94=82 sub %r13,%rdx=20 =E2=96=92 2,22 =E2=94=82 sub %rbx,%rdi=20 =E2=96=92 0,05 =E2=94=82 cmp %rdi,%rdx=20 =E2=96=92 =E2=94=82 =E2=86=91 je 1e9=20 =E2=96=92 =E2=94=82=20 =E2=96=92 =E2=94=82 /* If we are down to a range of 50 chars,=20 =E2=96=92 =E2=94=82 don't bother checking any other markers;=20 =E2=96=92 =E2=94=82 scan the intervening chars directly now. = */=20 =E2=96=92 =E2=94=82 if (best_above - best_below < 50)=20 =E2=96=92 3,21 =E2=94=82305: cmp $0x31,%rdx=20 =E2=96=92 =E2=94=82 =E2=86=93 jle 480=20 =E2=96=92 =E2=94=82 CONSIDER (BUF_ZV (b), BUF_ZV_BYTE (b));=20 =E2=96=92 =E2=94=82=20 =E2=96=92 =E2=94=82 if (b =3D=3D cached_buffer && BUF_MODIFF (b) =3D=3D= =20 cached_modiff) =E2=96=92 =E2=94=82 CONSIDER (cached_charpos, cached_bytepos);=20 =E2=96=92 =E2=94=82=20 =E2=96=92 =E2=94=82 for (tail =3D BUF_MARKERS (b); tail; tail =3D tai= l->next)=20 =E2=96=92 2,50 =E2=94=82 mov 0x10(%rax),%rax=20 =E2=96=92 4,25 =E2=94=82 test %rax,%rax=20 =E2=96=92 =E2=94=82 =E2=86=93 je 480=20 =E2=96=92 =E2=94=82 {=20 =E2=97=86 =E2=94=82 CONSIDER (tail->charpos, tail->bytepos);=20 =E2=96=92 2,64 =E2=94=8231c: mov 0x18(%rax),%rdx=20 =E2=96=92 59,16 =E2=94=82 cmp %rdx,%rsi=20 =E2=96=92 =E2=94=82 =E2=86=93 je 638=20 =E2=96=92 5,70 =E2=94=82 cmp %rdx,%rsi=20 =E2=96=92 =E2=94=82 =E2=86=91 jl 2e0=20 =E2=96=92 0,00 =E2=94=82 cmp %rdx,%r13=20 =E2=96=92 =E2=94=82 =E2=86=93 jge 438=20 =E2=96=92 0,00 =E2=94=82 mov 0x20(%rax),%rbx=20 =E2=96=92 0,01 =E2=94=82 mov %rdx,%r13=20 =E2=96=92 =E2=94=82 =E2=86=91 jmp 2f0=20 =E2=96=92 =E2=94=82 marker_byte_position():=20 =E2=96=92 =E2=94=82 if (!buf)=20 =E2=96=92 =E2=94=82 error ("Marker does not point anywhere");=20 =E2=96=92 =E2=94=82=20 =E2=96=92 =E2=94=82 eassert (BUF_BEG_BYTE (buf) <=3D m->bytepos && m-= >bytepos=20 <=3D BUF_Z_BYTE (b=E2=96=92 =E2=94=82=20 =E2=96=92 =E2=94=82 return m->bytepos;=20 =E2=96=92 =E2=94=82340: mov 0x20(%rdi),%rbx=20 =E2=96=92 =E2=94=82 =E2=86=91 jmpq cb=20 =E2=96=92 =E2=94=82 nop=20 =E2=96=92 =E2=94=82 buf_charpos_to_bytepos():=20 =E2=96=92 =E2=94=82=20 =E2=96=92 =E2=94=82 If at any point we can tell that the space bet= ween=20 those =E2=96=92 =E2=94=82 two best approximations is all single-byte,=20 =E2=96=92 =E2=94=82 we interpolate the result immediately. */=20 =E2=96=92 =E2=94=82=20 =E2=96=92 =E2=94=82 CONSIDER (BUF_PT (b), BUF_PT_BYTE (b));=20 =E2=96=92 =E2=94=82350: mov 0x2f0(%rdi),%r13=20 =E2=96=92 =E2=94=82 cmp %rsi,%r13=20 =E2=96=92 to my eyes, the fast case doesn't look too different though: =E2=94=82 =E2=86=93 jle 438 0,83 =E2=94=82 mov 0x20(%rax),%r8 0,93 =E2=94=82 mov %rdx,%rbp =E2=94=822f0: mov %rbp,%rdx 0,06 =E2=94=82 mov %r8,%rdi 0,20 =E2=94=82 sub %r13,%rdx 0,11 =E2=94=82 sub %rbx,%rdi 0,12 =E2=94=82 cmp %rdi,%rdx =E2=94=82 =E2=86=91 je 1e9 =E2=94=82 =E2=94=82 /* If we are down to a range of 50 chars, =E2=94=82 don't bother checking any other markers; =E2=94=82 scan the intervening chars directly now. = */ =E2=94=82 if (best_above - best_below < 50) 11,24 =E2=94=82305: cmp $0x31,%rdx =E2=94=82 =E2=86=93 jle 480 =E2=94=82 CONSIDER (BUF_ZV (b), BUF_ZV_BYTE (b)); =E2=94=82 =E2=94=82 if (b =3D=3D cached_buffer && BUF_MODIFF (b) =3D=3D= cached_modiff) =E2=94=82 CONSIDER (cached_charpos, cached_bytepos); =E2=94=82 =E2=94=82 for (tail =3D BUF_MARKERS (b); tail; tail =3D tai= l->next) 0,16 =E2=94=82 mov 0x10(%rax),%rax 10,41 =E2=94=82 test %rax,%rax =E2=94=82 =E2=86=93 je 480 =E2=94=82 { =E2=94=82 CONSIDER (tail->charpos, tail->bytepos); 3,19 =E2=94=8231c: mov 0x18(%rax),%rdx 42,86 =E2=94=82 cmp %rdx,%rsi =E2=94=82 =E2=86=93 je 638 10,36 =E2=94=82 cmp %rdx,%rsi =E2=94=82 =E2=86=91 jl 2e0 2,24 =E2=94=82 cmp %rdx,%r13 =E2=94=82 =E2=86=93 jge 438 0,76 =E2=94=82 mov 0x20(%rax),%rbx 0,43 =E2=94=82 mov %rdx,%r13 =E2=94=82 =E2=86=91 jmp 2f0 =E2=94=82 marker_byte_position(): =E2=94=82 if (!buf) =E2=94=82 error ("Marker does not point anywhere"); =E2=94=82 =E2=94=82 eassert (BUF_BEG_BYTE (buf) <=3D m->bytepos && m-= >bytepos=20 <=3D BUF_Z_BYTE (bu =E2=94=82 =E2=94=82 return m->bytepos; =E2=94=82340: mov 0x20(%rdi),%rbx =E2=94=82 =E2=86=91 jmpq cb =E2=94=82 nop =E2=94=82 buf_charpos_to_bytepos(): =E2=94=82 =E2=94=82 If at any point we can tell that the space bet= ween those =E2=94=82 two best approximations is all single-byte, =E2=94=82 we interpolate the result immediately. */ =E2=94=82 =E2=94=82 CONSIDER (BUF_PT (b), BUF_PT_BYTE (b)); =E2=94=82350: mov 0x2f0(%rdi),%r13 =E2=94=82 cmp %rsi,%r13 I hope this is of some use, but I'll keep looking for open source files=20 to reproduce the issue