Conversation
The `judge_single_signature` function performs CPU-intensive work: parsing GPG public keys from a keyring, parsing OpenPGP packets from the signature blob, and running cryptographic signature verification. When called directly from the async `simple_signing_allows_image` function this work runs on the async executor thread and can starve the event loop. Dispatch each verification call through `tokio::task::spawn_blocking` so the blocking work runs on a dedicated thread pool thread. To make the captured data `Send + 'static` add `Clone` to `Image` (all fields already implement `Clone`) and `PolicyReqMatchType` (enum of plain string variants).
Copilot
AI
changed the title
[WIP] Isolate longer synchronous code blocks in async contexts
simple: dispatch OpenPGP signature verification to blocking thread pool
Jul 15, 2026
mkulke
marked this pull request as ready for review
July 15, 2026 11:30
mkulke
approved these changes
Jul 15, 2026
There was a problem hiding this comment.
Pull request overview
This PR moves CPU-intensive OpenPGP signature verification (judge_single_signature) off Tokio async executor threads by dispatching it to tokio::task::spawn_blocking, preventing potential event-loop starvation during image signature policy checks.
Changes:
- Wrap each
judge_single_signatureinvocation intokio::task::spawn_blockingwithinsimple_signing_allows_image. - Derive
CloneforImageso it can be moved into blocking tasks. - Derive
CloneforPolicyReqMatchTypeso policy parameters can be moved into blocking tasks.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| image-rs/src/signature/policy/simple/mod.rs | Offloads OpenPGP signature verification to Tokio’s blocking thread pool. |
| image-rs/src/signature/policy/ref_match.rs | Adds Clone for PolicyReqMatchType to support moving policy data into blocking tasks. |
| image-rs/src/signature/image/mod.rs | Adds Clone for Image to support moving image data into blocking tasks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+93
to
+96
| for sig in sigs { | ||
| let image = image.clone(); | ||
| let signed_identity = parameters.signed_identity.clone(); | ||
| let pubkey_ring = pubkey_ring.clone(); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Magnus Kulke <mkulke@gmail.com>
Xynnn007
approved these changes
Jul 16, 2026
Member
|
@mkulke looks like the dco is wrong. Do you know how to handle this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Calling CPU-intensive synchronous code directly on an async executor thread risks starving the event loop. The
judge_single_signaturefunction — which parses GPG keyrings, decodes and decompresses OpenPGP packet streams, and runs cryptographic verification — was called inline from the asyncsimple_signing_allows_image.Changes
image/mod.rs— DeriveCloneforImage(all fields alreadyClone)policy/ref_match.rs— DeriveCloneforPolicyReqMatchType(string-only enum variants)policy/simple/mod.rs— Wrap eachjudge_single_signaturecall intokio::task::spawn_blocking, cloning the necessary data into the closure:Follows the existing
spawn_blockingpattern already used inpull.rsfor decryption key derivation.