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
Open

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

dvyukov opened this issue Oct 7, 2014 · 4 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Performance
Milestone

Comments

@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
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
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
Copy link
Contributor

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
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
@bcmills bcmills added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Performance
Projects
None yet
Development

No branches or pull requests

4 participants