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.bugs Subject: bug#69241: Fixed patch issues Date: Sat, 09 Mar 2024 10:56:42 +0200 Message-ID: <86msr7ye9h.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37830"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69241@debbugs.gnu.org To: Daniel Pettersson , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 09 09:58:00 2024 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 1risWl-0009d8-Sj for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Mar 2024 09:58:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1risWK-0003cD-Dz; Sat, 09 Mar 2024 03:57:32 -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 1risWI-0003bp-O7 for bug-gnu-emacs@gnu.org; Sat, 09 Mar 2024 03:57:30 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1risWH-00014G-Si for bug-gnu-emacs@gnu.org; Sat, 09 Mar 2024 03:57:30 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1risWo-0003pG-Ch for bug-gnu-emacs@gnu.org; Sat, 09 Mar 2024 03:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Mar 2024 08:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69241 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 69241-submit@debbugs.gnu.org id=B69241.170997465514673 (code B ref 69241); Sat, 09 Mar 2024 08:58:02 +0000 Original-Received: (at 69241) by debbugs.gnu.org; 9 Mar 2024 08:57:35 +0000 Original-Received: from localhost ([127.0.0.1]:60615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1risWN-0003ob-40 for submit@debbugs.gnu.org; Sat, 09 Mar 2024 03:57:35 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41888) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1risWK-0003oJ-SA for 69241@debbugs.gnu.org; Sat, 09 Mar 2024 03:57:33 -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 1risVi-00013f-Rv; Sat, 09 Mar 2024 03:56:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=JL5t2GkyfHn5AenKSL2wXoBcpWfglQSTFqr582x3J2E=; b=D4lafg2/R9e7VpS+zywf 7SWDXOEhfpT9zDPAILtqEBPTiLlFnHhXqive/vkp7J1TbWYNsE+6OPuK3RJFas/CzhADDV8tYZPak xW+r6jAZeA1MBj98oUYSpO+fEoxdMsFrYPLgmSXa92BfKwb0DcXQRfbo+mu0Znx9niZip+axivwEV bHHVxWBa6BUHTBW94l5zY+0b20hm09gMh6qucdXtsb4nDV5OxiaZ5X9sUDD2Tn0kELgyEucqoiMYZ sMgNkPxdWQcw+2mS5UPUc3lMa4mAhOpO6s4Fn//Q+GzbDkyAWOxiyBYq9lTpDPnU5HL1ai2mwCiHV M9m9fNZ4+Kckng==; In-Reply-To: (message from Daniel Pettersson on Wed, 28 Feb 2024 13:22:50 +0100) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:281310 Archived-At: > From: Daniel Pettersson > Date: Wed, 28 Feb 2024 13:22:50 +0100 > > The previous patch included an large regression, where "batch" of > messages where handled as an LIFO. This patch should fix the issue and > also removes the dependency on timer.el internal apis. Which makes it > instead dependent on undocumented behavior that timers of equal time are > executed in LIFO order. Joćo, any comments or suggestions? Should I install this? > >From c4d5ddb9ce5cdb8c283928daf6b166e4ce5a430d Mon Sep 17 00:00:00 2001 > From: Daniel Pettersson > Date: Wed, 28 Feb 2024 13:03:56 +0100 > Subject: [PATCH] Jsonrpc: improve performance of process filter function > > `run-at-time' keeps `timer-list' list sorted by inserting each timer > based on the timer value. This means that `timer--time-less-p' needs is > executed ~ N*N/2 times for each N pending messages. This means that > jsonrpc becomes unusable for connections that generate a lot messages at > the same time. > > * lisp/jsonrpc.el (Version): Bump to 1.0.25 > (jsonrpc--process-filter): Improve performance > --- > lisp/jsonrpc.el | 28 +++++++++++++++++++--------- > 1 file changed, 19 insertions(+), 9 deletions(-) > > diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el > index 14fe0447008..5037d8c5b2b 100644 > --- a/lisp/jsonrpc.el > +++ b/lisp/jsonrpc.el > @@ -4,7 +4,7 @@ > > ;; Author: Joćo Tįvora > ;; Keywords: processes, languages, extensions > -;; Version: 1.0.24 > +;; Version: 1.0.25 > ;; Package-Requires: ((emacs "25.2")) > > ;; This is a GNU ELPA :core package. Avoid functionality that is not > @@ -760,10 +760,11 @@ jsonrpc--process-filter > (setq message > (plist-put message :jsonrpc-json > (buffer-string))) > - (process-put proc 'jsonrpc-mqueue > - (nconc (process-get proc > - 'jsonrpc-mqueue) > - (list message))))) > + ;; Put new messages at the front of the queue, > + ;; this is correct as the order is reversed > + ;; before putting the timers on `timer-list'. > + (push message > + (process-get proc 'jsonrpc-mqueue)))) > (goto-char message-end) > (let ((inhibit-read-only t)) > (delete-region (point-min) (point))) > @@ -782,11 +783,20 @@ jsonrpc--process-filter > ;; non-locally (typically the reply to a request), so do > ;; this all this processing in top-level loops timer. > (cl-loop > + ;; `timer-activate' orders timers by time, which is an > + ;; very expensive operation when jsonrpc-mqueue is large, > + ;; therefore the time object is reused for each timer > + ;; created. > + with time = (current-time) > for msg = (pop (process-get proc 'jsonrpc-mqueue)) while msg > - do (run-at-time 0 nil > - (lambda (m) (with-temp-buffer > - (jsonrpc-connection-receive conn m))) > - msg))))))) > + do (let ((timer (timer-create))) > + (timer-set-time timer time) > + (timer-set-function timer > + (lambda (conn msg) > + (with-temp-buffer > + (jsonrpc-connection-receive conn msg))) > + (list conn msg)) > + (timer-activate timer)))))))) > > (defun jsonrpc--remove (conn id &optional deferred-spec) > "Cancel CONN's continuations for ID, including its timer, if it exists. > -- > 2.39.3 (Apple Git-145) >