Skip to content

Commit

Permalink
util/growstack: increase stack growth for 1.19
Browse files Browse the repository at this point in the history
Now that we've adopted go 1.19, we notice that the performance is much worse
(~8%) than we observed in go 1.18. Interestingly, we observe in profiles that
we spend a lot more time increasing our stack size underneath request
evaluation. This implied to me that some part of this is probably due to the
runtime's new stack growth behavior. Perhaps what is going on is that the
initial stacks are now smaller than they used to be so when we grow it, we grow
it by less than we need to. I ran a benchmark that seems to indicate that this
theory is true. I'd like to merge this to master and then backport it after we
collect some more data.

We never released this, so no note.

Touches #88038

Release note: None
  • Loading branch information
ajwerner committed Sep 20, 2022
1 parent d336fb2 commit 50ad662
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/util/growstack/growstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

package growstack

// Grow grows the goroutine stack by 16 KB. Goroutine stacks currently start
// Grow grows the goroutine stack by 32 KB. Goroutine stacks currently start
// at 2 KB in size. The code paths through the storage package often need a
// stack that is 32 KB in size. The stack growth is mildly expensive making it
// useful to trick the runtime into growing the stack early. Since goroutine
// stacks grow in multiples of 2 and start at 2 KB in size, by placing a 16 KB
// stacks grow in multiples of 2 and start at 2 KB in size, by placing a 32 KB
// object on the stack early in the lifetime of a goroutine we force the
// runtime to use a 32 KB stack for the goroutine.
// runtime to use a 64 KB stack for the goroutine.
func Grow()
2 changes: 1 addition & 1 deletion pkg/util/growstack/growstack.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

#include "funcdata.h"

TEXT ·Grow(SB),0,$16384-0
TEXT ·Grow(SB),0,$32768-0
NO_LOCAL_POINTERS
RET

0 comments on commit 50ad662

Please sign in to comment.