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

Open
dvyukov opened this Issue Oct 7, 2014 · 4 comments

Comments

Projects
None yet
3 participants
@dvyukov
Copy link
Member

dvyukov commented Oct 7, 2014

Compiler can recognize the common:
   case <-time.After(x):
construct and lower it into:
   runtime.selectrecvafter(x)
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.
@rsc

This comment has been minimized.

Copy link
Contributor

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.

@dvyukov

This comment has been minimized.

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.
@bradfitz

This comment has been minimized.

Copy link
Member

bradfitz commented Apr 2, 2015

Comments about this bug are in https://go-review.googlesource.com/#/c/8356/

@rsc rsc added this to the Unplanned milestone Apr 10, 2015

@rsc rsc removed the release-none label Apr 10, 2015

@dvyukov

This comment has been minimized.

Copy link
Member Author

dvyukov commented Apr 10, 2015

Here is implementation of the optimization:
https://go-review.googlesource.com/5032

@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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.