pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
misc/Codewhale: patch idle task-store rescan CPU spin
Module Name: pkgsrc-wip
Committed By: ci4ic4 <ci4ic4%gmail.com@localhost>
Pushed By: ci4ic4
Date: Sat Oct 3 09:47:46 2026 +0100
Changeset: ad32e30e650bd08af30566a1382ac3aeda109831
Modified Files:
Codewhale/Makefile
Codewhale/distinfo
Added Files:
Codewhale/patches/patch-crates_tui_src_task_manager.rs
Log Message:
misc/Codewhale: patch idle task-store rescan CPU spin
load_state re-parses every historical task file on each 200 ms idle
claim poll, so idle CPU scales with total task bytes. Check queue.json
first and skip the full reload when the queue is empty.
Fixed upstream post-0.10.0 (#6573/#6728); drop this patch at 0.10.1.
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=ad32e30e650bd08af30566a1382ac3aeda109831
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
Codewhale/Makefile | 2 +-
Codewhale/distinfo | 1 +
.../patches/patch-crates_tui_src_task_manager.rs | 45 ++++++++++++++++++++++
3 files changed, 47 insertions(+), 1 deletion(-)
diffs:
diff --git a/Codewhale/Makefile b/Codewhale/Makefile
index 6ed38afe14..92984a00dd 100644
--- a/Codewhale/Makefile
+++ b/Codewhale/Makefile
@@ -13,7 +13,7 @@ LICENSE= mit
WRKSRC= ${WRKDIR}/${DISTNAME}
USE_LANGUAGES= c
-USE_TOOLS+= pkg-config
+USE_TOOLS+= pkg-config patch
# Install both binary crates via separate cargo install invocations
# (cargo install does not accept multiple --path flags).
diff --git a/Codewhale/distinfo b/Codewhale/distinfo
index a9f5c8312f..cf7d575343 100644
--- a/Codewhale/distinfo
+++ b/Codewhale/distinfo
@@ -2028,3 +2028,4 @@ Size (zvariant_derive-4.2.0.crate) = 11057 bytes
BLAKE2s (zvariant_utils-2.1.0.crate) = b142d63425365aedf109bafac551bf52a32897836b938d4835a415a0444db92c
SHA512 (zvariant_utils-2.1.0.crate) = 345b70d1106b37df41426efdb1ba49bf270e00898381c2a8021b5761c59efdea55def45cb2e2598b130b6cba8733503f3997a55578bca90867ab3e8f2346f80e
Size (zvariant_utils-2.1.0.crate) = 7043 bytes
+SHA1 (patch-crates_tui_src_task_manager.rs) = c100a2442c9c0fd39d1df2caec2bb2da836e5a31
diff --git a/Codewhale/patches/patch-crates_tui_src_task_manager.rs b/Codewhale/patches/patch-crates_tui_src_task_manager.rs
new file mode 100644
index 0000000000..fce767ba40
--- /dev/null
+++ b/Codewhale/patches/patch-crates_tui_src_task_manager.rs
@@ -0,0 +1,45 @@
+$NetBSD$
+
+Avoid re-parsing every task file on each idle claim poll. When queue.json
+is empty there is nothing to claim, so check it first and skip the full
+load_state, which reads and serde-parses all historical task files (finished
+or not). Idle CPU previously scaled with total task-store bytes x workers x 5 Hz.
+
+--- crates/tui/src/task_manager.rs.orig
++++ crates/tui/src/task_manager.rs
+@@ -2188,6 +2188,12 @@
+ async fn claim_next_task(&self) -> Result<Option<(String, ExecutionTask, CancellationToken)>> {
+ let mut state = self.state.lock().await;
+ let _transaction = self.lock_store().await?;
++ // Cheap idle-poll fast path: when the queue is empty there is nothing to
++ // claim, so skip the full task-store reload (which re-parses every task
++ // file, finished or not) and return immediately.
++ if self.queue_on_disk_is_empty()? {
++ return Ok(None);
++ }
+ self.refresh_locked(&mut state)?;
+ if self.cancel_token.is_cancelled() {
+ return Ok(None);
+@@ -2969,6 +2975,22 @@
+ sleep(wait).await;
+ wait = (wait * 2).min(Duration::from_millis(50));
+ }
++ }
++
++ /// Whether `queue.json` holds no queued tasks.
++ ///
++ /// The idle claim poll calls this before `refresh_locked` so an empty queue
++ /// skips the full task-store reload. Reading and parsing only `queue.json`
++ /// is O(queue size), not O(all historical task bytes).
++ fn queue_on_disk_is_empty(&self) -> Result<bool> {
++ if !self.queue_path.exists() {
++ return Ok(true);
++ }
++ let content = fs::read_to_string(&self.queue_path)
++ .with_context(|| format!("Failed to read queue file {}", self.queue_path.display()))?;
++ let parsed: QueueFile = serde_json::from_str(&content)
++ .with_context(|| format!("Failed to parse queue file {}", self.queue_path.display()))?;
++ Ok(parsed.queue.is_empty())
+ }
+
+ fn refresh_locked(&self, state: &mut ManagerState) -> Result<()> {
Home |
Main Index |
Thread Index |
Old Index