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

iox-#2177 Update SPSC SoFi #2214

Merged
merged 8 commits into from
Aug 29, 2024

Conversation

albtam
Copy link
Contributor

@albtam albtam commented Mar 5, 2024

  • add comments to clarify concurrent behavior
  • fix memory orders

Pre-Review Checklist for the PR Author

  1. Add a second reviewer for complex new features or larger refactorings
  2. Code follows the coding style of CONTRIBUTING.md
  3. Tests follow the best practice for testing
  4. Changelog updated in the unreleased section including API breaking changes
  5. Branch follows the naming format (iox-123-this-is-a-branch)
  6. Commits messages are according to this guideline
  7. Update the PR title
    • Follow the same conventions as for commit messages
    • Link to the relevant issue
  8. Relevant issues are linked
  9. Add sensible notes for the reviewer
  10. All checks have passed (except task-list-completed)
  11. All touched (C/C++) source code files from iceoryx_hoofs are added to ./clang-tidy-diff-scans.txt
  12. Assign PR to reviewer

Notes for Reviewer

I updated some memory orders and updated the comments to make sure future contributors understand the changes

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Code according to our coding style and naming conventions
  • Unit tests have been written for new behavior
  • Public API changes are documented via doxygen
  • Copyright owner are updated in the changed files
  • All touched (C/C++) source code files from iceoryx_hoofs have been added to ./clang-tidy-diff-scans.txt
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

References

@albtam
Copy link
Contributor Author

albtam commented Mar 5, 2024

From #2178 (comment)

@elBoberido:

I could make your example pass miri by making both compare and swap loops use either compare_exchange or compare_exchange_weak.
But when increasing the number of pushes a lot it still detects (false positive?) races. The tests also need to be done in a different way, e.g. the cancelation points of the loop become more complex due to the overflow behavior.

Copy link

codecov bot commented Mar 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.21%. Comparing base (a285e98) to head (8e0af98).
Report is 9 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2214      +/-   ##
==========================================
- Coverage   78.22%   78.21%   -0.01%     
==========================================
  Files         433      433              
  Lines       16041    16033       -8     
  Branches     2301     2299       -2     
==========================================
- Hits        12548    12541       -7     
  Misses       2647     2647              
+ Partials      846      845       -1     
Flag Coverage Δ
unittests 78.04% <100.00%> (-0.01%) ⬇️
unittests_timing 15.06% <46.15%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...concurrent/buffer/include/iox/detail/spsc_sofi.hpp 100.00% <ø> (ø)
...concurrent/buffer/include/iox/detail/spsc_sofi.inl 91.83% <100.00%> (+2.36%) ⬆️

... and 1 file with indirect coverage changes

Copy link
Member

@elBoberido elBoberido left a comment

Choose a reason for hiding this comment

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

Sorry for letting you wait so long for the review. I needed a fresh mind to review lock-free code :)

@albtam albtam force-pushed the iox-2177-update-sofi branch from 1892aa0 to 8cc9277 Compare March 20, 2024 23:54
@elBoberido
Copy link
Member

@albtam just to be sure that you are not waiting on feedback. I'll wait until the CI (at least the github actions) are green.

@albtam
Copy link
Contributor Author

albtam commented Mar 27, 2024

@albtam just to be sure that you are not waiting on feedback. I'll wait until the CI (at least the github actions) are green.

@elBoberido Back to you

@albtam
Copy link
Contributor Author

albtam commented Apr 10, 2024

@elBoberido Thanks. I addressed most of your comments. There are still some points to clarify

@elBoberido
Copy link
Member

@albtam you can undo some of my suggestions 😅

Copy link
Member

@elBoberido elBoberido left a comment

Choose a reason for hiding this comment

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

This somehow becomes a never ending story but with the revert of the relaxed ordering in the places where acq_rel was required, we might be able to relax some of the acquire orderings. Unfortunately this is something which is hard to see when there are too many wrong orderings but once the ordering is at least as strong as required, we can identify the locations which definitely need the strong ordering and can try to relax some orderings which act as sync points when we identify new sync points or change the algorithm a bit.

@albtam
Copy link
Contributor Author

albtam commented Apr 23, 2024

I pushed some of your proposals. There is still something unclear. Lock-free is hard :P

Copy link
Member

@elBoberido elBoberido left a comment

Choose a reason for hiding this comment

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

Yes, lock-free is hard 😅

Btw, can you please adjust your commit messages with the issue number.

Before this is merged, it would be good to run test_stress_spsc_sofi. Ideally each of the three test for a few hours. The stress time can only be adjusted in the source code.

@albtam
Copy link
Contributor Author

albtam commented May 1, 2024

@elBoberido I implemented your last recommendations.

@elBoberido
Copy link
Member

@albtam sorry, this totally slipped my attention. The changes look good. Did you have a chance to run the stress tests?
It would also be great if you could run the Miri tests with the current memiry orders.

@elBoberido
Copy link
Member

@albtam did you have the chance to run the stress tests on an aarch64 CPU?

@albtam
Copy link
Contributor Author

albtam commented Aug 24, 2024

@elBoberido Sorry for the delay. I ran the stress tests (on x64 CPU). This test failed SpscSofiStress.SimultaneouslyPushAndPopOnEmptySoFi (both on master and my branch).

I don't have an aarch64 CPU, would it be possible for you to run the tests?

@orecham
Copy link
Contributor

orecham commented Aug 24, 2024

@elBoberido Sorry for the delay. I ran the stress tests (on x64 CPU). This test failed SpscSofiStress.SimultaneouslyPushAndPopOnEmptySoFi (both on master and my branch).

I don't have an aarch64 CPU, would it be possible for you to run the tests?

@albtam I can run it for you on my mac

@elBoberido
Copy link
Member

If it runs without error on the mac, then this can be merged. But before it needs to be rebased. There is now an abstraction for the atomics which leads to a merge conflict. It should be easily solved, though.

@albtam can you post the output of the stress tests. I've run main and your branch and didn't encounter an error.

@albtam albtam force-pushed the iox-2177-update-sofi branch from 04837bb to 081d5f2 Compare August 28, 2024 21:26
@albtam
Copy link
Contributor Author

albtam commented Aug 28, 2024

@elBoberido

Thanks

I've run main and your branch and didn't encounter an error.

I reran them and everything's fine.

I fixed the conflicts. Back to you

@elBoberido
Copy link
Member

@albtam thanks for your contribution :)

@elBoberido elBoberido merged commit 1549c96 into eclipse-iceoryx:main Aug 29, 2024
25 of 26 checks passed
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.

Update SPSCSofi Bug in lock-free sofi Decipher weird comment in SoFi
3 participants