From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: Excessive redisplay from lots of process output Date: Sat, 25 Feb 2023 17:43:40 +0800 Message-ID: <87pm9y2i7n.fsf@yahoo.com> References: <834jrk1dli.fsf@gnu.org> <619913E2-4062-4865-8351-5EADFA4DCC70@yahoo.com> <83ttzakxj8.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19836"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Spencer Baugh , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Feb 25 10:46:52 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 1pVr8m-0004yU-J4 for ged-emacs-devel@m.gmane-mx.org; Sat, 25 Feb 2023 10:46:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVr89-0006dt-4J; Sat, 25 Feb 2023 04:46:13 -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 1pVr87-0006a4-Hk for emacs-devel@gnu.org; Sat, 25 Feb 2023 04:46:11 -0500 Original-Received: from sonic311-50.consmr.mail.ne1.yahoo.com ([66.163.188.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVr7z-000819-Hi for emacs-devel@gnu.org; Sat, 25 Feb 2023 04:46:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1677318360; bh=nvArZiqzDJxX20SZlSHIRVEjN5VXKss7FTP0zJdJNS0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=eSelMoXmB4+W5uX5ajxQAE1yEwQXO0S7YBqq9CyNV+biMFKuxgvbqzPBJMjh/L4zLhW9WvapM8rbgy2JHoHkE+GH+t49gnhuYVsK1uZWGfVyWC619y7JxgOjHsQqTICsjBZEWpv+yMjHa7+x2Go6umpCuKJps1QbkiD64SdJDF50fkPWzBqRYhuA8BQJgH2CY1KUL3tMtfHy76z4BkynSTqliYWzQiKCq0fxPd74tStSOY/MEOYK46p+oQVPuoLBqerP7xxhjhxWDzHub1J+4DNassKwPxAONuHywnTwG09dbAaBvTlEn2oJoUFO723x+VJdji5Mt72guOr+yMV5kg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1677318360; bh=wb8iHhlNLuFw5ONXNTyqbOgbxY0Z4f7K4ij2aWMyMw+=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=ZaQZeeerEo3N8VpiBlGAsuLgkFP5AoVfMiC8qwC/YxKT+/HrB0k70J3Xbz+aKRzPh1DeVZ4FXEdDesyBi1L1iqlta/LbnL17hNb4XfbHMZ4lHDBn6l5Zuk/iXAL8c9ECOLmiLVFofhl+IPF3Xwhpturnp7SB91YPO0Yy5OcZEI+UI5Y+T2A4S9K8SD6tGyfmrtkukG/0pgPgi+NCgjk9Rn+ZgYkjRYWT6yUgcPClxur+9zPdmsX91hJAcn4dEnI+kbzWo6FmitvVf1LltUrxPV8IB027Ovslqh74vXq1vEvIwEVfjfqM5rCiCufDNDYqbRY9ReugDn5voFCicmybGg== X-YMail-OSG: nuh.elQVM1lqQrtpRkVPFBPTXOH_VMVxLq6KKW7CObIgQHOk8LdHHKqBAbJwwpJ y34Lwm0mUusWY75s422k.exNjJIPLh.GAxsipSBplKSGPeR9EbabQlUj0cstSzKq5ul4uK13LWDn vTBw3Zt_8XUslXwsUuHNiUtYwk0pAiYRAoRZrIJI34C0RkpoGGeEbC5raLbYamaQ73Ba.gQRHUr9 zH52nN7KCxqOH3n9e88LSrYTjroPvZshdjubARV8lPk.YwlxLlAc1rKTARXjUEcnTSDB26vREM1Q gZ_2L0r8XBa0mICKd.YNtv0e4JUS8xCl2ho.80A7eWaLfR7qbz24Bpnl7FR.A_7S0_4lorjw.LfK DjUe3RN.4jAb7XN6Wkp1WtHJQmoJ.mKYwz8RJ6lDCPnwuKUlvuLQq0AlNidTrco3HU1DoK8shQfh FqZEIT5A4ARDUdw.PqC1QpTrAfgCtAPggqQZUuYzxXwsL7WzBGF30feghT_xKw5iEY9q8Wrqi4cW lbQVW09RcRHKveVUyzyaiwkFiOjzRi.wJKZxXnMxpHkZJlQfC_K.L1nH5UPVd4nXKEi1js_eOatI AUkBYPED7InN5BRNI.uvSmrOhsyKlEBZ0NKyGVxhGK.PyxLfhVi77CD5Z_dClKZtVdCGTvs8Elaq kHoxikYChxW0Slb5zuhlewkWlZVU0qFWZ21LxT8gZpdmmYWQJnH7nAMhAqj.j1OmeQu9OvFyr.vH om_PQvvxfVWZkkZbrPCp1JBEwQ2W8fPz6PFNaNsoYnSy5ZNgHv7NYi9F3_qScoLiF1VzmK4ocATs sAlwaxqtfkk9Io17ftCFr8.aqgnrxgyYTB1ipCpWdF X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.ne1.yahoo.com with HTTP; Sat, 25 Feb 2023 09:46:00 +0000 Original-Received: by hermes--production-sg3-9fc5746c8-7wpmf (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 3feb388f14b531732273ad57e8214dde; Sat, 25 Feb 2023 09:43:56 +0000 (UTC) In-Reply-To: <83ttzakxj8.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 25 Feb 2023 09:35:23 +0200") X-Mailer: WebService/1.1.21221 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.188.231; envelope-from=luangruo@yahoo.com; helo=sonic311-50.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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:303788 Archived-At: Eli Zaretskii writes: > 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: XFlush (called by flush_frame) is the function which avoids doing anything if nothing on the display has changed, as it makes no requests itself. Calling flush_frame after a redisplay which does nothing is harmless; all the OP is experiencing tells us is that XFlush is not to blame, but most likely some other X protocol request calling _XReply. > Where do we call _XReply and for what purpose? I don't see it in our > sources anywhere. _XReply is the function called with Xlib whenever you make an X protocol request that has a reply, such as XGetWindowProperty: dpyinfo = FRAME_DISPLAY_INFO (f); if (XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), dpyinfo->Xatom_wm_state, 0, 2, False, AnyPropertyType, &type, &format, &nitems, &bytes_after, &data) != Success) return; if (!data || nitems != 2 || format != 32) { This is expensive because it involves sending a request to the X server and waiting for a response, which easily takes hundereds of ms over a slow network connection. Fortunately, Emacs 29 should not call XSync as much as Emacs 28 did. Which is why I asked Spencer to try it out.