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

fix default event port behavior along with FileDescriptorActivity #320

Merged
merged 2 commits into from
May 7, 2020

Conversation

doudou
Copy link
Contributor

@doudou doudou commented May 5, 2020

With the introduction of the work() method, which allowed to
be more precise on what gets called in which condition,
an event port under FileDescriptorActivity would not make
updateHook get called anymore.

This broke the Rock workflow with file descriptor activities.
(Un)fortunately, the effect has been subtle enough to not be
noticed readily. Or people started deploying tasks under the
normal Activity where before it would work with the FDA (I'm
guilty of that).

This is a rather convoluted code path (the characters in the
play are a FileDescriptorActivity 'FDA', ExecutionEngine 'EE'
and a TaskContext 'TC'

  • the port signal calls FDA::trigger()
  • FDA::trigger() wakes-up the FDA loop, which calls EE::work(Trigger)
  • EE::work(Trigger) calls EE::processPortCallbacks but NOT
    EE::processHooks (expected from the work() refactoring)

At that point, we have to remember that TC::addEventPort registers
a port callback that by default calls TC->trigger(). The
comment at that point in the code itself says "default schedules
an updateHook" (which we're indeed expecting with a FDA)

  • so, EE::processPortCallbacks in the end calls TC::trigger
  • which, by default calls FDA::timeout()

Until now, FDA::timeout() was not implemented. This PR implements it.

With the introduction of the work() method, which allowed to
be more precise on what gets called in which condition,
an event port under FileDescriptorActivity would not make
updateHook get called anymore.

This broke the Rock workflow with file descriptor activities.
(Un)fortunately, the effect has been subtle enough to not be
noticed readily. Or people started deploying tasks under the
normal Activity where before it would work with the FDA (I'm
guilty of that).

This is a rather convoluted code path (the characters in the
play are a FileDescriptorActivity 'FDA', ExecutionEngine 'EE'
and a TaskContext 'TC'

- the port signal calls FDA::trigger()
- FDA::trigger() wakes-up the FDA loop, which calls EE::work(Trigger)
- EE::work(Trigger) calls EE::processPortCallbacks but NOT
  EE::processHooks (expected from the work() refactoring)

At that point, we have to remember that TC::addEventPort registers
a port callback that by default calls TC::trigger(). The
comment at that point in the code itself says "default schedules
an updateHook" (which we're indeed expecting with a FDA)

- so, EE::processPortCallbacks in the end calls TC::trigger
- which, by default calls FDA::timeout

And FDA::timeout() was not implemented.
@snrkiwi
Copy link
Contributor

snrkiwi commented May 7, 2020

The first commit has a mix of whitespace fixes, refactoring, and some actual changes. Can you indicate what the actual changes in behavior are? It's hard to pull that out of the noise ...

@doudou
Copy link
Contributor Author

doudou commented May 7, 2020

Until now, FDA::timeout() was not implemented.

This is the change: FDA::timeout is now implemented so that work(Timeout) gets called.

@meyerj
Copy link
Member

meyerj commented May 7, 2020

Unfortunately I don't have time at the moment to check in detail, but please check my existing PR which partially refactored the FileDescriptorActivity implementation in #309. The primary goal was to get rid of the locks in trigger() and breakLoop() and it should not affect the behavior of trigger() with respect to which hooks get triggered.

With your patch FileDescriptorActivity basically becomes a normal non-periodic Activity that can additionally be triggered by file descriptor activities or timeouts. That is not exactly the behavior that I would expect, and I would have assumed that it was not the intention in the original implementation. But of course it is possible, and if you as one of the original authors think that it should be like that, it's fine.

It is correct that FileDescriptorActivity::trigger() and EE::work(Trigger) do not and should not trigger a full update cycle including updateHook(). The activity gets triggered way too often, for example whenever a called operation executed in another TaskContext finished and wants to notify the caller. Also note that TaskCore::trigger() actually calls getActivity()->timeout() in TaskCore.cpp:93 since #91, not getActivity()->trigger(), to not change the semantics of this method or break the API, but the difference is very subtle and not very obvious. Maybe we should have already introduced new, more explicit methods to TaskCore and deprecate TaskCore::trigger() at some point later...

@doudou
Copy link
Contributor Author

doudou commented May 7, 2020

@meyerj thanks for the long explanation. It nicely confirms the data flow I thought was happening, always good.

The original behavior was intentional. This is a major breakage for rock. I did understand the intent of the change to work, and am definitely not contesting that. This is meant to restore pre-work behavior that we rely on.

As for the other pull request ... I'm not sure what you expect me to do with it (except from reviewing it, which I just did)

Copy link
Member

@meyerj meyerj left a comment

Choose a reason for hiding this comment

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

@meyerj thanks for the long explanation. It nicely confirms the data flow I thought was happening, always good.

The original behavior was intentional. This is a major breakage for rock. I did understand the intent of the change to work, and am definitely not contesting that. This is meant to restore pre-work behavior that we rely on.

Okay. I do not see an immediate problem is we still support user triggers with TaskCore::trigger() or FileDescriptorActivity::timeout(), and the unit test makes sense and passes, too.

As for the other pull request ... I'm not sure what you expect me to do with it (except from reviewing it, which I just did)

Yes, exactly. I was not sure anymore whether it would conflict conceptually or maybe already solved your problem in another way. But apparently this is not the case and the small merge conflicts can be resolved easily.

So LGTM!

@doudou doudou merged commit 600102e into orocos-toolchain:master May 7, 2020
@doudou doudou deleted the fix_event_port_and_fda branch May 7, 2020 21:28
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.

3 participants