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

new conc future api #821

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

duckyduckmaster
Copy link

@duckyduckmaster duckyduckmaster commented Jun 13, 2017

An implementation of multiple classes of lock-free futures, in order to fix the scalability problems of using only one class with mutex-locks. There are three different future classes available which are defined in three different source files:

  • future.c : futures with multiple get, await and chain operations.
  • vanilla_future.c : futures with only one get operation.
  • poly_vanilla_future.c : futures with multiple get operations.

Currently the API of the future.c file is the only used and further code is needed in order to enable vanilla and poly vanilla futures, such as compiler analysis:
I forgot to include tests so they may be put inside another PR.

@kikofernandez
Copy link
Contributor

could you provide some brief explanation about the different kinds of futures?

}
}

void handle_future(encore_actor_t *actor, pony_ctx_t *futctx, void * pony_node)
Copy link
Contributor

Choose a reason for hiding this comment

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

this function seems to be used for all futures. Is this correct?
If so, shouldn't it be placed in a more general future file, instead of in the vanilla future?
(I may be missing the point where this is called and if this is always called)

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it is correct that this function is used for all futures, the reason why its placed inside the vanilla future file is because the vanilla future is the future which is most often used, and therefore most calls to handle_future can be inlined.

Copy link
Contributor

@kikofernandez kikofernandez left a comment

Choose a reason for hiding this comment

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

Before this can be merged, I would like for the author to reply to the feedback :)

static inline void poly_vanilla_future_block_actor(pony_ctx_t **ctx, poly_vanilla_future_t *fut)
{
perr("future_block_actor");
if (__atomic_load_n(&(fut->fulfilled), __ATOMIC_SEQ_CST)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this condition needed at all? The function above (poly_vanilla_future_mk) seems to do this checking.

static inline void poly_vanilla_future_block_actor(pony_ctx_t **ctx, poly_vanilla_future_t *fut)
{
perr("future_block_actor");
if (__atomic_load_n(&(fut->fulfilled), __ATOMIC_SEQ_CST)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the __atomic_load_n work similar to acquire and release semantics, i.e., the state between acquire and release can be thought as a "transaction" visible to other threads?


void future_discharge(pony_ctx_t **ctx, future_t *fut);

/* VANILLA FUTURE API */
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great if the definition of vanilla futures et al is specified in the header files (or somewhere).
From the PR description:

future.c : futures with multiple get, await and chain operations.
vanilla_future.c : futures with only one get operation.
poly_vanilla_future.c : futures with multiple get operations.

it's not clear to me if a vanilla future has a single get operation or if it means that I cannot get multiple times from it (which could happen if there is an optimisation to reuse the future, e.g.)

static inline void vanilla_future_block_actor(pony_ctx_t **ctx, vanilla_future_t *fut)
{
perr("future_block_actor");
if (__atomic_load_n(&(fut->fulfilled), __ATOMIC_SEQ_CST)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same as in poly_vanilla. Is this if needed?

static inline void vanilla_future_block_actor(pony_ctx_t **ctx, vanilla_future_t *fut)
{
perr("future_block_actor");
if (__atomic_load_n(&(fut->fulfilled), __ATOMIC_SEQ_CST)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

many of these methods seem to be exactly the same.
Would it make sense to have a macro that defines these common methods and the specialised methods in the files?

// multiple times (re-entrant locks). this does not happen when we work with plain Encore
// however, re-entrant locks are necessary for the ParT runtime library.
//
// Use case:
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if the removal of this may affect ParTs


void future_await(pony_ctx_t **ctx, future_t *fut)
void future_discharge(pony_ctx_t **ctx, future_t *fut)
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure of what the naming means here. Maybe it's best if you provide some more information.
At the same time, I get the feeling that this discharge is possibly doing too many things. As I understood:

  1. Goes through the list of blocked actors and schedules them
  2. Starts running chained computations attached to the future, following a LIFO order. I would have expected that computations that are attached first run before the ones attached later (if the chaining operation happens in the same actor, and it's fair to assume any order if the future is shared among actors that may chain computations in this same future)

@duckyduckmaster
Copy link
Author

duckyduckmaster commented Oct 18, 2017 via email

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.

None yet

2 participants