-
Notifications
You must be signed in to change notification settings - Fork 14
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
pool: Fix unsafe randomizers #643
Merged
Merged
Conversation
This file contains 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
There is no way to access it outside the package anyway. Signed-off-by: Leonard Lyubich <[email protected]>
Impossible to reproduce 100% consistently, but still better to have it. Signed-off-by: Leonard Lyubich <[email protected]>
It is about to change, would be nice to track performance diff. Signed-off-by: Leonard Lyubich <[email protected]>
Previously, pool used `rand.NewSource` which is documented as 'not safe for concurrent use by multiple goroutines'. Since pool is generally accessed from multiple goroutines, it could finish with panic thrown by the mentioned component. Now pool uses safe random generators from the same `math/rand` package. Previous approach is kept for some tests that do not need multi-threading. Benchmark runs show that execution speed has obviously dropped due to sync costs, but it is negligible: ``` goos: linux goarch: amd64 pkg: github.com/nspcc-dev/neofs-sdk-go/pool cpu: Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz │ sec/op │ Sampler-8 37.93n ± 13% │ B/op │ Sampler-8 0.000 ± 0% │ allocs/op │ Sampler-8 0.000 ± 0% ``` Fixes #631. Signed-off-by: Leonard Lyubich <[email protected]>
cthulhu-rider
force-pushed
the
bugfix/631
branch
from
December 4, 2024 16:41
a7a8fe1
to
fd1e188
Compare
cthulhu-rider
force-pushed
the
bugfix/631
branch
3 times, most recently
from
December 4, 2024 18:31
76ec91a
to
fd1e188
Compare
i've ensured that AIO tests fail not due to these changes, so they are gonna be fixed within #644 |
cthulhu-rider
requested review from
roman-khimov,
smallhive and
carpawell
as code owners
December 4, 2024 18:32
roman-khimov
approved these changes
Dec 4, 2024
AliceInHunterland
approved these changes
Dec 4, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, tested with 250k parallel searchers and even a ram of 12 GB was enough for it (before it was crashing).
AliceInHunterland
added a commit
to nspcc-dev/neo-go
that referenced
this pull request
Dec 12, 2024
Update to the version without pool panics https://github .com/nspcc-dev/neofs-sdk-go/pull/643. Signed-off-by: Ekaterina Pavlova <[email protected]>
AliceInHunterland
added a commit
to nspcc-dev/neo-go
that referenced
this pull request
Dec 13, 2024
Update to the version without pool panics nspcc-dev/neofs-sdk-go#643. Signed-off-by: Ekaterina Pavlova <[email protected]>
AliceInHunterland
added a commit
to nspcc-dev/neo-go
that referenced
this pull request
Dec 13, 2024
Update to the version without pool panics nspcc-dev/neofs-sdk-go#643. Signed-off-by: Ekaterina Pavlova <[email protected]>
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.
we can also just mutex the panicking part, safe
rand
functions do the same