From patchwork Sun Mar 2 21:30:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Wong X-Patchwork-Id: 39588 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C818327BBEB; Sun, 2 Mar 2025 21:34:48 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 5349A27BBE2 for ; Sun, 2 Mar 2025 21:34:45 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1toqxK-0004sh-7r; Sun, 02 Mar 2025 16:34:38 -0500 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 1toqwG-0003ck-Re for guix-patches@gnu.org; Sun, 02 Mar 2025 16:33:36 -0500 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 1toqwD-0006L5-Bd for guix-patches@gnu.org; Sun, 02 Mar 2025 16:33:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=5OIWr+e5rNTWhYLA7BJ6UF1CUtJZ/8y9YMw1nOIxdCE=; b=NzN8AhAAmrKjd1/w+gY0VYfmFUguZVx0vTA1vmf9vucBfmfq6BPY/pZOmMNMZ4RNEAVrfpUMaYdOKGaCQOV7sE012uUOEI2QfPhQMHHkwUAZfbGpsDQ6I3KQsy94hWMyhnLIa9f3oozKsqefPz6yC7ZmP7u7OCPQUz7NtpoBlqlCJkLZE/ZbQA0zoXfkUQ9TT4KK4oBdy0pTnz1ewtrdYEl25N1pmUKTkz2c6wfXtQUsCnxuWRiLSv3P2+mJlfytiMLidxHn8XSdixnOz8NymlzcRII0mm/sEtNgeDhcoYL61G1H6K12qrB+1A4AYdws4hWbAKFl6MJR0JfLxIdj7A==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1toqwD-0001iw-6l; Sun, 02 Mar 2025 16:33:29 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76513] [PATCH rust-team v3 78/78] gnu: rust-typst-cli: Add bugfix patch. Resent-From: Andrew Wong Original-Sender: "Debbugs-submit" Resent-CC: divya@subvertising.org, efraim@flashner.co.il, guix-patches@gnu.org Resent-Date: Sun, 02 Mar 2025 21:33:29 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76513 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76513@debbugs.gnu.org Cc: Andrew Wong , divya@subvertising.org, efraim@flashner.co.il X-Debbugs-Original-Xcc: divya@subvertising.org, efraim@flashner.co.il Received: via spool by 76513-submit@debbugs.gnu.org id=B76513.17409511986422 (code B ref 76513); Sun, 02 Mar 2025 21:33:29 +0000 Received: (at 76513) by debbugs.gnu.org; 2 Mar 2025 21:33:18 +0000 Received: from localhost ([127.0.0.1]:37552 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1toqw1-0001fC-As for submit@debbugs.gnu.org; Sun, 02 Mar 2025 16:33:18 -0500 Received: from qs51p00im-qukt01080501.me.com ([17.57.155.22]:22361) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1toqvJ-0001Q8-Kh for 76513@debbugs.gnu.org; Sun, 02 Mar 2025 16:32:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; bh=5OIWr+e5rNTWhYLA7BJ6UF1CUtJZ/8y9YMw1nOIxdCE=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=daGnn3Orkqk0pjV+kIScRTEE1LZsH+y3S3D20ox07nSk/MkyYBa2uKYyz1WvjsyVi q0QC8XCbzZOD0Fy/Hn7fwlv2YpB70/BWIgwjK40SlOJesUn0RtRjlwGx0qxIQyWAdn WQNPws+tm1iT7deRjDGPsk14gmeJuo+nnxrvdXQ50xGpLESXBa7vP8wwjvtG4Zewe3 Xcf7jLW9B3e+QiE8dnop6oTN041wWTcYC2cCcqhwCbX/WSWiRx0BLu7awhE+NZbGji aPWO3s5J1gYkjN1QYdJR30kzRnxGHS2jk/XvSR+h946SPVrfCU+yn/FDyMV7GQCFKm kINOlEnK5mwgw== Received: from wongworks.lan (qs51p00im-dlb-asmtp-mailmevip.me.com [17.57.155.28]) by qs51p00im-qukt01080501.me.com (Postfix) with ESMTPSA id 88E0819802E9; Sun, 2 Mar 2025 21:32:27 +0000 (UTC) Date: Sun, 2 Mar 2025 16:30:49 -0500 Message-ID: <6fc6923262a7efb747bce644fd71f0a882f69bad.1740950733.git.wongandj@icloud.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 7qlwMxZbs8gNnzgW_4dpVBHkG5I0xBF- X-Proofpoint-GUID: 7qlwMxZbs8gNnzgW_4dpVBHkG5I0xBF- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-03-02_06,2025-02-28_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 clxscore=1015 adultscore=0 phishscore=0 mlxscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2503020175 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Andrew Wong X-ACL-Warn: , Andrew Wong via Guix-patches X-Patchwork-Original-From: Andrew Wong via Guix-patches via From: Andrew Wong Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/typst.scm (rust-typst-cli)[source]: Add bugfix patch from upstream git. * gnu/packages/patches/rust-typst-cli-fix-high-cpu-usage.patch: New file. Change-Id: If055c0f8136a51f4a3a119b76dc04f5700b2b3e9 --- .../rust-typst-cli-fix-high-cpu-usage.patch | 97 +++++++++++++++++++ gnu/packages/typst.scm | 8 +- 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/rust-typst-cli-fix-high-cpu-usage.patch diff --git a/gnu/packages/patches/rust-typst-cli-fix-high-cpu-usage.patch b/gnu/packages/patches/rust-typst-cli-fix-high-cpu-usage.patch new file mode 100644 index 0000000000..f3f1a88a6a --- /dev/null +++ b/gnu/packages/patches/rust-typst-cli-fix-high-cpu-usage.patch @@ -0,0 +1,97 @@ +From acd3a5b7a5999d22fbf2da488744d564b2f3638e Mon Sep 17 00:00:00 2001 +From: aodenis <45949528+aodenis@users.noreply.github.com> +Date: Tue, 25 Feb 2025 13:41:54 +0100 +Subject: [PATCH] Fix high CPU usage due to inotify watch triggering itself + (#5905) + +Co-authored-by: Laurenz +--- + src/watch.rs | 57 +++++++++++++++++++---------------- + 1 file changed, 31 insertions(+), 26 deletions(-) + +diff --git a/src/watch.rs b/src/watch.rs +index 91132fc3..cc727f0f 100644 +--- a/src/watch.rs ++++ b/src/watch.rs +@@ -204,6 +204,10 @@ impl Watcher { + let event = event + .map_err(|err| eco_format!("failed to watch dependencies ({err})"))?; + ++ if !is_relevant_event_kind(&event.kind) { ++ continue; ++ } ++ + // Workaround for notify-rs' implicit unwatch on remove/rename + // (triggered by some editors when saving files) with the + // inotify backend. By keeping track of the potentially +@@ -224,7 +228,17 @@ impl Watcher { + } + } + +- relevant |= self.is_event_relevant(&event); ++ // Don't recompile because the output file changed. ++ // FIXME: This doesn't work properly for multifile image export. ++ if event ++ .paths ++ .iter() ++ .all(|path| is_same_file(path, &self.output).unwrap_or(false)) ++ { ++ continue; ++ } ++ ++ relevant = true; + } + + // If we found a relevant event or if any of the missing files now +@@ -234,32 +248,23 @@ impl Watcher { + } + } + } ++} + +- /// Whether a watch event is relevant for compilation. +- fn is_event_relevant(&self, event: ¬ify::Event) -> bool { +- // Never recompile because the output file changed. +- if event +- .paths +- .iter() +- .all(|path| is_same_file(path, &self.output).unwrap_or(false)) +- { +- return false; +- } +- +- match &event.kind { +- notify::EventKind::Any => true, +- notify::EventKind::Access(_) => false, +- notify::EventKind::Create(_) => true, +- notify::EventKind::Modify(kind) => match kind { +- notify::event::ModifyKind::Any => true, +- notify::event::ModifyKind::Data(_) => true, +- notify::event::ModifyKind::Metadata(_) => false, +- notify::event::ModifyKind::Name(_) => true, +- notify::event::ModifyKind::Other => false, +- }, +- notify::EventKind::Remove(_) => true, +- notify::EventKind::Other => false, +- } ++/// Whether a kind of watch event is relevant for compilation. ++fn is_relevant_event_kind(kind: ¬ify::EventKind) -> bool { ++ match kind { ++ notify::EventKind::Any => true, ++ notify::EventKind::Access(_) => false, ++ notify::EventKind::Create(_) => true, ++ notify::EventKind::Modify(kind) => match kind { ++ notify::event::ModifyKind::Any => true, ++ notify::event::ModifyKind::Data(_) => true, ++ notify::event::ModifyKind::Metadata(_) => false, ++ notify::event::ModifyKind::Name(_) => true, ++ notify::event::ModifyKind::Other => false, ++ }, ++ notify::EventKind::Remove(_) => true, ++ notify::EventKind::Other => false, + } + } + +-- +2.48.1 + diff --git a/gnu/packages/typst.scm b/gnu/packages/typst.scm index 7deb5ef898..878ee7c433 100644 --- a/gnu/packages/typst.scm +++ b/gnu/packages/typst.scm @@ -101,7 +101,13 @@ (define-public rust-typst-cli (uri (crate-uri "typst-cli" version)) (file-name (string-append name "-" version ".tar.gz")) (sha256 - (base32 "09zfrcc5awycl4906r5qhzfmf9qc2jxb30z0iq7dizqkd6wl900i")))) + (base32 "09zfrcc5awycl4906r5qhzfmf9qc2jxb30z0iq7dizqkd6wl900i")) + (patches + ;; This patch should no longer apply after the next release. + ;; Please remove after its changes are integrated. + ;; (Version at time of writing: 0.13.0) + ;; (See: https://github.com/typst/typst/pull/5905) + (search-patches "rust-typst-cli-fix-high-cpu-usage.patch")))) (build-system cargo-build-system) (arguments `(#:cargo-inputs (("rust-chrono" ,rust-chrono-0.4)