From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#48118: 27.1; 28; Only first process receives output with multiple running processes Date: Mon, 24 May 2021 23:05:47 +0200 Message-ID: <86bl8z7sgk.fsf@miha-pc> References: <64c194f9-b984-adaa-d5fd-86aa3ed3833a@daniel-mendler.de> Reply-To: miha@kamnitnik.top Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16957"; mail-complaints-to="usenet@ciao.gmane.io" Cc: mail@daniel-mendler.de, eliz@gnu.org, 48118@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 24 23:01:37 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1llHhf-0004Cz-Os for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 May 2021 23:01:35 +0200 Original-Received: from localhost ([::1]:57164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llHhe-00061j-M8 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 May 2021 17:01:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llHhD-0005z6-EU for bug-gnu-emacs@gnu.org; Mon, 24 May 2021 17:01:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60702) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llHh7-00009R-QP for bug-gnu-emacs@gnu.org; Mon, 24 May 2021 17:01:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1llHh7-0000Gc-OE for bug-gnu-emacs@gnu.org; Mon, 24 May 2021 17:01:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: miha@kamnitnik.top Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 May 2021 21:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48118 X-GNU-PR-Package: emacs Original-Received: via spool by 48118-submit@debbugs.gnu.org id=B48118.1621890031982 (code B ref 48118); Mon, 24 May 2021 21:01:01 +0000 Original-Received: (at 48118) by debbugs.gnu.org; 24 May 2021 21:00:31 +0000 Original-Received: from localhost ([127.0.0.1]:44015 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1llHgd-0000Fl-4A for submit@debbugs.gnu.org; Mon, 24 May 2021 17:00:31 -0400 Original-Received: from kamnitnik.top ([209.250.245.214]:59044 helo=mail.kamnitnik.top) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1llHga-0000Fc-6C for 48118@debbugs.gnu.org; Mon, 24 May 2021 17:00:29 -0400 Original-Received: from localhost (unknown [IPv6:2a00:ee2:e04:9300:b7eb:7ae7:cc56:e0da]) by mail.kamnitnik.top (Postfix) with ESMTPSA id 88E57BBB78; Mon, 24 May 2021 21:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1621890026; bh=Dwhcu+X94gIPJ+1rlfe3KONcsRp8lwDkiURU+b44QW4=; h=From:To:Cc:Subject:In-Reply-To:Date:From; b=VsB4F3oLNhnu1D2CJBVGWKCGzkk9ezprh9og3UE/mW/Nk1TMilVoNfi4OU7s00HuF ItZKGS9nrtrY7CSBgzQjdLJRbnm/mJulWxV/lLWa+bRsn6jiYay+m4/g+SyEywZeI/ NItwVKnKlZcX2HOeLAU2p11ZVh4M3KnwHQ9V/K47A5Phox28L3SfuDwedgef9vLawi 3ph8B8Wwy+Md9ORX7b1rmbrX/BMhdo//WKMq62xg1WwA7UxdfaQU1Vy8WXGxP4kyb8 fb2P4JCspOWyptIsabRaDwgNrRz5a4SCzr8tTe8UcU6fwCBRx7z/podgkmhp0EIMG0 pThNM8tShAb8w== In-Reply-To: <87v981k39m.fsf@gnus.org> (message from Lars Ingebrigtsen on Sun, 02 May 2021 09:23:33 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:207144 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain I propose the following simple patch. It makes output from multiple /bin/yes programs arrive at the same rate and multiple grep processes can run without them seemingly blocking each other. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Try-to-not-prioritise-reading-from-lower-fds.patch Content-Transfer-Encoding: quoted-printable From=2029544585ec07ec180bb13fac9142d3755c597cd9 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Miha=3D20Rihtar=3DC5=3DA1i=3DC4=3D8D?=3D Date: Mon, 24 May 2021 22:46:47 +0200 Subject: [PATCH] Try to not prioritise reading from lower fds * src/process.c (wait_reading_process_output): When looping through fds, continue from where we left off. =2D-- src/process.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/process.c b/src/process.c index 47a2a6f1a3..9c2f328ebc 100644 =2D-- a/src/process.c +++ b/src/process.c @@ -5134,6 +5134,7 @@ wait_reading_process_output (intmax_t time_limit, int= nsecs, int read_kbd, Lisp_Object wait_for_cell, struct Lisp_Process *wait_proc, int just_wait_proc) { + static int last_read_channel =3D -1; int channel, nfds; fd_set Available; fd_set Writeok; @@ -5188,6 +5189,7 @@ wait_reading_process_output (intmax_t time_limit, int= nsecs, int read_kbd, while (1) { bool process_skipped =3D false; + bool wrapped; =20 /* If calling from keyboard input, do not quit since we want to return C-g as an input character. @@ -5722,8 +5724,17 @@ wait_reading_process_output (intmax_t time_limit, in= t nsecs, int read_kbd, d->func (channel, d->data); } =20 =2D for (channel =3D 0; channel <=3D max_desc; channel++) =2D { + for (channel =3D last_read_channel + 1, wrapped =3D false; + !wrapped || (channel <=3D last_read_channel && channel <=3D max_desc); + channel++) + { + if (channel > max_desc) + { + wrapped =3D true; + channel =3D -1; + continue; + } + if (FD_ISSET (channel, &Available) && ((fd_callback_info[channel].flags & (KEYBOARD_FD | PROCESS_FD)) =3D=3D PROCESS_FD)) @@ -5761,6 +5772,7 @@ wait_reading_process_output (intmax_t time_limit, int= nsecs, int read_kbd, don't try to read from any other processes before doing the select again. */ FD_ZERO (&Available); + last_read_channel =3D channel; =20 if (do_display) redisplay_preserve_echo_area (12); =2D-=20 2.31.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmCsFSsTHG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZPxEMEAClRWlM+qdc9krvYul/FhbOa9mKs7ec BsT6MoaV3hA5gAct3IZ+dGbPP8xX6stHTYsoi0DH7TOVbMxKBQK/95C6NYv+d/1E Xocx50O7pmcSUilT+zXvE1JspTpTqGYmfI/+SzSTt9GlAiMBcuEa9dj7qm8Ve44n Lc/DjR12IsioTuBOo7pyLcx/P4QSQjfMyaNkQRgmaXY5o0ofpR30Zlo8JzXty7As nw6rw8MOUvJ1odxPxSCI6NvUy/FKYti9cBYMVoO8Z7GWmbDrsBOrSZ7w8lgELbYg lZdHFD9l2KP7ENAqCW8NiTF8vqn6vXVmkfT+BYwTKPFTosJBd27tVQ3dxIY68snj cR16d8wonlTcmlEzJrrA407ppWMWYc8VWJ+jblQ9xD3F+rBR8LjM2Mu10uwJ91Ej UIS4Kj8Bkv/sdJDH0TZWBrXPn6YcnV2jfPEFe4G5wFOLq9IqOyadfR6eR9bChZTb cvVjus5bKMz+ZU11pr9R3B2ow+vkJ1gWO3+SDjOUaHo39doWcgz2/KAuSgGqD9Je 1m2zbgBaI1lEzQlVUIw2GHjLcXDJJrSOQsevALKuSOvg5K3GRwYNczvhUQEkeCUd k05xC/MBLTOcBwScaMm3tuYr7dxhUG5utiCIt4zp8USeJcpxJYuK6xJZWoR+Zmio LLU7hPnwioM/jA== =IpBR -----END PGP SIGNATURE----- --==-=-=--