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

Speed up local action execution #3017

Merged
merged 1 commit into from Nov 22, 2017
Merged

Speed up local action execution #3017

merged 1 commit into from Nov 22, 2017

Conversation

hkaiser
Copy link
Member

@hkaiser hkaiser commented Nov 20, 2017

  • this patch significantly speeds up local action execution (both,
    direct and non-direct) by avoiding to construct a (remote) promise
    but instead directly scheduling the function bound to the action
    as a local thread, while using a simple (local-only) future.
  • direct actions are executed by directly invoking the function bound to
    the function

Copy link
Member

@sithhell sithhell left a comment

Choose a reason for hiding this comment

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

Overall good catch! Please see the comment about keep_alive

future<Result> f = make_ready_future(
get_remote_result_type::call(std::move(result)));

return keep_alive(std::move(f), id);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to keep the id alive here. The future is already done and the handler will be called immediately having no effect at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added this to maintain semantic compatibility with the old code. A user may rely on the id being kept alive until the value was extracted from the future.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, in which scenario would that be the case? Originally, the keep alive was there to ensure that the component stays alive until the result is delivered. In the case where have a local synchronous invocation, this holds true. In addition, the handler is called immediately with the id_type refcounter being decremented.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I concur.

action_type::execute_function(
addr.address_, addr.type_, std::forward<Ts>(vs)...);

return keep_alive(make_ready_future(), id);
Copy link
Member

Choose a reason for hiding this comment

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

Same here regarding keep_alive

addr.address_, addr.type_, std::forward<Ts>(vs)...);

return keep_alive(std::move(f), id);
}
Copy link
Member

Choose a reason for hiding this comment

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

I like that!

@hkaiser
Copy link
Member Author

hkaiser commented Nov 22, 2017

@sithhell Your comment shave been addressed.

- this patch significantly speeds up local action execution (both,
  direct and non-direct) by avoiding to construct a (remote) promise
  but instead directly scheduling the function bound to the action
  as a local thread, while using a simple (local-only) future.
Copy link
Member

@sithhell sithhell left a comment

Choose a reason for hiding this comment

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

Perfect, thanks!

@hkaiser hkaiser merged commit bd2f240 into master Nov 22, 2017
@hkaiser hkaiser deleted the action_performance branch November 22, 2017 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants