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: Fri, 24 Feb 2023 21:34:38 +0200 Message-ID: <83fsaun9gx.fsf@gnu.org> References: <834jrk1dli.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28816"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, azeng@janestreet.com To: Spencer Baugh Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Feb 24 20:35:18 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 1pVdqe-0007GQ-Ud for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Feb 2023 20:35:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVdq6-0005qX-SP; Fri, 24 Feb 2023 14:34:42 -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 1pVdq4-0005q9-Gm for emacs-devel@gnu.org; Fri, 24 Feb 2023 14:34:40 -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 1pVdq4-0007vI-38; Fri, 24 Feb 2023 14:34:40 -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=bPyXa7jUHKarTX7DaOGSQZj7j2+gjWpVlRvwmBsyG8Q=; b=ZJfKnlrNVLrK Lcnm2xkUroxyYE5RH9XCzURRWtHGF1JTNJ+0fTa+vx7pg0lcNRJqs/XmcwWQzHJIYFh86t1KuQnmj qLKl1hGwHt4tt5GKGoJ84r9YSV2zImSpSOybomxi9mcAyWnmYoDpn86ISFstJz+tdeKQ5u4J/EQbr vD+NKblPvREII9diAXd/8O7ofvBN2zYZwUILAJvLgAXGgqeYPc/J/V/PwHPeRpStBz+bMxD2wrICf 78+sRAu5juYXJCJyfrafMf4iE7e/7ksRh8Lcimv6El/aqhVg3LPgeK+If8Bi3J4GpVIkcChzbodSU WrxftqVXT5PQC90kRyu38g==; 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 1pVdq2-0003wr-9p; Fri, 24 Feb 2023 14:34:39 -0500 In-Reply-To: (message from Spencer Baugh on Fri, 24 Feb 2023 14:14:55 -0500) 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:303755 Archived-At: > From: Spencer Baugh > Date: Fri, 24 Feb 2023 14:14:55 -0500 > Cc: emacs-devel@gnu.org, > azeng@janestreet.com > > On Fri, Feb 17, 2023 at 11:06 AM Eli Zaretskii wrote: > > > > > From: Spencer Baugh > > > Cc: azeng@janestreet.com > > > Date: Fri, 17 Feb 2023 10:16:11 -0500 > > > > > > Emacs calls redisplay every time it reads process output. This causes > > > Emacs to become painfully slow when these two conditions are met: > > > > > > - When redisplay is expensive (e.g. when using ssh X forwarding) > > > > > > - And when there is frequent process output, say hundreds or thousands > > > of times a second (e.g. ERC receiving network traffic, shells > > > running commands which log heavily, other things which run in the > > > background) > > > > This cannot be the whole story, because usually redisplay exits almost > > immediately after being called, having determined that nothing needs > > to be changed on display. > > > > So the important part of your situation that you didn't disclose is: > > why does Emacs in your case perform the expensive redisplay each time > > redisplay is entered? Can you figure that out by stepping through > > redisplay_internal? (Let me know if you need guidance.) > > Actually, I'm looking a bit more into it, and I think there is still > some issue causing excessive X traffic when there's lots of process > output to be read. On emacs -Q with Emacs 28, flush_frame/XFlush is > called on every redisplay, and does seem to be actually writing X > requests on the X socket every time. > > Here's a backtrace of where flush_frame/XFlush is being called from: > > #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 > #8 0x000000000050aea4 in read_char (used_mouse_menu=, > local_getcjmp=, end_time=) at > keyboard.c:2198 > #9 0x000000000050aea4 in read_char (used_mouse_menu=, > prev_event=, local_getcjmp=, > end_time=) at keyboard.c:2261 > #10 0x000000000050aea4 in read_char (commandflag=commandflag@entry=1, > map=map@entry=0x127fed3, prev_event=, > used_mouse_menu=used_mouse_menu@entry=0x7fffffffda5b, > end_time=end_time@entry=0x0) at keyboard.c:2892 > #11 0x000000000050cc5e in read_key_sequence > (keybuf=keybuf@entry=0x7fffffffdb60, prompt=prompt@entry=0x0, > dont_downcase_last=dont_downcase_last@entry=false, > can_return_switch_frame=can_return_switch_frame@entry=true, > fix_current_buffer=fix_current_buffer@entry=true, > prevent_redisplay=prevent_redisplay@entry=false) at keyboard.c:9635 > #12 0x000000000050e390 in command_loop_1 () at keyboard.c:1392 > #13 0x0000000000578754 in internal_condition_case > (bfun=bfun@entry=0x50e180 , > handlers=handlers@entry=0x90, hfun=hfun@entry=0x504990 ) at > eval.c:1450 > #14 0x00000000004ff4aa in command_loop_2 > (handlers=handlers@entry=0x90) at keyboard.c:1133 > #15 0x0000000000578704 in internal_catch (tag=tag@entry=0xe850, > func=func@entry=0x4ff490 , arg=arg@entry=0x90) at > eval.c:1181 > #16 0x00000000004ff46a in command_loop () at keyboard.c:1111 > #17 0x00000000005045cb in recursive_edit_1 () at keyboard.c:720 > #18 0x00000000005048e5 in Frecursive_edit () at keyboard.c:803 > #19 0x000000000041e909 in main (argc=4, argv=) at emacs.c:2361 > > What could be causing this? This says that Emacs have read some stuff from the sub-process. When that happens, we always perform a relatively-thorough redisplay, which is what you see. This is normal. If the problem is that flush_frame causes too much X traffic across the network, perhaps some tuning of your X connection is in order. Or maybe some X expert (I'm not) could suggest something else.