Skip to content

fix: avoid deprecated Atomic::fetch_update on rustc 1.99 - #316

Merged
senamakel merged 2 commits into
mainfrom
fix-prefetch-fetch-update-deprecation
Oct 26, 2026
Merged

senamakel merged 2 commits into
mainfrom
fix-prefetch-fetch-update-deprecation

Conversation

@senamakel

@senamakel senamakel commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Rust 1.99 deprecates Atomic::fetch_update (renamed try_update, not stable on MSRV 1.96).

  • WorkerPool::try_acquire: compare_exchange loop with identical semantics; new test concurrent_acquires_never_exceed_the_pool_size.
  • Two test helpers: #[allow(deprecated)] with MSRV comment.

Verified: clippy -D warnings on 1.96.1 and 1.99.1, fmt, doc, nextest 1781/1781.

Summary by CodeRabbit

  • Bug Fixes
    • Improved worker-pool reliability under concurrent requests, ensuring the number of active permits does not exceed the configured pool size.
  • Tests
    • Added coverage for concurrent permit acquisition and confirmed that permits become available again after they are released.

senamakel and others added 2 commits October 26, 2026 11:09
The permit acquisition path now uses an explicit compare_exchange_weak
loop instead of fetch_update, since fetch_update is deprecated in favour
of try_update on newer toolchains but try_update is not stable on this
crate's MSRV. A test covers concurrent acquires to confirm the pool never
grants more permits than its size.

Auto-committed-on: cuttlefish
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Annotate the two `fetch_update` call sites with `#[allow(deprecated)]` and
bind the result to a local, since the replacement `try_update` is not stable
on this crate's MSRV.

Auto-committed-on: cuttlefish
Co-authored-by: Medulla <medulla@tinyhumans.ai>
@tinysweeper

tinysweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

Reviewed head: edb2c23e0c18625ea79d3d142937336e56671817

Verdict: Ready for maintainer review · Priority: none
Coverage: Reviewed 4 of 4 files.
Pull request purpose (title): fix: avoid deprecate…

Diagnostics and supporting details

Full summary

Pull request purpose (title): fix: avoid deprecated Atomic::fetch_update on rustc 1.99. This pull request, titled "fix: avoid deprecated Atomic::fetch_update on rustc 1.99," replaces uses of `Atomic::fetch_update` — deprecated on Rust 1.99 in favor of `try_update`, which is not stable on the crate's MSRV 1.96 — with behavior-equivalent alternatives across the prefetch worker pool and two test helpers, and adds a concurrency test for the worker pool. No trusted push-delta comparison is available, so no push-delta analysis is reported.

Review snapshot

Change surface Files Review signal Count
Production 1 Active findings 0
Tests 3 Noted findings 0
Documentation 0 Resolved findings 0
Configuration 0 Pending checks/questions 0

Completeness: Complete
Test assessment: No supported feature-to-test mapping was available; this does not mean tests are absent or passed.

What changed

`WorkerPool::try_acquire` in crates/tinymemory-tools/src/prefetch/mod.rs now uses a `compare_exchange_weak` loop instead of `fetch_update`, loading `free` with `Acquire`, returning `None` when `checked_sub(1)` fails (pool exhausted), and retrying with the observed value on contention; a grant returns a `Permit` whose `Drop` releases the unit. Two test helpers — the `take_one` decrement helper in crates/tinymemory-integrations/src/cortex/testing/mod.rs and the flaky `ListStore` save counter in crates/tinymemory-tools/src/deletion/mod_tests.rs — keep `fetch_update` but gain `#[allow(deprecated)]` with an MSRV comment. A new test, `concurrent_acquires_never_exceed_the_pool_size`, spawns 16 scoped threads against a pool of 3 and asserts exactly 3 permits are granted and availability returns to 3 after release.

Features

  • Modified — take_one helper deprecation allowance: Keeps the existing fetch_update-based decrement in the cortex testing helper and silences the Rust 1.99 deprecation with an MSRV justification comment; behavior of the counter helper is unchanged. (crates/tinymemory-integrations/src/cortex/testing/mod.rs pub(crate) type Shared = Arc<Double>;)

Tests

No supported feature-to-test mapping was produced. Test execution is not inferred.

Findings

No active actionable findings.

Before merge

None.

Agent review details

critique

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: Reviewed 4 files; 0 findings. _The code index is behind this pull request (indexed at `70e22044385b`), so retrieved context may be out of date._

security

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: Reviewed 4 files; 0 findings. _The code index is behind this pull request (indexed at `70e22044385b`), so retrieved context may be out of date._

tests

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: The prefetch change swaps `fetch_update` for an equivalent `compare_exchange_weak` loop and adds `concurrent_acquires_never_exceed_the_pool_size`, which fails if the bound is broken; the two `take_one`-style `#[allow(deprecated)]` rewrites are behaviour-preserving (the test helper's `failing_saves.fetch_update` path is already exercised by the failing-save tests). The one thing the new test does not cover is the exhaustion path — with the pool at 0 the loop reaches `checked_sub(1)?` and returns `None`, which no test in the diff pins (the existing `no worker was free for b` assertion covers it indirectly through the prefetcher). No defect I can anchor beyond that coverage nit, which I am not raising: the `None` branch is reached by the existing pooled-enqueue test at line 179. _The code index is behind this pull request (indexed at `70e22044385b`), so retrieved context may be out of date._

commits

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: No sensitive content in committed files. _The code index is behind this pull request (indexed at `70e22044385b`), so retrieved context may be out of date._

description

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: The change replaces the deprecated `Atomic::fetch_update` in `WorkerPool::try_acquire` with an equivalent compare_exchange loop and silences the same deprecation in two test helpers, matching the description, and the new test is deterministic and consistent with the existing suite. The prefetch loop preserves the original semantics (`checked_sub(1)?` on a loaded value, retry on contention, permit released by `Drop`), so I found nothing reportable. _The code index is behind this pull request (indexed at `70e22044385b`), so retrieved context may be out of date._
Evidence and run details
  • Models: ladder/vectors-oai3, deepseek-v4.1-flash
  • Spend: $0.000245
  • Tokens: 170709 input · 3615 output · 51712 cached · 181 embedding
  • Updated: 2026-10-26T11:10:44Z
Head State Pass summary
edb2c23e0c18 ready for maintainer review 0 active finding(s), 0 resolved finding(s) (at 2026-10-26T11:10:44Z)

tinysweeper 0.1.2

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T11:11:20.017133Z edb2c23 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2479fe07-eee8-4060-8779-4e24e4cb5e82
Commits

Reviewing files that changed from the base of the PR and between 8b919fd and edb2c23.

Files selected for processing: 4
  • crates/tinymemory-integrations/src/cortex/testing/mod.rs
  • crates/tinymemory-tools/src/deletion/mod_tests.rs
  • crates/tinymemory-tools/src/prefetch/mod.rs
  • crates/tinymemory-tools/src/prefetch/mod_tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The changes add local deprecation allowances to two existing fetch_update calls. WorkerPool::try_acquire now uses a compare-exchange loop, and a concurrency test checks permit acquisition and release.

Changes: Atomic Counter Updates

Layer / File(s) Summary
Retain fetch_update calls
crates/tinymemory-integrations/src/cortex/testing/mod.rs, crates/tinymemory-tools/src/deletion/mod_tests.rs
Both existing fetch_update calls receive local deprecation allowances. The Flaky::save helper stores the update result before checking whether to return its existing error.
Use compare-exchange for worker acquisition
crates/tinymemory-tools/src/prefetch/mod.rs, crates/tinymemory-tools/src/prefetch/mod_tests.rs
WorkerPool::try_acquire retries a weak compare-exchange after contention and returns no permit when the count is zero. A concurrent test checks that a pool of size three grants exactly three permits and restores the count when they are dropped.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: m3ga-mind

Merge Risk: Minimal · up to edb2c

Worker permit limits and recovery remain intact; the change is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix: avoid deprecated Atomic::fetch_update on rustc 1.99" matches the main change. The PR replaces the fetch_update call in WorkerPool::try_acquire with a compare_exchange loop, adds a conc…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix: avoid deprecated Atomic::fetch_update on rustc 1.99" matches the main change. The PR replaces the fetch_update call in WorkerPool::try_acquire with a compare_exchange loop, adds a concurrency test, and silences the deprecation warning at two test-helper call sites. The title names the deprecated API and the compiler version that triggers the warning. It does not mention the new concurrency test, but that test is secondary to the fix.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit counts the workers three,
Then waits for compare-exchange to agree.
Sixteen paws reach for a turn,
Three permits go out, then return.
The counter rests, as calm as can be.

Comment @coderabbitai help to get the list of available commands.

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tinysweeper found nothing blocking. Approving.

Diagnostics

Total spend: $0.0002

@tinysweeper tinysweeper Bot added the priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect. label Oct 26, 2026
@senamakel
senamakel merged commit 523f074 into main Oct 26, 2026
39 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant