From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Excessive redisplay from lots of process output Date: Sat, 25 Feb 2023 09:35:23 +0200 Message-ID: <83ttzakxj8.fsf@gnu.org> References: <834jrk1dli.fsf@gnu.org> <619913E2-4062-4865-8351-5EADFA4DCC70@yahoo.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16986"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Po Lu , Spencer Baugh Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Feb 25 08:36:53 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pVp6y-0004FO-16 for ged-emacs-devel@m.gmane-mx.org; Sat, 25 Feb 2023 08:36:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVp60-0001SM-N3; Sat, 25 Feb 2023 02:35:52 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVp5j-0001Ny-RU for emacs-devel@gnu.org; Sat, 25 Feb 2023 02:35:41 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVp5g-0005C8-Pf; Sat, 25 Feb 2023 02:35:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=umsMYxk1gcZaWv+0eYwagoVEGnOM6WQLmdiuyKJGHb8=; b=i0n6kydzluQr kQSIg2xajluzqV8u3iIm29ejEyntp93KUcEfn/apuTXoaphlNGiav9wZaZ1MV/lRQOV60832a9jkR kPZ9SPFnpSoyZQLr3wsMfCT0viY66uMcR2EsZ3WOfLr4U9W7I4eLiFQgva1aQUgzzZH5TVm4SoANE lzvJvCINFYYV4jwG55ZkHgF7d4yumQ9VcOrAFY87yJKBZzTo9pT9JYN4n/mBLOyShb2tTTWFb7YYc +yl4U6Q+9g/kZlNnYWFO0ULnQEzUMU8kJb5loZkoIYdxf18MNb3ZnBkiatbNBqiLr0TawxFOnASL9 muumdEuq0npEVinZEkFljw==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVp5V-0008NL-5D; Sat, 25 Feb 2023 02:35:30 -0500 In-Reply-To: <619913E2-4062-4865-8351-5EADFA4DCC70@yahoo.com> (message from Po Lu on Sat, 25 Feb 2023 07:10:24 +0800) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:303784 Archived-At: > Date: Sat, 25 Feb 2023 07:10:24 +0800 > From: Po Lu > > If the problem is still there in Emacs 29, please run Emacs under xscope, and tell which request(s) are being made. Emacs should not make X requests when nothing on the display has actually changed. The backtrace posted by Spencer tells us that Emacs called redisplay_preserve_echo_area: >#0 0x00007ffff4abc5c0 in XFlush () at /lib64/libX11.so.6 >#1 0x00000000004d23d6 in x_flush (f=) at xterm.c:250 >#2 0x00000000004d2416 in x_flip_and_flush (f=0xf956d0) at xterm.c:246 >#3 0x00000000004d2416 in x_flip_and_flush (f=0xf956d0) at xterm.c:1230 >#4 0x0000000000461374 in redisplay_preserve_echo_area (f=out>) at frame.h:1700 >#5 0x0000000000461374 in redisplay_preserve_echo_area >(from_where=from_where@entry=12) at xdisp.c:16527 >#6 0x00000000005bee33 in wait_reading_process_output >(time_limit=time_limit@entry=0, nsecs=nsecs@entry=0, >read_kbd=read_kbd@entry=-1, do_display=true, >wait_for_cell=wait_for_cell@entry=0x0, wait_proc=wait_proc@entry=0x0, >just_wait_proc=just_wait_proc@entry=0) at process.c:5808 >#7 0x000000000050aea4 in read_char (end_time=0x0, >used_mouse_menu=0x7fffffffda5b, kbp=) at >keyboard.c:3926 And redisplay_preserve_echo_area calls flush_frame unconditionally for the selected frame: void redisplay_preserve_echo_area (int from_where) { redisplay_trace ("redisplay_preserve_echo_area (%d)\n", from_where); block_input (); specpdl_ref count = SPECPDL_INDEX (); record_unwind_protect_void (unwind_redisplay_preserve_echo_area); block_buffer_flips (); unblock_input (); if (!NILP (echo_area_buffer[1])) { /* We have a previously displayed message, but no current message. Redisplay the previous message. */ display_last_displayed_message_p = true; redisplay_internal (); display_last_displayed_message_p = false; } else redisplay_internal (); flush_frame (SELECTED_FRAME ()); <<<<<<<<<<<<<<<<<<<<<<<<<<<< unbind_to (count, Qnil); } How can we avoid this call to flush_frame "when nothing on the display has actually changed"? We don't have any mechanism for update_frame and/or redisplay_internal to tell back whether anything was changed on display. There's a lot that _can_ change: . text-area of the windows . mode lines, header lines, and tab-lines . menu bar, tool bar, and tab bar . fringes . scroll bars . frame's title . new frames and windows, including tooltips We currently don't have any indication for whether any of those have changed. Where do we call _XReply and for what purpose? I don't see it in our sources anywhere.