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

runtime: copy and expand stacks instead of splitting them #4910

Closed
ugorji opened this issue Feb 25, 2013 · 6 comments
Closed

runtime: copy and expand stacks instead of splitting them #4910

ugorji opened this issue Feb 25, 2013 · 6 comments

Comments

@ugorji
Copy link
Contributor

ugorji commented Feb 25, 2013

Seemingly innocuous changes in recursive functions increased or decreased benchmark time
dramatically. Sometimes, benchmark time would increase 20%-100%, when we changed the
order of initialization of variables or declared a temporary variable explicitly.

Further analysis showed that this was a side-effect of the segmented stacks splitting.

During discussion, Russ mentioned that there was some work that could be done to try to
alleviate this. 

Filing this issue to track it.

========== Russ message from Google Groups discussion ==========
I think there could be some work done on choosing how big
a stack to allocate, which would perhaps relieve some of the
inner stack split checks.

There was some work at Berkeley a few years ago [1] that looked
at doing analysis of the program's call graph to remove some
stack split checks and to choose stack sizes, and I've been
meaning to look into whether we can do something smart like
that in Go's split stacks.  But ultimately if you end up triggering
a stack split in a tight loop you're not going to run as fast as
if you don't.

Tail call optimization is not mandated by the spec, is not
possible in functions with defer, and makes debugging harder.
I'm glad that we don't have that in the 6g compiler.

I've thought about runtime heuristics for stack sizes, but we
don't have enough information at stack split time to move
the stack, so by the time you realize 'it would be nice if the
current frame were bigger' it's too late.

Russ

[1] http://capriccio.cs.berkeley.edu/pubs/capriccio-sosp-2003.pdf
==========

More Context is at: 
  https://groups.google.com/d/msg/golang-dev/6Vs1sxmSSb0/CtgsMHzAgZwJ
  https://groups.google.com/d/msg/golang-dev/vxRuA-gbwdw/xiaDzM586VMJ
@adg
Copy link
Contributor

adg commented Feb 25, 2013

Comment 1:

Labels changed: added priority-someday, performance, removed priority-triage, go1.1maybe.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 2:

My suggestions are fine but even better is to stop using split stacks. That might happen
for Go 1.3.

Labels changed: added priority-later, go1.3, removed priority-someday, performance.

Owner changed to @randall77.

@robpike
Copy link
Contributor

robpike commented Aug 20, 2013

Comment 3:

Labels changed: removed go1.3.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 4:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 5:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 6:

Labels changed: added repo-main.

@ugorji ugorji closed this as completed Jan 6, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants