From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.devel Subject: Re: Excessive redisplay from lots of process output Date: Fri, 24 Feb 2023 14:14:55 -0500 Message-ID: References: <834jrk1dli.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28895"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, azeng@janestreet.com To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Feb 24 20:35:17 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-0007GP-V4 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 1pVdqI-00067S-1S; Fri, 24 Feb 2023 14:34:54 -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 1pVdXD-0005Gk-U4 for emacs-devel@gnu.org; Fri, 24 Feb 2023 14:15:13 -0500 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVdXB-0006ay-16 for emacs-devel@gnu.org; Fri, 24 Feb 2023 14:15:10 -0500 Original-Received: from mail-yw1-f200.google.com ([209.85.128.200]) by mxgoog2.mail.janestreet.com with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) (Exim 4.96) id 1pVdX8-002HDI-2s for emacs-devel@gnu.org; Fri, 24 Feb 2023 14:15:07 -0500 Original-Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-536c02ed619so3907127b3.8 for ; Fri, 24 Feb 2023 11:15:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=G+uec9JlNQvBvkiugu9V5Evcokvz9yrw7uxNvwZqQos=; b=1BlI7QCo6OmEVGaSVh9kbHs/dt04v7OyCeH5qmzxvvbxivHjz6Q89QaCzBoxaeZWDB s+54Fu0+0JgkSJaROSxhIy8GivlxmVr4qvzlIAcrOrjesu1lazzT7ANF6s4pMmcBWDTH zszIhfj6qPlZCU4Syb7a8djmv/5jZFuFL12ws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=G+uec9JlNQvBvkiugu9V5Evcokvz9yrw7uxNvwZqQos=; b=pjAVNmA7qAo0gHchagy9iX/W9NkhVvE1JD09VJyoO5eXjaxGqEybPHvJN1p3CmEedO G/VgzWyl+iIumb9EGZR7xhvqpvwk8P/o3Oob46pBvPFgjEJSOTLhH5xZExYlIPqzIUmb jiD7g5fEYAVS78q+anmAq1/wS3FRaoqa0YPFO8LkpNtC1iC2+/OiqzKYAx7RJAYJ+XWa 4k+Fkjxs2fT99pLVHfPEnY4HerSO44VUYHQrFuS5yFm+HljxZl8j3cC+C9916DwFm3QN 2B60wnAO85hPqRwXVtZfL8CrkZMO8hYGOcHteD18H7E1/t9tFz97whk0xrYNghfm6Qa9 oHGg== X-Gm-Message-State: AO0yUKU5nfpd/DsGm1Xwip5vnxYnCqHJdbE/cvON9CJeAiY7pCXJqJe/ iSWz47EnL36wPdpsgson6G1Lxy7iF+gri9wUErBDIbV/z6033pD/+C6Br24PnyZxQ/ifM9XqTEN VRnTifg7ADsss5lUKLApOy/BIAc8= X-Received: by 2002:a81:b605:0:b0:536:4194:e6eb with SMTP id u5-20020a81b605000000b005364194e6ebmr5273820ywh.0.1677266106654; Fri, 24 Feb 2023 11:15:06 -0800 (PST) X-Google-Smtp-Source: AK7set8xZTekett6mEYB/JtZsrOSwfNxPWBICaDf8rwRumEsIq6O9DAJ5xf/pyLrme32bEeHMdC/5iGJo4XWFh7WpHc= X-Received: by 2002:a81:b605:0:b0:536:4194:e6eb with SMTP id u5-20020a81b605000000b005364194e6ebmr5273814ywh.0.1677266106430; Fri, 24 Feb 2023 11:15:06 -0800 (PST) In-Reply-To: <834jrk1dli.fsf@gnu.org> Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 24 Feb 2023 14:34:52 -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:303756 Archived-At: 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=) 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?