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 #33 efficient named pipes with semaphores #847

Conversation

elfenpiff
Copy link
Contributor

@elfenpiff elfenpiff commented Jun 10, 2021

Pre-Review Checklist for the PR Author

  1. Code follows the coding style of CONTRIBUTING.md
  2. Tests follow the best practice for testing
  3. Branch follows the naming format (iox-#123-this-is-a-branch)
  4. Commits messages are according to this guideline
    • Commit messages have the issue ID (iox-#123 commit text)
    • Commit messages are signed (git commit -s)
    • Commit author matches Eclipse Contributor Agreement (and ECA is signed)
  5. Update the PR title
    • Follow the same conventions as for commit messages
    • Link to the relevant issue
  6. Relevant issues are linked
  7. Add sensible notes for the reviewer
  8. All checks have passed (except task-list-completed)
  9. Assign PR to reviewer

Notes for Reviewer

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
  • PR title describes the changes

Post-review Checklist for the PR Author

  1. All open points are addressed and tracked via issues

References

  • Closes TBD

@elfenpiff elfenpiff self-assigned this Jun 10, 2021
@elfenpiff elfenpiff force-pushed the iox-#33-efficient-named-pipes-with-semaphores branch from e3c82db to 060d645 Compare June 10, 2021 23:42
@codecov
Copy link

codecov bot commented Jun 11, 2021

Codecov Report

Merging #847 (efa2a79) into master (e5e91d5) will decrease coverage by 0.17%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #847      +/-   ##
==========================================
- Coverage   75.10%   74.93%   -0.18%     
==========================================
  Files         332      332              
  Lines       11880    11970      +90     
  Branches     2007     2013       +6     
==========================================
+ Hits         8923     8970      +47     
- Misses       2188     2227      +39     
- Partials      769      773       +4     
Flag Coverage Δ
unittests 73.82% <66.66%> (-0.15%) ⬇️
unittests_timing 30.44% <14.37%> (-0.08%) ⬇️

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

Impacted Files Coverage Δ
...fs/internal/posix_wrapper/shared_memory_object.hpp 66.66% <ø> (ø)
.../posix_wrapper/shared_memory_object/memory_map.cpp 33.98% <0.00%> (-0.68%) ⬇️
...six_wrapper/shared_memory_object/shared_memory.cpp 68.21% <ø> (ø)
...oryx_posh/include/iceoryx_posh/roudi/roudi_app.hpp 40.00% <ø> (ø)
...ceoryx_posh/source/roudi/application/roudi_app.cpp 72.97% <0.00%> (ø)
..._posh/source/roudi/memory/default_roudi_memory.cpp 90.00% <ø> (ø)
iceoryx_hoofs/source/posix_wrapper/named_pipe.cpp 61.37% <59.82%> (-22.41%) ⬇️
...oofs/source/posix_wrapper/shared_memory_object.cpp 83.33% <92.30%> (+13.69%) ⬆️
...ceoryx_hoofs/internal/posix_wrapper/posix_call.inl 100.00% <100.00%> (ø)
iceoryx_hoofs/source/posix_wrapper/semaphore.cpp 68.99% <100.00%> (+5.08%) ⬆️
... and 7 more

… into explicit policy

Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
@elfenpiff elfenpiff force-pushed the iox-#33-efficient-named-pipes-with-semaphores branch from f8765c5 to 36c3c22 Compare June 16, 2021 15:15
@elfenpiff elfenpiff marked this pull request as ready for review June 16, 2021 15:15
Signed-off-by: Christian Eltzschig <me@elchris.org>
@elfenpiff elfenpiff force-pushed the iox-#33-efficient-named-pipes-with-semaphores branch from 9a16aea to 22aece1 Compare June 17, 2021 16:38
Restore cout/cerr/clog flags when changing

Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
…Handle in semaphore

Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
@elfenpiff elfenpiff force-pushed the iox-#33-efficient-named-pipes-with-semaphores branch from 22aece1 to 568a7af Compare June 17, 2021 16:44
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Christian Eltzschig <me@elchris.org>

std::atomic<uint64_t> initializationGuard{INVALID_DATA};
using semaphoreMemory_t = uint8_t[sizeof(Semaphore)];
alignas(alignof(Semaphore)) semaphoreMemory_t semaphores[2U];
Copy link
Member

Choose a reason for hiding this comment

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

alignas(Semaphore) is sufficient.

Wouldn't it make more sense to use two cxx::optional<Semaphore> for this task?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sadly no since I require direct access to uninitialized memory and the optional does not provide me this kind of access.
The semaphore shouldn't be moved and the idea here is to have the memory available and do a placement new with the creation pattern to avoid the move which would come with the standard create.

Copy link
Member

Choose a reason for hiding this comment

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

The list of reason why I don't like this pattern grows. We need to switch to the good old factory method pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@elBoberido but even the factory pattern would be somehow ugly for objects that are neither copyable nor movable.

The user has a place in mind where the object should life and then provides the factory with a pointer to that memory and the arguments.
But the memory handling should be abstracted! Didn't we had the idea for an uninitialized typed array which provides you the raw correctly aligned memory?

This could then be also used as a building block for the list, forward list, vector, optional etc.

Copy link
Member

Choose a reason for hiding this comment

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

You are right. This has the same problem. I thought about expected<Error> whatever(optional<Semaphore>& s, ...) could be added to the semaphore. Or maybe something generic where only an emplace method is expected.

The uninitialized array is quite a low building block and shouldn't be overused. After all, you have to take care of calling the dtor by yourself, take care of the alignment and such stuff. We already have a typed container for uninitialized data which takes care of all of that. It's the optional.

iceoryx_hoofs/source/posix_wrapper/named_pipe.cpp Outdated Show resolved Hide resolved
iceoryx_hoofs/test/moduletests/test_ipc_channel.cpp Outdated Show resolved Hide resolved
Signed-off-by: Christian Eltzschig <me@elchris.org>
@elfenpiff elfenpiff requested a review from elBoberido June 17, 2021 23:44
@elfenpiff elfenpiff merged commit 0912609 into eclipse-iceoryx:master Jun 18, 2021
@elfenpiff elfenpiff deleted the iox-#33-efficient-named-pipes-with-semaphores branch June 18, 2021 17:27
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.

Basic Windows 10 support
3 participants