🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #4086

Bug#1153687: rust-blocking: idle threads never exit since 1.7.0 and wake every 500 ms (14 wakeups/s in gnome-shell)

#4086
From: Paul Menzel
Date: Wed, 11 Nov 2026 00:30
120 lines
7265 bytes
This is a multi-part message in MIME format.
--------------AdTbXHuNF2niLDkUo0KANxPr
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Source: rust-blocking
Version: 1.7.0+ds-1
Severity: important
Tags: patch upstream
Forwarded: https://github.com/smol-rs/blocking/issues/83
Control: affects -1 + src:glycin gnome-shell

AI disclaimer: Analyzed and drafted by claude-fable-5.2 and reviewed by me.]

Dear Debian folks,


Since blocking 1.7.0, idle worker threads of the thread pool never exit 
while the pool is below its thread limit (default 500). Each left-over 
thread wakes every 500 ms for ever. As the crate is linked statically, 
this regresses idle power use of every consumer built against 
librust-blocking-dev 1.7.0+ds-1.

Upstream commit 6f41360 ("Support setting the number of threads without 
an env var") changed the exit condition in Executor::main_loop() from

     if res.timed_out() && inner.queue.is_empty() {

to

     if (Some(inner.thread_count) > 
inner.thread_limit.map(NonZeroUsize::get))
         && (res.timed_out() && inner.queue.is_empty())
     {

so a thread that times out with an empty queue only stops when the pool 
is over its limit. Below the limit it returns to wait_timeout(500 ms) in 
a loop. With 1.6.2 it exited after 500 ms.

Impact, seen on a Dell XPS 13 9310 with Debian sid/unstable, gnome-shell 
51.0-3 and libglycin-2-0 2.2.3+ds-1:

Every image load that grows the pool leaves a permanent "blocking-N" 
thread behind in gnome-shell. After some uptime there are seven, each 
with 2 voluntary context switches per second, about 14 wakeups/s in 
total on an idle desktop. All of them time out in the same wait:

     futex(0x7fb2b44977b8, FUTEX_WAIT_BITSET_PRIVATE, 64, {tv_sec=1312, 
tv_nsec=862622780}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT
     futex(0x7fb2b44977b8, FUTEX_WAIT_BITSET_PRIVATE, 64, {tv_sec=1313, 
tv_nsec=363075132}, FUTEX_BITSET_MATCH_ANY) = -1 ETIMEDOUT

The backtrace consists only of the thread entry, main_loop() and 
Condvar::wait_timeout(), so the threads are idle and not running a task. 
gnome-software shows the same left-over thread.

Upstream glycin is not affected, as its Cargo.lock pins blocking 1.6.2. 
The Debian build is, as it uses the packaged 1.7.0.

The attached patch is the main_loop() hunk of the fix proposed upstream 
[1], as a quilt patch with DEP-3 header. A thread now exits when the 
queue is empty and it either timed out or the pool is over the limit.

I built librust-blocking-dev with the patch and rebuilt glycin 2.2.3+ds 
against it (both with DEB_BUILD_OPTIONS=nocheck). After a reboot, 
gnome-shell has no "blocking-*" threads at idle and the whole process is 
at about 1 context switch per second. Tracing thread creation and exit 
while changing the wallpaper shows the pool threads being spawned and 
exiting again:

     spawn blocking-5 in pid 1081
     exit blocking-5 tid 3650 after pid 1081

Besides the upload of rust-blocking, the reverse dependencies linking it 
statically need a rebuild to pick up the fix, at least glycin.


Kind regards,

Paul


[1]: https://github.com/smol-rs/blocking/pull/84
--------------AdTbXHuNF2niLDkUo0KANxPr
Content-Type: text/x-patch; charset=UTF-8; name="blocking-idle-exit.patch"
Content-Disposition: attachment; filename="blocking-idle-exit.patch"
Content-Transfer-Encoding: base64

RGVzY3JpcHRpb246IExldCBpZGxlIHRocmVhZHMgZXhpdCB3aGVuIHVuZGVyIHRoZSB0aHJl
YWQgbGltaXQKIFNpbmNlIDEuNy4wIChjb21taXQgNmY0MTM2MCwgIlN1cHBvcnQgc2V0dGlu
ZyB0aGUgbnVtYmVyIG9mIHRocmVhZHMKIHdpdGhvdXQgYW4gZW52IHZhciIpLCBhbiBpZGxl
IHBvb2wgdGhyZWFkIG9ubHkgZXhpdHMgaWYgdGhlIHBvb2wgaXMKICpvdmVyKiB0aGUgdGhy
ZWFkIGxpbWl0IChkZWZhdWx0IDUwMCkuIElkbGUgdGhyZWFkcyB0aGVyZWZvcmUgbmV2ZXIK
IGV4aXQgYW5kI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gICAgLy8gU3RvcCB0aGlzIHRocmVhZCBpZiB0aGVyZSBpcyBubyB3b3JrIHF1
ZXVlZCBhbmQgaXQgaGFzIGVpdGhlcgorICAgICAgICAgICAgLy8gYmVlbiBpZGxlIGZvciBh
IHdoaWxlLCBvciB0aGVyZSBhcmUgdG9vIG1hbnkgdGhyZWFkcyBpbiB0aGUKKyAgICAgICAg
ICAgIC8vIHBvb2wgKHRoZSB0aHJlYWQgbGltaXQgd2FzIGxvd2VyZWQpLgorICAgICAgICAg
ICAgbGV0IG92ZXJfbGltaXQgPSBpbm5lcgorICAgICAgICAgICAgICAgIC50aHJlYWRfbGlt
aXQKKyAgICAgICAgICAgICAgICAubWFwX29yKGZhbHNlLCB8bGltaXR8IGlubmVyLnRocmVh
ZF9jb3VudCA+IGxpbWl0LmdldCgpKTsKKyAgICAgICAgICAgIGlmIGlubmVyLnF1ZXVlLmlz
X2VtcHR5KCkgJiYgKHJlcy50aW1lZF9vdXQoKSB8fCBvdmVyX2xpbWl0KSB7CiAgICAgICAg
ICAgICAgICAgaW5uZXIuaWRsZV9jb3VudCAtPSAxOwogICAgICAgICAgICAgICAgIGlubmVy
LnRocmVhZF9jb3VudCAtPSAxOwogICAgICAgICAgICAgICAgIGJyZWFrOwo=

--------------AdTbXHuNF2niLDkUo0KANxPr--
Technical Details
Message-ID: <NY4nT-b7qU-1@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.corradoroberto.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.corradoroberto.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod
From: Paul Menzel <pmenzel@molgen.mpg.de>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1153687: rust-blocking: idle threads never exit since 1.7.0 and wake every 500 ms (14 wakeups/s in gnome-shell)
Date: Wed, 11 Nov 2026 01:30:01 +0100
Message-ID: <NY4nT-b7qU-1@gated-at.bofh.it>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Wed Nov 11 00:25:10 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.45
Reply-To: Paul Menzel <pmenzel@molgen.mpg.de>, 1153687@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: dr@jones.dk
X-Debian-Pr-Message: report 1153687
X-Debian-Pr-Package: src:rust-blocking
X-Debian-Pr-Keywords: patch upstream
X-Debian-Pr-Source: rust-blocking
Content-Type: multipart/mixed; boundary="------------AdTbXHuNF2niLDkUo0KANxPr"
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2001946
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 120
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Wed, 11 Nov 2026 01:22:11 +0100
X-Original-Message-ID: <b293be48-7ebd-46bb-9eb7-6d21ddc466dc@molgen.mpg.de>