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 #489 replace introspection threads with periodic task #490

Conversation

elBoberido
Copy link
Member

@elBoberido elBoberido commented Jan 13, 2021

Pre-Review Checklist for the PR Author

  1. Branch follows the naming format (iox-#123-this-is-a-branch)
  2. 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)
  3. Update the PR title
    • Follow the same conventions as for commit messages
    • Link to the relevant issue
  4. Relevant issues are linked
  5. Add sensible notes for the reviewer
  6. All checks have passed
  7. Assign PR to reviewer

Notes for Reviewer

This PR replaces the thread in the introspection classes with a PeriodicTask and simplifies the code. The test time with the RouDiEnvironment will also be reduced a little bit (1s posh_modultetests and 2s in posh_integrationtests), since the stopping of the threads is not done by a polling with 100ms period.

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

Post-review Checklist for the Eclipse Committer

  1. All checkboxes in the PR checklist are checked or crossed out
  2. Merge

References

Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
…essIntrospection

Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
…Introspection

Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
Copy link
Member

@dkroenke dkroenke left a comment

Choose a reason for hiding this comment

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

Two questions:

  1. Could be the TimeSpecReference in the run() method maybe Monotonic? I think the timeout interval does not depend on the current value of time.

  2. This is maybe for future use: For validation purpose the user maybe wants to know how often the task was executed. A getter method like uint64_t getExecutionCount() could be helpful for tests.

@dkroenke dkroenke added the refactoring Refactor code without adding features label Jan 14, 2021
@elBoberido
Copy link
Member Author

@dkroenke I will have a look if a monotonic clock is possible with the semaphore.

Regarding the uint64_t getExecutionCount(). In tests, you can always add a counter to the function which will be executed. This could be helpful for other situations though. I would consider it as low prio and create an issue for this. This is a good first issue for a new contributor. Do you agree?

@elBoberido
Copy link
Member Author

@dkroenke regarding the monotonic clock, I just checked the the semaphore documentation and an absolute timeout is required, therefore we cannot use a monotonic clock

Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
Copy link
Contributor

@MatthiasKillat MatthiasKillat left a comment

Choose a reason for hiding this comment

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

Improves the sending process of introspection data. I just would consider to use chrono (why would we not use it?) . Tests are missing but this is a draft anyway.

Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
@elBoberido elBoberido marked this pull request as ready for review January 15, 2021 18:00
@elBoberido
Copy link
Member Author

Regarding the uint64_t getExecutionCount(). In tests, you can always add a counter to the function which will be executed. This could be helpful for other situations though. I would consider it as low prio and create an issue for this. This is a good first issue for a new contributor. Do you agree?

done with #502

…oolIntrospection

Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
@dkroenke
Copy link
Member

@elfenpiff 350cb50 has no iox number.

@elfenpiff elfenpiff force-pushed the iox-#489-replace-intropection-threads-with-PeriodicTask branch from 3e1ad66 to 3b495ff Compare January 18, 2021 16:50
@elBoberido elBoberido changed the title Iox #489 replace port and process intropection threads with periodic task Iox #489 replace introspection threads with periodic task Jan 18, 2021

/// @brief copy data fro internal struct into interface struct
void copyMemPoolInfo(const MemoryManager& memoryManager, MemPoolInfoContainer& dest) noexcept;

private:
units::Duration m_sendInterval{units::Duration::seconds<unsigned long long int>(1)};
Copy link
Contributor

Choose a reason for hiding this comment

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

using namespace iox::units::duration_literals will enable you to use the user-defined literal operation 1_s Locally in a class it should not lead to evil namespace polution.

Reminds me of plan to clean up the using namespace in iceoryx_posh_types.hpp 😋

Copy link
Member Author

Choose a reason for hiding this comment

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

that's unfortunately not possible within a class

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, you're right. One thing I saw when checking the coreguidlines. They explicitly exclude using namespace std::units::duration_literals, see. So we might leave them in headers but probably not in iceoryx_posh_types.hpp as this will increase lookup times.

auto elapsedTime{std::chrono::duration_cast<std::chrono::milliseconds>(stop - start)};

EXPECT_THAT(elapsedTime, Ge(SLEEP_TIME));
});
Copy link
Contributor

@mossmaurice mossmaurice Jan 19, 2021

Choose a reason for hiding this comment

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

What about adding a test case that call start() again while the thread/task is still running?

Copy link
Member Author

Choose a reason for hiding this comment

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

that's what PeriodicTaskWhichIsActiveAppliesNewIntervalAfterStart is doing

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, ok you're calling start() indirectly via the other c'tor. That's what I missed. Could we make the user more aware that the behaviour of the two c'tors is very different? One does start the other not. I have the feeling folks will do the same mistake as I in the near future (and my future self, too).

Copy link
Member Author

Choose a reason for hiding this comment

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

Any suggestions? An @attention doxygen tag?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm torn inbetween. What about removing the "automatic start c'tor"? An explicit start call might be simpler for most users.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can do that, but then you have the opposite problem to not forget to start it. I'm also not quite sure about this.

Just as food for thought, how about something like this

class PeriodicTask {
    enum class OnInit {
        STOPPED,
        RUNNING
    }

    PeriodicTask(OnInit onInit, ...)
};

PeriodicTask task{PeriodicTask::OnInit::RUNNING, ...}

It could also be the separator between the actual PeriodicTask args and the variadic args forwarded to the callable and thus help prevent ambiguities.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like your approach, but it might create too much noise. There can be already quite a lot of args. If we leave out the "automatic start c'tor" won't the user notice this right away and then add start?

Copy link
Member Author

@elBoberido elBoberido Jan 20, 2021

Choose a reason for hiding this comment

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

well, I think it will take as much time as when starting immediately and noticing it's not what you wanted. Maybe even longer because noticing that something is not happening might take longer to realize.
Maybe we also need input from others :D

Copy link
Member Author

Choose a reason for hiding this comment

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

added a struct to indicate the automatic or manual start of the task

Comment on lines -24 to -26
#define private public
#define protected public

Copy link
Contributor

Choose a reason for hiding this comment

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

🥳

Copy link
Member Author

Choose a reason for hiding this comment

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

only 5 remaining. Those also need to go the way of the dodo in order to support Windows.

elfenpiff and others added 6 commits January 19, 2021 22:41
…r msvc and mac

Signed-off-by: Christian Eltzschig <me@elchris.org>
Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
…ction tests

Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
dkroenke
dkroenke previously approved these changes Jan 21, 2021
…ction classes

Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
Signed-off-by: Mathias Kraus <mathias.kraus@apex.ai>
@elBoberido
Copy link
Member Author

oh, and could the one of the reviewer please take care to the reviewer task list ;)

@elBoberido elBoberido merged commit 6e5c6dd into eclipse-iceoryx:master Jan 22, 2021
@elBoberido elBoberido deleted the iox-#489-replace-intropection-threads-with-PeriodicTask branch January 22, 2021 14:41
@@ -62,12 +62,12 @@ class PortIntrospection

struct PublisherInfo
{
PublisherInfo() = default;
PublisherInfo() noexcept {};
Copy link
Contributor

@sculpordwarf sculpordwarf Jan 23, 2021

Choose a reason for hiding this comment

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

@elBoberido This will generate a warning in more strict builds:
https://rextester.com/live/WANPI61259
-Weverything

504430806/source.cpp:7:32: warning: extra ';' after member function definition [-Wextra-semi]
    PublisherInfo() noexcept {};
                               ^

Copy link
Member Author

Choose a reason for hiding this comment

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

@sculpordwarf thanks for the hint. I'll fix it with my next PR. I'm wondering why our CI didn't catch it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Refactor code without adding features
Projects
None yet
6 participants