Skip to content

Conversation

@orecham
Copy link
Contributor

@orecham orecham commented Nov 29, 2025

Notes for Reviewer

  1. Adds iceoryx2-bb-concurrency crate
  2. Re-exports atomic types from iceoryx2-pal
  3. Renames atomic types to drop the Iox prefix
    1. This change is more of a proposal - can be reverted if not agreed upon
  4. Change upper-layer crates to depend on iceoryx2-bb-concurrency instead of iceoryx2-pal-concurrency-sync
  5. Adds SpinLock to iceoryx2-bb-concurrency and uses it instead of the spin crate

A number of crates in upper layers of the architecture were depending directly on iceoryx2-pal for concurrency primitives, which is not congruent with the defined architecture.

A new crate is added to iceoryx2-bb to re-export required concurrency primitives which are implemented in iceoryx2-pal. Only the primitives required by upper layers are currently re-exported, more can be added as needed.
Some additional concurrency primitives useful to upper layers of iceoryx2 but not required in iceoryx2-pal are also included in this crate.

Pre-Review Checklist for the PR Author

  • Add sensible notes for the reviewer
  • PR title is short, expressive and meaningful
  • Relevant issues are linked in the References section
  • Every source code file has a copyright header with SPDX-License-Identifier: Apache-2.0 OR MIT
  • Branch follows the naming format (iox2-123-introduce-posix-ipc-example)
  • Commits messages are according to this guideline
  • Tests follow the best practice for testing
  • Changelog updated in the unreleased section including API breaking changes
  • Assign PR to reviewer
  • All checks have passed (except task-list-completed)

Checklist for the PR Reviewer

  • Commits are properly organized and messages are according to the guideline
  • Unit tests have been written for new behavior
  • Public API is documented
  • PR title describes the changes

Post-review Checklist for the PR Author

  • All open points are addressed and tracked via issues

References

Closes #1202


macro_rules! zero_copy_send_atomic {
($type_name:ident, $base_type:ident) => {
paste::paste! {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This approach adds a new (compile-time) dependency paste to simplify the code for wrapping atomics in iceoryx2-pal-concurrency-sync in a new type so that iceoryx2-bb traits may be defined on it. If this new dependency is an issue, could potentially manually import all types as aliases for use in the macro instead...

@orecham orecham force-pushed the iox2-1202-re-export-synchronization-primitives-from-pal branch from 44cab38 to b2e7410 Compare November 29, 2025 10:41
@orecham orecham changed the title [#1202] Add concurrency primtiives crate to building blocks [#1202] Add concurrency primitives crate to building blocks Nov 29, 2025
@orecham orecham force-pushed the iox2-1202-re-export-synchronization-primitives-from-pal branch from b2e7410 to 82b0377 Compare November 29, 2025 10:54
@orecham orecham self-assigned this Nov 29, 2025
@codecov
Copy link

codecov bot commented Nov 29, 2025

Codecov Report

❌ Patch coverage is 90.62500% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.46%. Comparing base (e0a0541) to head (7cbc40e).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
iceoryx2-bb/lock-free/src/spsc/index_queue.rs 50.00% 5 Missing ⚠️
iceoryx2-bb/concurrency/src/atomic.rs 75.00% 3 Missing ⚠️
...x2-cal/src/zero_copy_connection/used_chunk_list.rs 70.00% 3 Missing ⚠️
iceoryx2-bb/concurrency/src/spin.rs 94.28% 2 Missing ⚠️
iceoryx2-bb/elementary/src/lazy_singleton.rs 0.00% 2 Missing ⚠️
iceoryx2-bb/log/src/logger/console.rs 0.00% 1 Missing ⚠️
iceoryx2-bb/posix/src/shared_memory.rs 66.66% 1 Missing ⚠️
iceoryx2-pal/concurrency-sync/src/atomic.rs 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1204      +/-   ##
==========================================
+ Coverage   78.39%   78.46%   +0.07%     
==========================================
  Files         411      413       +2     
  Lines       41008    41049      +41     
  Branches     1095     1095              
==========================================
+ Hits        32149    32210      +61     
+ Misses       8026     8006      -20     
  Partials      833      833              
Flag Coverage Δ
CPP 72.80% <ø> (ø)
Rust 78.28% <90.62%> (+0.07%) ⬆️

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

Files with missing lines Coverage Δ
iceoryx2-bb/container/src/flatmap.rs 78.86% <100.00%> (ø)
iceoryx2-bb/container/src/queue.rs 91.44% <100.00%> (ø)
iceoryx2-bb/container/src/slotmap.rs 90.00% <100.00%> (ø)
...ryx2-bb/elementary-traits/src/placement_default.rs 20.37% <ø> (+5.55%) ⬆️
...ceoryx2-bb/elementary-traits/src/zero_copy_send.rs 75.00% <ø> (ø)
iceoryx2-bb/elementary/src/bump_allocator.rs 100.00% <100.00%> (ø)
iceoryx2-bb/elementary/src/cyclic_tagger.rs 100.00% <100.00%> (ø)
iceoryx2-bb/elementary/src/relocatable_ptr.rs 100.00% <100.00%> (ø)
iceoryx2-bb/elementary/src/unique_id.rs 100.00% <ø> (ø)
iceoryx2-bb/linux/src/epoll.rs 71.21% <100.00%> (ø)
... and 53 more

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@orecham orecham force-pushed the iox2-1202-re-export-synchronization-primitives-from-pal branch from 82b0377 to 88a0937 Compare November 29, 2025 11:41
use iceoryx2_bb_elementary_traits::placement_default::PlacementDefault;
use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend;

macro_rules! zero_copy_send_atomic {
Copy link
Contributor

@elfenpiff elfenpiff Nov 29, 2025

Choose a reason for hiding this comment

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

I think this approach is a bit cumbersome and introduces a dependency which we actually do not need. What do you think about the following approach:

  1. iceoryx2-bb-elementary depends directly on iceoryx2-pal-concurrency-sync as the only crate. In there we implement PlacementDefault and ZeroCopySend as it was before.
  2. iceoryx2-bb-concurrency re-exports the iceoryx2-pal-concurrency-sync Atomic**'s with the new namespace iceoryx2-bb-concurrency

With this we get rid of the paste dependency and do it like the Rust lib does it with core and the std re-exports. Also I do not see the benefit of removing the iceoryx2-pal-concurrency-sync dependency in iceoryx2-bb-elementary .

Copy link
Contributor Author

@orecham orecham Dec 1, 2025

Choose a reason for hiding this comment

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

@elfenpiff

Do you mean iceoryx2-bb-elementary-traits instead of iceoryx2-bb-elementary throughout this comment?

I think this approach is a bit cumbersome

If you mean the use of the "new type" wrapper, I can see how this could be undesirable if we need the atomics in iceoryx2-pal and iceoryx2-bb to be recognized as the same type in some instances, but do we have this use-case if we change the upper-layer crates use the iceoryx2-bb version everywhere?

Do we have the same requirement as std and core, where some use crates would like to seamlessly switch between depending on iceoryx2-bb and iceoryx2-pal?

get rid of the paste dependency

If paste is a problem (even though it is compile-time only), it can be removed by just writing some more boilerplate code by hand.

I do not see the benefit of removing the iceoryx2-pal-concurrency-sync dependency in iceoryx2-bb-elementary .

The motivation was to have a less tangled dependency tree. I was aiming to only have one crate in iceoryx2-bb depend on iceoryx2-pal-concurrency-sync.

Copy link
Contributor

@elfenpiff elfenpiff left a comment

Choose a reason for hiding this comment

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

When possible, please use rather this approach: https://github.com/eclipse-iceoryx/iceoryx2/pull/1204/files#r2573007733

paste = { workspace = true }

[dev-dependencies]
iceoryx2-bb-posix = { workspace = true }
Copy link
Contributor

@elfenpiff elfenpiff Nov 29, 2025

Choose a reason for hiding this comment

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

This is a cyclic dependency and cannot be published to crates.io - even when it is a dev-dependency!

Since iceoryx2-bb-posix requires atomics, you must remove this dependency or iceoryx2-bb-posix dependends again on the iceoryx2-pal-concurrency-sync crate.

Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I can see only the spin_tests.rs depends on posix, see use iceoryx2_bb_posix::system_configuration::SystemInfo; It is used to acquire the number of cpu cores to parallelize the tests as much as the hardware allows.

But I think for something simple like a spinlock tests it is maybe a bit overkill and we can hardcode this to always 2 so that the tests use exactly two threads.

With this the dev-dependency to iceoryx2-bb-posix would be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@orecham orecham force-pushed the iox2-1202-re-export-synchronization-primitives-from-pal branch from 8ce0787 to 7cbc40e Compare December 1, 2025 20:16
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.

Export synchronization primitives from iceoryx2-bb

2 participants