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

fix(pkg/counter): finish making counter atomic (#3276) #3283

Closed
wants to merge 1 commit into from
Closed

fix(pkg/counter): finish making counter atomic (#3276) #3283

wants to merge 1 commit into from

Conversation

rafaeldtinoco
Copy link
Contributor

Last changes renamed Increment/Decrement to Increase/Decrease. This was reverted after discussions.

With this new approach:

  • Overflow is detected in both cases (and proved by test).
  • Thread safety is guaranteed by atomic Add/Sub operations.
  • Unit tests prove all assumptions and thread safety for all cases.
  • Benchmark tests can be used to test other approaches in the future.
  • Overflow of a sum of all given arguments isn't detected (avoid overhead).

NOTE: The issue is now fully fixed...

Originally, the bug was only about reading counter value in parallel to atomic operation (multiple LOAD/STORE simultaneously, and some not protected by atomics).

Previous fix, made by commit 1e54ce2, fixed data race but overflow errors could be reported more than once. It also had atomic operations for each given argument (if multiple arguments).

This version addresses all concerns.

commit: 0b97409 (main), cherry-pick

Last changes renamed Increment/Decrement to Increase/Decrease. This was
reverted after discussions.

With this new approach:

- Overflow is detected in both cases (and proved by test).
- Thread safety is guaranteed by atomic Add/Sub operations.
- Unit tests prove all assumptions and thread safety for all cases.
- Benchmark tests can be used to test other approaches in the future.
- Overflow of a sum of all given arguments isn't detected (avoid overhead).

NOTE: The issue is now fully fixed...

Originally, the bug was only about reading counter value in parallel to
atomic operation (multiple LOAD/STORE simultaneously, and some not
protected by atomics).

Previous fix, made by commit 1e54ce2, fixed data race but overflow errors
could be reported more than once. It also had atomic operations for each
given argument (if multiple arguments).

This version addresses all concerns.

commit: 0b97409 (main), cherry-pick
@rafaeldtinoco
Copy link
Contributor Author

This was wrongly done to main (its a cherry-pick for v0.16.0).

@rafaeldtinoco rafaeldtinoco deleted the v0.16.0-cherry branch June 28, 2023 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant