Skip to content

chore: Adapt ThreadIdManager for MSRV 1.80#91

Open
polarathene wants to merge 2 commits intoAmanieu:masterfrom
polarathene:chore/use-const-binaryheap
Open

chore: Adapt ThreadIdManager for MSRV 1.80#91
polarathene wants to merge 2 commits intoAmanieu:masterfrom
polarathene:chore/use-const-binaryheap

Conversation

@polarathene
Copy link
Copy Markdown
Contributor

@polarathene polarathene commented Jan 10, 2026

UPDATE: There's an alternative that wouldn't bump the MSRV if adding another crate were acceptable.

Alternative details - Collapsed for brevity

The MSRV bump could be avoided if choosing to use the BinaryHeap from the dary_heap crate (with the extras feature for const fn support), that has an MSRV of 1.61 which is already within the MSRV of thread_local:

the code in dary_heap is directly based on that of the standard library.
The BinaryHeap provided by this crate should therefore provide similar performance as that of the standard library

Beyond std::collections::BinaryHeap, the only other std import that couldn't be switched over to core is std::sync::Mutex. Adopting a crate like mcslock or spin for a spin-lock instead of OS Mutex would enable no_std compatibility for thread_local 👍 (granted spin locks aren't ideal, nor is it desired within thread_local if it can be avoided)

#58 also contributed a custom minimal spinlock Mutex that looks to be adaptable to no_std compatibility too.


Change Proposed

This reverts changes from #76 related to workaround BinaryHeap::new() previously lacking const fn support which arrived in Rust 1.80.0.

  • The first commit handles that workaround revert and adapts to an earlier proposal for OnceLock (raising the MSRV to Rust 1.70.0).
  • The 2nd commit then restores the existing static Mutex implementation from Remove once_cell dependency #76 , but raises the MSRV to 1.80.0 where BinaryHeap::new() is const fn compatible.

The two separate commits was for convenience if preferring to be more conservative towards the MSRV bump. Based on the previous MSRV bump, it does seem acceptable to merge this PR without staging it out into separate PRs/releases that incrementally raise the MSRV.

18 month MSRV:

  • Remove once_cell dependency #76 raised the MSRV to Rust 1.63.0 (August 2022) and was merged in April 2024.
  • Rust 1.70.0 (June 2024) 1.80.0 (July 2024) both fall within this acceptable MSRV bump range (or rather will by end of Feb 2026).

NOTE: Probably should delay merging this until #83 has been merged/released?

There is not much incentive for this change beyond simplifying the code a little bit with the const fn support. I have not checked if it makes any meaningful performance difference.

As for concerns raised in #50 (comment)

  • The MSRV was 1.58.0 (Jan 2022) at the time (April 2023), with the 1.63 (Aug 2023) MSRV bump being accepted by Remove once_cell dependency #76 in April 2024.
  • Once chore: release v1.1.10 #83 publishes the 1.10.0 release of this crate, there is presumably low churn that it's fine to raise MSRV (as explained by earlier observations), and that the Cargo resolver supports rust-version since Rust 1.56.0? So those on toolchains of Rust prior to 1.80.0 (July 2024) would still get the 1.10.0 crate release.

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.

1 participant