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: Tue, 25 May 2021 17:18:22 +0200 Message-ID: <868s427sg1.fsf@miha-pc> References: <86bl8z7sgk.fsf@miha-pc> <83im37cac6.fsf@gnu.org> Reply-To: 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="33617"; mail-complaints-to="usenet@ciao.gmane.io" Cc: mail@daniel-mendler.de, larsi@gnus.org, 48118@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 25 18:34:32 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 1lla0l-0008Wt-DH for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 25 May 2021 18:34:32 +0200 Original-Received: from localhost ([::1]:45924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lla0k-0008UO-ER for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 25 May 2021 12:34:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llYks-0002U9-IN for bug-gnu-emacs@gnu.org; Tue, 25 May 2021 11:14:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35015) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1llYks-0002S6-Aq for bug-gnu-emacs@gnu.org; Tue, 25 May 2021 11:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1llYks-0001Ac-5b for bug-gnu-emacs@gnu.org; Tue, 25 May 2021 11:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 25 May 2021 15:14:02 +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.16219555954432 (code B ref 48118); Tue, 25 May 2021 15:14:02 +0000 Original-Received: (at 48118) by debbugs.gnu.org; 25 May 2021 15:13:15 +0000 Original-Received: from localhost ([127.0.0.1]:46561 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1llYjy-00019H-Gw for submit@debbugs.gnu.org; Tue, 25 May 2021 11:13:15 -0400 Original-Received: from kamnitnik.top ([209.250.245.214]:34050 helo=mail.kamnitnik.top) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1llYjt-00018p-SM for 48118@debbugs.gnu.org; Tue, 25 May 2021 11:13:04 -0400 Original-Received: from localhost (unknown [IPv6:2a00:ee2:e04:9300:b7eb:7ae7:cc56:e0da]) by mail.kamnitnik.top (Postfix) with ESMTPSA id C742FBBB83; Tue, 25 May 2021 15:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1621955579; bh=peVTDNVmfaOPe5JBpKEknFj+BIjBx4AraA07k+nS+1A=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=UVuHFVQ4ks/NJwWpp9Hc1ekMqe03JoYr5GYRnJEgykPTQHeENyIWT/MrhKvvMEy1a d66njW5G0eRv1vh1Fa7XUQ19z6pxZDuGnOION2yg91RP9yGq3Pig7xYY2idVzN4I7A 4tJx468/NMFJCzguLixNp+kW/LwwneH61lbnRRwwO1cVB2oC3zQxfU1S1cvMUdsAv5 66HZaYkuou1MTAQ5V9tVqrNtWP5b1lbmW0NkhI6pyZCQim+/E84XiJxqcXY76rmXC4 Khv3SGT/QioSsJRdzENlmxdHvJF01LW7Qt9zEmvJCtGhGQ0fRS51+Hn25dpg8/vwsC DuFtaoWwH/7KA== In-Reply-To: <83im37cac6.fsf@gnu.org> 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:207221 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> From: miha@kamnitnik.top >> Cc: mail@daniel-mendler.de, eliz@gnu.org, 48118@debbugs.gnu.org >> Date: Mon, 24 May 2021 23:05:47 +0200 >>=20 >> 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. > > Thanks, but I don't think we can make such changes unconditionally. > I'm okay with trying this by default, but we should have a Lisp > variable that would allow to get back to the old behavior. That's > because if some user complains about some problems, and we think the > problems are caused by this change, we could tell that user to flip > the variable and see if the problems go away. > > That variable should also be in NEWS. Revised patch. --=-=-= 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=2077fb8097f2ed20f034230a5c61dee00880bbcd24 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. (syms_of_process): Vprocess_prioritize_lower_fds: New variable =2D-- etc/NEWS | 7 +++++++ src/process.c | 27 +++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 1541b74a3b..cc767c8dc2 100644 =2D-- a/etc/NEWS +++ b/etc/NEWS @@ -2706,6 +2706,13 @@ the Emacs Lisp reference manual for background. * Lisp Changes in Emacs 28.1 =20 +++ +** New variable 'process-prioritize-lower-fds' +When looping through file descriptors to handle subprocess output, try +to continue from where the previous loop left off instead of always +beginning from file descriptor zero. Set this variable to t to get +the old behaviour. + +--- ** New function 'sxhash-equal-including-properties'. This is identical to 'sxhash-equal' but accounting also for string properties. diff --git a/src/process.c b/src/process.c index 47a2a6f1a3..7bf55c203e 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,8 @@ wait_reading_process_output (intmax_t time_limit, int= nsecs, int read_kbd, while (1) { bool process_skipped =3D false; + bool wrapped; + int channel_start; =20 /* If calling from keyboard input, do not quit since we want to return C-g as an input character. @@ -5722,8 +5725,20 @@ 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 { + channel_start + =3D !NILP (Vprocess_prioritize_lower_fds) ? 0 : last_read_channel + 1; + + for (channel =3D channel_start, wrapped =3D false; + !wrapped || (channel < channel_start && 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 +5776,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); @@ -8477,6 +8493,13 @@ syms_of_process (void) The variable takes effect when `start-process' is called. */); Vprocess_adaptive_read_buffering =3D Qt; =20 + DEFVAR_LISP ("process-prioritize-lower-fds", Vprocess_prioritize_lower_f= ds, + doc: /* If nil, try to not prioritize reading from any process. +Emacs loops through file descriptors to receive data from subprocesses. A= fter +accepting output from the first file descriptor with available data, resta= rt the +loop from the file descriptor 0 if this option is non-nil. */); + Vprocess_prioritize_lower_fds =3D Qnil; + DEFVAR_LISP ("interrupt-process-functions", Vinterrupt_process_functions, doc: /* List of functions to be called for `interrupt-process'. The arguments of the functions are the same as for `interrupt-process'. =2D-=20 2.31.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmCtFT4THG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZP+wPEAC2xizoCIuatCksnIEjEp5NP6BT5wbY Sl6TIo8Qs8qAjpFuHlxOZMlgFpIWUQcOzZy3cF7VZ5WhaM5XQTAAQ416IQUmWNAQ QlZ6HxVDIBWL/IoR8oLP9TVSrTX2mWvUxXBXX2u3tuqfbRLx5lOPWHRMkkpd3jLU NiIPYw5xxB44xeOO57jdz+od3iffnIOwv869VH+9B2svL1AfLjRHWLbxV3jLYae1 34DVhANQ9XN3RTf8SkxcXmGiFSwPz4hjPuCRXXV7Vk3RFNAlCB2CvIKyClQspFEQ /qj1MDiJzdshnf5Sp84OjNzBbKvePIdCiyaQUkPjSgUA6D4T03oHjiKKIIwK3iv5 VmwyPALqcGAAlpXe4OmmYQ4VSlyFTLyFBAAc63IpgNvMmgoms3+sdTGe3N+Z75/N f0ieQbxpNnNKhYz21cT7DDl5nvywejnNI62qVHjd7XO9meRVjQOYwhxr5GexslUC po/qQh9RSXhhNZc4+qSSUorR/5yI+gVkMk2xdG5Ieu36mk9dUqkxDnbZL6628mcb tjT9Lp0hBZOPquOj4pDjYZ54uEfQgYwK7ZuUy9gtwktP5nvuR1XlwyjMPkPD22Se W/s+3wyo5Ei7ENwoloBmBkDMkI3s+QEyNisJ0DT07n04t5/0qAr7tXcwe1Wyomqb GeVciukGotwETw== =eL8Q -----END PGP SIGNATURE----- --==-=-=--