Skip to content

Optimize performance + allocator replacement.#43

Merged
s3rius merged 4 commits intomasterfrom
copilot/optimize-natspy-benchmarks
Mar 27, 2026
Merged

Optimize performance + allocator replacement.#43
s3rius merged 4 commits intomasterfrom
copilot/optimize-natspy-benchmarks

Conversation

@s3rius
Copy link
Copy Markdown
Member

@s3rius s3rius commented Mar 27, 2026

Lots of small changes here and there.

Copilot AI and others added 2 commits March 27, 2026 11:22
1. Rewrite CallbackSubscription: Replace Mutex+timeout polling with
   channel-based unsubscribe signaling and tokio::select!, eliminating
   per-message Mutex lock/unlock and timer creation overhead.

2. Switch nats_session from tokio::sync::RwLock to std::sync::RwLock:
   Clone Client synchronously before entering async futures, removing
   async lock acquisition from the hot path. Also fix flush() which
   incorrectly used write() instead of read().

3. Optimize process_message GIL usage: Combine two GIL acquisitions
   (Message conversion + callback invocation) into a single
   Python::attach call via new Message::from_nats_message method.

Agent-Logs-Url: https://github.com/taskiq-python/natsrpy/sessions/03a654d2-e0e5-4c06-8341-b78656505688

Co-authored-by: s3rius <18153319+s3rius@users.noreply.github.com>
@s3rius s3rius changed the title Optimize performance Optimize performance + allocator replacement. Mar 27, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 90.47619% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.33%. Comparing base (3779c49) to head (7fd11ab).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/nats_cls.rs 86.90% 11 Missing ⚠️
src/subscriptions/callback.rs 80.43% 9 Missing ⚠️
src/subscriptions/iterator.rs 84.78% 7 Missing ⚠️
src/message.rs 86.95% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #43      +/-   ##
==========================================
- Coverage   87.78%   87.33%   -0.45%     
==========================================
  Files          30       30              
  Lines        3013     2993      -20     
==========================================
- Hits         2645     2614      -31     
- Misses        368      379      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copilot AI and others added 2 commits March 27, 2026 17:07
…se buffers (#44)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: s3rius <18153319+s3rius@users.noreply.github.com>
@s3rius s3rius merged commit 6545f18 into master Mar 27, 2026
7 checks passed
@s3rius s3rius deleted the copilot/optimize-natspy-benchmarks branch March 27, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants