eclipse-iceoryx / iceoryx2

Eclipse iceoryx2™ - true zero-copy inter-process-communication in pure Rust
https://iceoryx.io
Apache License 2.0
1.03k stars 40 forks source link

[#504] slotmap #505

Closed elfenpiff closed 2 days ago

elfenpiff commented 2 weeks ago

Notes for Reviewer

The SlotMap is required to store multiple data segments and fixed indices so that the senders and receivers of a shared memory communication can manage them (add/remove at runtime). When a sender runs out of memory a new data segment is added at the same index by every participant and this index is part of the memory offset the sender delivers to the receiver via the zero copy channel.

The RelocatableContainer concept had to be cleaned up a bit in order to implement the SlotMap.

Example: details::MetaQueue (implementation). Queue (runtime fixed-size heap version), ReloctableQueue (runtime fixed-size shared memory version), FixedSizeQueue (compile-time fixed-size shared memory version)

The ReloctableContainer trait contained a new() method where a relative position to the memory had to be provided. This was removed since it was too error prone to use. The BumpAllocator in combination with the already existing new_uninit + init(allocator) approach was used to replace it. This is relevant for all FixedSize** versions.

Since Rust does not allow any compile time const operations we could not use in the fixed size version pre-allocated memory in the form of

struct FixedSizeVersion<const CAPACITY: usize> {
  state: RelocatableVersion,
  memory: [u8; RelocatableVersion::const_memory_size(CAPACITY)], // not supported
}

To make the code somehow readable, the actual payload members where listed after the RelocatableVersion in the struct definition.

Also, the RelocatableVec had to be refactored to follow the details::MetaVec, Vec, RelocatableVec, FixedSizeVec pattern so that it could be used in the implementation of the SlotMap.

Pre-Review Checklist for the PR Author

  1. [x] Add sensible notes for the reviewer
  2. [x] PR title is short, expressive and meaningful
  3. [x] Relevant issues are linked in the References section
  4. [x] Every source code file has a copyright header with SPDX-License-Identifier: Apache-2.0 OR MIT
  5. [x] Branch follows the naming format (iox2-123-introduce-posix-ipc-example)
  6. [x] Commits messages are according to this guideline
    • [x] Commit messages have the issue ID ([#123] Add posix ipc example)
    • [x] Commit author matches Eclipse Contributor Agreement (and ECA is signed)
  7. [x] Tests follow the best practice for testing
  8. [x] Changelog updated in the unreleased section including API breaking changes
  9. [x] Assign PR to reviewer
  10. [x] All checks have passed (except task-list-completed)

Checklist for the PR Reviewer

Post-review Checklist for the PR Author

  1. [x] All open points are addressed and tracked via issues

References

Closes #504

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 81.65007% with 129 lines in your changes missing coverage. Please review.

Project coverage is 79.08%. Comparing base (810fb87) to head (a5f1e64). Report is 29 commits behind head on main.

Files with missing lines Patch % Lines
iceoryx2-bb/container/src/slotmap.rs 77.08% 77 Missing :warning:
iceoryx2-bb/container/src/vec.rs 77.63% 51 Missing :warning:
iceoryx2-bb/container/src/queue.rs 96.55% 1 Missing :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505/graphs/tree.svg?width=650&height=150&src=pr&token=FN3YFXTJCI&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx)](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx) ```diff @@ Coverage Diff @@ ## main #505 +/- ## ========================================== - Coverage 79.22% 79.08% -0.14% ========================================== Files 200 201 +1 Lines 23765 24139 +374 ========================================== + Hits 18828 19091 +263 - Misses 4937 5048 +111 ``` | [Files with missing lines](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx) | Coverage Δ | | |---|---|---| | [iceoryx2-bb/elementary/src/bump\_allocator.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?src=pr&el=tree&filepath=iceoryx2-bb%2Felementary%2Fsrc%2Fbump_allocator.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItYmIvZWxlbWVudGFyeS9zcmMvYnVtcF9hbGxvY2F0b3IucnM=) | `86.36% <ø> (ø)` | | | [iceoryx2-bb/elementary/src/owning\_pointer.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?src=pr&el=tree&filepath=iceoryx2-bb%2Felementary%2Fsrc%2Fowning_pointer.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItYmIvZWxlbWVudGFyeS9zcmMvb3duaW5nX3BvaW50ZXIucnM=) | `96.00% <ø> (ø)` | | | [iceoryx2-bb/elementary/src/relocatable\_ptr.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?src=pr&el=tree&filepath=iceoryx2-bb%2Felementary%2Fsrc%2Frelocatable_ptr.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItYmIvZWxlbWVudGFyeS9zcmMvcmVsb2NhdGFibGVfcHRyLnJz) | `100.00% <ø> (ø)` | | | [iceoryx2-bb/lock-free/src/mpmc/bit\_set.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?src=pr&el=tree&filepath=iceoryx2-bb%2Flock-free%2Fsrc%2Fmpmc%2Fbit_set.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItYmIvbG9jay1mcmVlL3NyYy9tcG1jL2JpdF9zZXQucnM=) | `95.23% <100.00%> (-0.14%)` | :arrow_down: | | [iceoryx2-bb/lock-free/src/mpmc/container.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?src=pr&el=tree&filepath=iceoryx2-bb%2Flock-free%2Fsrc%2Fmpmc%2Fcontainer.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItYmIvbG9jay1mcmVlL3NyYy9tcG1jL2NvbnRhaW5lci5ycw==) | `96.38% <100.00%> (-0.28%)` | :arrow_down: | | [iceoryx2-bb/lock-free/src/mpmc/unique\_index\_set.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?src=pr&el=tree&filepath=iceoryx2-bb%2Flock-free%2Fsrc%2Fmpmc%2Funique_index_set.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItYmIvbG9jay1mcmVlL3NyYy9tcG1jL3VuaXF1ZV9pbmRleF9zZXQucnM=) | `92.96% <100.00%> (-0.30%)` | :arrow_down: | | [iceoryx2-bb/lock-free/src/spsc/index\_queue.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?src=pr&el=tree&filepath=iceoryx2-bb%2Flock-free%2Fsrc%2Fspsc%2Findex_queue.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItYmIvbG9jay1mcmVlL3NyYy9zcHNjL2luZGV4X3F1ZXVlLnJz) | `86.50% <100.00%> (-0.46%)` | :arrow_down: | | [...ck-free/src/spsc/safely\_overflowing\_index\_queue.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?src=pr&el=tree&filepath=iceoryx2-bb%2Flock-free%2Fsrc%2Fspsc%2Fsafely_overflowing_index_queue.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItYmIvbG9jay1mcmVlL3NyYy9zcHNjL3NhZmVseV9vdmVyZmxvd2luZ19pbmRleF9xdWV1ZS5ycw==) | `94.61% <100.00%> (-0.19%)` | :arrow_down: | | [iceoryx2-bb/memory/src/pool\_allocator.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?src=pr&el=tree&filepath=iceoryx2-bb%2Fmemory%2Fsrc%2Fpool_allocator.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItYmIvbWVtb3J5L3NyYy9wb29sX2FsbG9jYXRvci5ycw==) | `94.80% <100.00%> (+0.23%)` | :arrow_up: | | [iceoryx2-cal/src/shared\_memory/common.rs](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?src=pr&el=tree&filepath=iceoryx2-cal%2Fsrc%2Fshared_memory%2Fcommon.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx#diff-aWNlb3J5eDItY2FsL3NyYy9zaGFyZWRfbWVtb3J5L2NvbW1vbi5ycw==) | `86.38% <100.00%> (ø)` | | | ... and [10 more](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx) | | ... and [5 files with indirect coverage changes](https://app.codecov.io/gh/eclipse-iceoryx/iceoryx2/pull/505/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse-iceoryx)

🚨 Try these New Features: