Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make USED_PARALLELISM atomic #1532

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

nathaniel-daniel
Copy link
Contributor

Fixes #1491

This fixes UB with the USED_PARALLELISM variable, rationale described in #1491. Additionally, static mut is difficult to use correctly, to the point where it is likely to be removed in a future edition. Instead, I have replaced the bool with an AtomicBool, which can be used without unsafe.

This approach is superior to #1492, as using a mutex for a bool is wasteful.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Looks good to me! @Narsil WDYT?

@ArthurZucker ArthurZucker requested a review from Narsil June 6, 2024 09:19
@Narsil
Copy link
Collaborator

Narsil commented Jun 6, 2024

Thanks a lot for this !

Much better indeed than the existing code.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Narsil
Copy link
Collaborator

Narsil commented Jun 6, 2024

Let's ignore the clippy lints, I'll tackle them in another PR.

@Narsil Narsil merged commit bfefcf6 into huggingface:main Jun 6, 2024
9 of 12 checks passed
ArthurZucker pushed a commit that referenced this pull request Jun 17, 2024
@nathaniel-daniel nathaniel-daniel deleted the fix-issue-1492 branch August 1, 2024 19:30
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.

Unsound use of unsafe in src/utils/parallelism.rs
4 participants