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#75342: [PATCH] Speed up asynchronous man page fontifying Date: Sat, 04 Jan 2025 10:27:29 +0200 Message-ID: <86bjwnf0ge.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39047"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 75342@debbugs.gnu.org, juri@linkov.net To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 04 09:28:17 2025 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 1tTzW4-0009z4-TB for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 Jan 2025 09:28:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTzVt-00085f-2K; Sat, 04 Jan 2025 03:28:05 -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 1tTzVq-000856-R8 for bug-gnu-emacs@gnu.org; Sat, 04 Jan 2025 03:28:02 -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 1tTzVq-0002Ts-Ia for bug-gnu-emacs@gnu.org; Sat, 04 Jan 2025 03:28:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=yIO6s1cb2/12Mx3mQ5++xvBdVhtqE8pPjiyVApV3mI4=; b=oV7fsB+QXb8X6ZyWTOAdzGC+xBkJAkMvTcMSp0zXzUDBtYKiVT+d2Ovrk0cXUIbS/mpy4x/6WTQDdrIV63/ZnTJUeGNogFDpqIpWR+J9IQq/PrbMfhVsqDbo7pFkRpFANd0/geuwYCcyWmu/tAL15lWD+9g8r33nBFB6PmtQJsxJKSwbu3bUIHPoJJQlZ5+51KOaQLLy0dGNwSYaJSjbL2tv0gMnLCl9dgK56HS8Q4IDlW41BgXAA5JgYo4mLYiBKlCVGVgKJLFntfY/h0ug0bzplz1tD+RiJV6MmOZTkHuAJcBdWJzQhoU9p9WUcV4MJjDS97iOwZSbk3fiZvQw6Q==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tTzVq-0002Vl-9z for bug-gnu-emacs@gnu.org; Sat, 04 Jan 2025 03:28: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, 04 Jan 2025 08:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75342 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 75342-submit@debbugs.gnu.org id=B75342.17359792589617 (code B ref 75342); Sat, 04 Jan 2025 08:28:02 +0000 Original-Received: (at 75342) by debbugs.gnu.org; 4 Jan 2025 08:27:38 +0000 Original-Received: from localhost ([127.0.0.1]:53297 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tTzVR-0002V2-GD for submit@debbugs.gnu.org; Sat, 04 Jan 2025 03:27:37 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49126) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tTzVP-0002Up-Rt for 75342@debbugs.gnu.org; Sat, 04 Jan 2025 03:27:36 -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 1tTzVK-0001NB-AY; Sat, 04 Jan 2025 03:27:30 -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=yIO6s1cb2/12Mx3mQ5++xvBdVhtqE8pPjiyVApV3mI4=; b=otDoC5MT7H5Y 9Hq5JzmyH+teREXg4/G7ZWUXnFe9BrAdHL4hXYArwiO35fShOJeD8RVVbzDjcvIcf+o+sSV2rbsHZ JDcJ5tPaOIqtMofw+yjF/3OPNr/GImPtx/pX5ouJDyPZNoso6DdlomQxXGMJUZuQnuWtkcbj6O5Fu G+BxXxodVHs3MN1/kqNvTtQLlCE9lxmxKHCjBNykgPeAkX0AgolFOU2ee6hH2L+ukhjKp+Ky5fqkL jAIynx/hBHr5Om63XPdcentxsSAthXbncneM1wSoQBVaEfjFPABcfqsF9KyTY4hhQD05xUnNUSJOk efsMjpE6LhGx5O3KLCU5aQ==; In-Reply-To: (message from Stefan Kangas on Sat, 4 Jan 2025 01:22:03 -0600) 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:298341 Archived-At: > Cc: Juri Linkov > From: Stefan Kangas > Date: Sat, 4 Jan 2025 01:22:03 -0600 > > We seem to call `man--maybe-fontify-manpage` many times on very small > chunks: on my machine, it processes ~30 characters at a time. Things > get substantially faster if we make `Man-bgproc-filter` fontify the > buffer in much larger chunks. The main drawback of doing this is that > we risk very briefly seeing an incorrect display flash by in the man > buffer (e.g., with `end-of-buffer`). Man-bgproc-filter also affects how we process sections of the man page, see bug#36927. Wouldn't larger chunks increase the probability of making an error there? > My measurements show that 32 KiB might be a good choice, and gives a > ~95% speedup: > > | Chunk size (KiB) | Completion time (s) | > |------------------+---------------------| > | 4 | 29.3 | > | 8 | 18.2 | > | 16 | 12.7 | > | 32 | 7.4 | > | 64 | 6.5 | > | 128 | 5.4 | > > Is this the best approach to optimize something like this, or am I > overlooking something obvious? Note that I didn't add a variable for > the chunk size, but we could easily add one, if that'd be useful. > > When I set `Man-prefer-synchronous-call` to t, it takes ~1.8 seconds to > process the same page. I guess that this is the lower bound for how > fast we could make the asynchronous call. Why not make Man-prefer-synchronous-call t by default, then?