Re: [go-nuts] gcwaiting=1 will causes block all the goroutines?

2019-04-10 Thread mountainfpf
Thank you, brother, the following jake brothers helped me to bring out all the confusion. 在 2019年4月10日星期三 UTC+8下午9:31:41,Ian Lance Taylor写道: > > On Wed, Apr 10, 2019 at 4:52 AM > wrote: > > > > My macos has 4 cores, but i start 3 goroutines, 2 sub goroutines, 1 > main goroutine. > > After

[go-nuts] Re: gcwaiting=1 will causes block all the goroutines?

2019-04-10 Thread mountainfpf
Thank you very much for your meticulous reply. I basically understand the scheduling mechanism, but I still don’t understand the third paragraph. It is "It is also important to note that the behavior of runtime.GC() is not the exactly same as the normal backgound GC that gets run by the

[go-nuts] gcwaiting=1 will causes block all the goroutines?

2019-04-10 Thread mountainfpf
Hi, My macos has 4 cores, but i start 3 goroutines, 2 sub goroutines, 1 main goroutine. After main goroutine exec 3 times output, triggering gc causes gcwaiting=1. Finally all goroutine blocking package main import ( "fmt" "log" "net/http" _ "net/http/pprof" "runtime" // "runtime" "time"

Re: [go-nuts] A value copy will occur when executing for range xxx?

2019-04-04 Thread mountainfpf
hehe, thanks, so if i want understand deeply, need to look up gc code? 在 2019年4月3日星期三 UTC+8下午10:34:57,Ian Lance Taylor写道: > > On Wed, Apr 3, 2019 at 6:32 AM > wrote: > > > > thanks! v must be a value copy,Is this determined by the compiler? > > It's determined by the language definition. > >

Re: [go-nuts] A value copy will occur when executing for range xxx?

2019-04-03 Thread mountainfpf
thanks! v must be a value copy,Is this determined by the compiler? 在 2019年4月3日星期三 UTC+8下午7:57:26,Marvin Renich写道: > > * mount...@gmail.com > > [190403 05:10]: > > package main > > > > func main() { > > b := []int{1} > > > > bb := make([]*int, 0, 1) > > for k, v := range b { > > The

[go-nuts] A value copy will occur when executing for range xxx?

2019-04-03 Thread mountainfpf
package main func main() { b := []int{1} bb := make([]*int, 0, 1) for k, v := range b { _ = //8 line _ = [k] //9 line // bb = append(bb, ) bb = append(bb, [k]) } // for _, v := range bb { // fmt.Println(*v) // } } 1、When i use `go too compile -N -l -S main.go |grep "main.go:8" ` print asm

[go-nuts] Re: gdb go optimized out

2019-03-18 Thread mountainfpf
I set the parameters in your way and execute dlv or not.Thanks. On Saturday, March 16, 2019 at 12:12:42 AM UTC+8, Jake Montgomery wrote: > > First off, we are always happy to have new users in the group. But one > more bit of etiquette - Please don't post screenshots of text. Instead copy >

[go-nuts] Re: gdb go optimized out

2019-03-14 Thread mountainfpf
First of all, thank you very much for your answer. I use the giant font because I copied it directly from Google Translate. When I debug grow func of mheap.go file, I print the ask variable, it output No symbol "ask" in current context, print npage it output optimized out. func (h *mheap)

[go-nuts] gdb go optimized out

2019-03-13 Thread mountainfpf
Very strange, when I compile with go build -o main -gcflags "-N -l" main.go, it appears optimized out when debugging with gdb. Who knows why? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

Re: [go-nuts] I found a very strange code that would cause deadlocks and blocking,why???

2019-02-28 Thread mountainfpf
Is there a recommended tutorial? 在 2019年3月1日星期五 UTC+8下午12:21:58,Robert Engels写道: > > I think it would be helpful if you learned more about concurrent > programming. It is 10x harder, even with the simplifications that Go > offers. If you don’t understand the concepts you are going to struggle.

Re: [go-nuts] I found a very strange code that would cause deadlocks and blocking,why???

2019-02-28 Thread mountainfpf
This is the stack information printed when blocking, how to see which G blocking program? SIGABRT: abort PC=0x7fff9ceabbf2 m=0 sigcode=0 goroutine 0 [idle]: runtime.pthread_cond_wait(0x1967620, 0x19675e0, 0x7fff) /usr/local/go/src/runtime/sys_darwin.go:302 +0x51

[go-nuts] Re: I found a very strange code that would cause deadlocks and blocking,why???

2019-02-28 Thread mountainfpf
First of all, I am very grateful for your reply. I still want to know if it has anything to do with STW? 在 2019年3月1日星期五 UTC+8上午3:55:57,Louki Sumirniy写道: > > Channels require goroutines. `<-variable` blocks the goroutine it is in > and waits for another goroutine to do the opposite, being

Re: [go-nuts] I found a very strange code that would cause deadlocks and blocking,why???

2019-02-28 Thread mountainfpf
ok, thanks! 在 2019年2月28日星期四 UTC+8下午5:49:48,Jan Mercl写道: > > On Thu, Feb 28, 2019 at 10:20 AM > wrote: > > Please do not post colorized source code, particularly not using low > contrast, inverted color schemes. There are people not able to read it. > Some others may just ignore it or even

[go-nuts] I found a very strange code that would cause deadlocks and blocking,why???

2019-02-28 Thread mountainfpf
dead lock: package main import ( "fmt" // _ "github.com/go-sql-driver/mysql" ) func main() { c1 := make(chan int, 10) fmt.Println(<-c1) } block: package main import ( "fmt" _ "github.com/go-sql-driver/mysql" ) func main() { c1 := make(chan int, 10)

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-27 Thread mountainfpf
It is in line 899 and line 914 of the malloc.go file. 899 spc := makeSpanClass(sizeclass, noscan) 914 s = largeAlloc(size, needzero, noscan) 在 2019年1月27日星期日 UTC+8下午1:55:29,Ian Lance Taylor写道: > > On Sat, Jan 26, 2019 at 6:50 PM > wrote: > > > > I am looking at go1.11.1. > > I don't see a

Re: [go-nuts] Existing code for order-preserving concurrent work queue?

2019-01-27 Thread mountainfpf
when i open the link, it return:Unavailable For Legal Reasons Viewing and/or sharing code snippets is not available in your country for legal reasons. This message might also appear if your country is misdetected. If you believe this is an error, please file an issue

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-26 Thread mountainfpf
I am looking at go1.11.1. The memory allocation is still difficult to understand. What reference materials can help me understand the context of this block? 在 2019年1月27日星期日 UTC+8上午3:03:47,Ian Lance Taylor写道: > > On Sat, Jan 26, 2019 at 5:37 AM > wrote: > > > > Why the garbage collector won't

Re: [go-nuts] Re: why map the key type must not be a function, map, or slice

2019-01-26 Thread mountainfpf
I looked at your program example, mainly using the reflection type to design the mapped key, perhaps the reflected key is a comparable type, but I mainly propose specific types, such as func, slice, map can not be used as a key use 在 2019年1月25日星期五 UTC+8下午11:31:57,Victor Giordano写道: > > Yeah, i

Re: [go-nuts] Re: why map the key type must not be a function, map, or slice

2019-01-26 Thread mountainfpf
I use it often, I don't know what you mean by this. 在 2019年1月25日星期五 UTC+8下午11:04:08,Burak Serdar写道: > > On Fri, Jan 25, 2019 at 7:47 AM Victor Giordano > wrote: > > > > Just wanna say : It would be nice to employ a custom type as a valid key > for a map!!! :D > > You can use a struct as a

Re: [go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-26 Thread mountainfpf
Why the garbage collector won't know how to find the pointers? I looked at mallocgc and decided if the GC needs to scan this object based on the noscan flag. 在 2019年1月25日星期五 UTC+8下午10:58:44,Ian Lance Taylor写道: > > On Thu, Jan 24, 2019 at 11:58 PM > > wrote: > > > > go 1.11.1 source code is

[go-nuts] Why makechan distinguish elements do not contain pointers or contain pointers?

2019-01-24 Thread mountainfpf
go 1.11.1 source code is below: Generally speaking, make chan just pay attention to the presence or absence of buf. When I saw the source code of make chan, I can understand case 1: chan buf is 0, but can't understand case 2 & default. Who knows this principle? Thanks! var c *hchan

[go-nuts] How to debug goroutine with dlv

2019-01-23 Thread mountainfpf
When i debug go func() with dlv, use s to go into but not exec. Who is familiar with dlv debugging go source code? thanks! package main import "fmt" func main() { a := make(chan int) go func() { a <- 1 }() for { select { case i, ok := <-a:

Re: [go-nuts] Re: why map the key type must not be a function, map, or slice

2019-01-23 Thread mountainfpf
thanks lan. 在 2019年1月23日星期三 UTC+8下午11:26:57,Ian Lance Taylor写道: > > On Tue, Jan 22, 2019 at 11:47 PM > > wrote: > > > > i got : > > # command-line-arguments > > ./key.go:6:18: invalid operation: F() == F() (func can only be compared > to nil) > > Yes, that is what the language spec says

[go-nuts] Re: why map the key type must not be a function, map, or slice

2019-01-22 Thread mountainfpf
exec code: package main import "fmt" func main() { fmt.Println(F() == F()) } func F() func() int { i := 0 return func() int { i++ return i } } i got : # command-line-arguments ./key.go:6:18: invalid operation: F() == F() (func can only be compared to nil)

[go-nuts] About how to study chan send and receive data

2019-01-22 Thread mountainfpf
file:main.go code : package main func main() { a := make(chan int) go func() { a <- 1 }() println(<-a) } go build -o main main.go gdb main make(chan int) really exec: func makechan(t *chantype, size int) *hchan { elem := t.elem ... ... } go func() really exec

[go-nuts] why map the key type must not be a function, map, or slice

2019-01-22 Thread mountainfpf
When i use the func, map slice as the key of map, it isn't work! So I lookup source why, i find // spec: "The comparison operators == and != must be fully defined // for operands of the key type; thus the key type must not be a // function, map, or slice."