-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add support for future-less asynchronous calls on void methods #8
Comments
Doug Lea calls these one way message sends. |
It's a bit wonky to implement it that way since it would require adding machinery, either to the type checker or to the code generation, to know if the current thing being translated is being "captured" or not. It wouldn't be hard, but I would prefer to avoid adding that kind of complexity for just one thing. What would actually be easier to implement is another operator for one way message sends. For example, |
For a first implementation of this feature, I am all for it. |
Just one point on this issue. It applies to all kinds of methods, not just those returning void. Sent from my iPhone On 19/07/2014, at 10:09, EliasC [email protected] wrote:
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm |
I guess the difference between the two approaches boils down to whether one way sends are a language feature or an optimisation. |
This is a good point. I like both actually. What I originally suggested is not visible to the user, which is nice — and in line with the project. But it is also good to be able to explicate what one wants. So I'd like both I guess. But I'd favour the first kind just to lower the number of concepts in the language. |
Just a reminder that nothing we do in |
Given the level of documentation of the current implementation, I agree with you 100% ;) |
I would guess the C optimizer is smart enough to remove the unused result. Even if we capture the return value of one function call, 'x =
|
The C compiler is really not that smart. Partially because we are generating code that looks very much like use, and because there are multiple use-sites and the creation-site is always different from at leaf one use-site. I ran with -O1, -O2 and -O3 and saw roughly the same 30% time spent generating futures never used. |
This has been implemented and seems to work (i.e. it doesn't break anything obvious). Feel free to reopen this if new problems arise. |
Can you just briefly write down how this works here for our perusal and inclusion in Stephan’s language spec? |
The expression |
Don't confuse methods of void return type with those whose result you don't care about. We may care to know when a void method returns. Sent from my iPhone On 23/07/2014, at 10:30, EliasC [email protected] wrote:
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm |
@supercooldave Sure, and in that case we can still use |
I'll put it in the manual later today |
Super! |
We currently implement async sends to
void
methods using standard futures which are fulfilled by()
. This makes some sense -- it is possible to wait for the method to finish. On the other hand, it is highly suboptimal. Profiling the prime sieve program for example showed that ~30% of the entire program was spent creating and fulfillingFut void
.We need a way to call
void
methods asynchronously without futures. For now, I think a good solution (given it is simple to implement) is to check whether the caller saves the result of the call or not. So, give the methodfoo() : void
, the callshould generate a call without future overhead, whereas the call
should generate the same code as we currently do for both those cases.
(Someone might argue this is premature optimisation but currently that's not the case. Anything that makes our current key example run faster is important.)
@EliasC — I am assigning you to this task. If you can have this done before August 1st, we are good.
The text was updated successfully, but these errors were encountered: