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

cmd/compile: recognize case <-time.After(x) #8895

dvyukov opened this issue Oct 7, 2014 · 4 comments

cmd/compile: recognize case <-time.After(x) #8895

dvyukov opened this issue Oct 7, 2014 · 4 comments


Copy link

dvyukov commented Oct 7, 2014

Compiler can recognize the common:
   case <-time.After(x):
construct and lower it into:
Runtime can handle this case much more efficiently: no need to create Timer, chan and
arm timers; it just needs to do a timed park of the goroutine until x. As a bonus, the
timer does not leak.
Copy link

rsc commented Oct 7, 2014

Comment 1:

This may not be necessary depending on what we do or don't do for issue #8898.

Status changed to Accepted.

Copy link
Member Author

dvyukov commented Oct 8, 2014

Comment 2:

I agree that this is related to issue #8898, and 8898 will somewhat alleviate benefit
from this optimization.
But this is still somewhat orthogonal thing, as in this case we don't even allocate nor
generate garbage.

Copy link

bradfitz commented Apr 2, 2015

Comments about this bug are in

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc removed the release-none label Apr 10, 2015
Copy link
Member Author

dvyukov commented Apr 10, 2015

Here is implementation of the optimization:

@rsc rsc removed accepted labels Apr 14, 2015
@rsc rsc changed the title cmd/gc: recognize case <-time.After(x) cmd/compile: recognize case <-time.After(x) Jun 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants