The initial allocation size is exported, you can use the runtime/metrics 
package to look at it. Something like this:

package main

import (
    "fmt"
    "runtime/metrics"
)

func main() {
    s := []metrics.Sample{{Name: "/gc/stack/starting-size:bytes"}}
    metrics.Read(s)
    fmt.Printf("%d\n", s[0].Value.Uint64())
}

On Saturday, August 13, 2022 at 7:00:58 AM UTC-7 lia...@garena.com wrote:

> Hi masters,
>
> As far as I know, go 1.19 supports self-adaptive stack size when spawning 
> a goroutine, which intends to decrease the calling times of morestack that 
> aims to claim more frames from heap.
>
> After each GC happens, Go runtime will calculate the average stack usage 
> and the next time, goroutine would created with such a stack size.
>
> My question is, how do we validate the whole process or check it if works 
> well or not.
> Is there any metric or stack size checking function, or should I use pprof 
> to peek the alloc part ?
>
> Kindly thanks for all
>
> ```
> func main() {
> go func() {
> // spawn a goroutine started from a fixed stack size
> }()
>
> runtime.GC()
>
> go func() {
> // spawn a goroutine started from an avg stack size. 
> }()
> }
> ```
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/69d9bbd6-4e07-4f8c-82d4-0bb783c3c23dn%40googlegroups.com.

Reply via email to