[go-nuts] how dose netpollblock be awoken while sysmon sleep?
I have a test code like this: func main() { tcpAddress, err := net.ResolveTCPAddr("tcp", ":") if err != nil { fmt.Println(err) } listener, err := net.ListenTCP("tcp", tcpAddress) c, e := listener.AcceptTCP() if e != nil { fmt.Println(e) } t := make([]byte, 0, 1000) c.Read(t) } when the main function blocked on AcceptTCP(), the runtime.sysmon() function will enter sleep soon which is because npidle equal to gomaxprocs. and then a tcp connection comes, how dose acceptTCP be awoken? I couldn't find a runtime.netpoll() been call anymore. could some give some advise, effective tools, design document or debug method to read golang's source code? I always want to debug some code in runtime, but i conn't find a effective way to do this now; I read these code so hard without clearly understand the detail design . -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: how dose netpollblock be awoken while sysmon sleep?
I got it. it because there is a blocking netpool in runtime.findrunable() function. -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] how dose netpollblock been awaked while sysmon slepp?
thank you, i got it. how did you debug the go runtime? use print or gcc, or some other tools? Thank you for tolerate my grammatical mistakes again. 在 2017年4月20日星期四 UTC+8上午11:59:06,Ian Lance Taylor写道: > > On Wed, Apr 19, 2017 at 7:42 PM, 代君 > > wrote: > > > > i have a test code like this: > > func main() { > > tcpAddress, err := net.ResolveTCPAddr("tcp", ":") > > if err != nil { > > fmt.Println(err) > > } > > listener, err := net.ListenTCP("tcp", tcpAddress) > > > > c, e := listener.AcceptTCP() > > if e != nil { > > fmt.Println(e) > > } > > > > t := make([]byte, 0, 1000) > > c.Read(t) > > } > > when the main function blocked on AcceptTCP(), the runtime.sysmon() > > function will enter sleep soon which is because npidle equal to > gomaxprocs. > > > > and then a tcp connect coming, how acceptTCP been waked? I couldn't find > a > > runtime.netpoll() been call anymore. > > In the findrunnable function, when a P tries to find a G to run, if > there is nothing to run, but there are some goroutines waiting for > network activity, then the P will block in a call to netpoll until > something is ready. > > > could some give some advise, effective tools, design document or debug > > method to read golang's source code? I always want to debug some code in > > runtime, but i > > conn't find a effective way to do this now; I read these code so hard > > without clearly understand the detail design . > > For the scheduler you can read > > https://docs.google.com/document/d/1TTj4T2JO42uD5ID9e89oa0sLKhJYD0Y_kqxDv3I3XMw/view > > , although it is somewhat out of date. > > Ian > -- 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. For more options, visit https://groups.google.com/d/optout.
[go-nuts] sigaction implementation on darwin
Where is the sigaction implementation on macos with purego?I only found the cgo implementation in runtime/sys_darwin.go. -- 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/0ff0555a-e5c4-40d1-8bbd-c8b96a06e5a6n%40googlegroups.com.
[go-nuts] abort assembly code profile
I have some golang code like this: ```golang type C [2]int //go:noinline func t1(a, b C) C { var ret C for i := 0; i < len(a); i++ { ret[i] = a[i] + b[i] } return ret } //go:noinline func t2(a, b C) C { return t1(a, b) } ``` and build with command: go build main.go then i use objdump -d main to check the output assembly code, it like this: ```golang 000100086b40 <_main.t1>: 100086b40: fe 0f 1e f8 str x30, [sp, #-32]! 100086b44: fd 83 1f f8 sturx29, [sp, #-8] 100086b48: fd 23 00 d1 sub x29, sp, #8 100086b4c: ff ff 04 a9 stp xzr, xzr, [sp, #72] 100086b50: ff ff 00 a9 stp xzr, xzr, [sp, #8] 100086b54: 00 00 80 d2 mov x0, #0 100086b58: 09 00 00 14 b 0x100086b7c <_main.t1+0x3c> 100086b5c: e1 a3 00 91 add x1, sp, #40 100086b60: 22 78 60 f8 ldr x2, [x1, x0, lsl #3] 100086b64: e3 e3 00 91 add x3, sp, #56 100086b68: 64 78 60 f8 ldr x4, [x3, x0, lsl #3] 100086b6c: 42 00 04 8b add x2, x2, x4 100086b70: e4 23 00 91 add x4, sp, #8 100086b74: 82 78 20 f8 str x2, [x4, x0, lsl #3] 100086b78: 00 04 00 91 add x0, x0, #1 100086b7c: 1f 08 00 f1 cmp x0, #2 100086b80: eb fe ff 54 b.lt0x100086b5c <_main.t1+0x1c> 100086b84: e0 07 40 f9 ldr x0, [sp, #8] 100086b88: e1 0b 40 f9 ldr x1, [sp, #16] 100086b8c: e0 27 00 f9 str x0, [sp, #72] 100086b90: e1 2b 00 f9 str x1, [sp, #80] 100086b94: ff 83 00 91 add sp, sp, #32 100086b98: fd 23 00 d1 sub x29, sp, #8 100086b9c: c0 03 5f d6 ret ``` I think the above assembly code is not optimal。 1. the register value of x1,x3 can be compute out side of the loop. 2. store the result directly to [sp, #72], and [sp, #80], the temporary data in [sp, #8] and [sp, #16] not necessary. i want to know why the compiler couldn't do the optimize, or which command cat go more optimized code. -- 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/6c9e529b-d19e-4747-a2db-fa0f76548725n%40googlegroups.com.