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

2019-02-28 Thread fgergo
If you haven't studied concurrency before, I can't recommend any tutorials. To start to learn about concurrency, I'd first recommend _some_ reading and theoretical background. Concurrency is a complex concept. A "10x" multiplier estimation compared to e.g. structured programming is probably right,

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] Will a pointer point to C.xxx be garbage collected by Go runtime?

2019-02-28 Thread Jan Mercl
On Fri, Mar 1, 2019 at 6:37 AM Cholerae Hu wrote: > Will 'a' be scanned by go runtime? Yes. > It is allocate by go runtime. Correct and that's the reason the GC will handle it normally. > If p is scanned, go runtime should throw a 'bad pointer' error, because the memory pointed by p is alloca

[go-nuts] Will a pointer point to C.xxx be garbage collected by Go runtime?

2019-02-28 Thread Cholerae Hu
Consider the following code: ``` package main /* struct B { int i; }; struct A { int j; struct B b; }; */ import "C" func NewA() *C.struct_A { return &C.struct_A{ j: 1, b: C.struct_B{ i: 2, }, } } func main() { a := NewA() } ``` Will 'a' be scanned by go runtime? I

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

2019-02-28 Thread 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. Start with some tutorials and work your way up. > On Feb 28, 2019, at 10:14 PM, mountain

Re: [go-nuts] Is Go a single pass compiler?

2019-02-28 Thread David Riley
Was this book written in the '70s or '80s? Single-pass compilation is great in some ways (memory and time efficient), not in others (usability). C is (sort of) single-pass (if you don't count the preprocessor, optimization passes, etc), which is why you need function prototypes. Assemblers ar

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 runtime.semasleep

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

2019-02-28 Thread Robert Engels
It does not. > On Feb 28, 2019, at 9:13 PM, mountain...@gmail.com wrote: > > 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 th

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

2019-02-28 Thread Kurtis Rader
On Thu, Feb 28, 2019 at 7:13 PM wrote: > First of all, I am very grateful for your reply. I still want to know if > it has anything to do with STW? > What is "STW"? This is the first time that acronym has appeared in this thread. If you're referring to "stop the world" garbage collection the ans

[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 `chann

[go-nuts] Re: processing complex csv

2019-02-28 Thread Ahsan Deliri
Thank you for the idea. Sometimes you just need someone to state the obvious. On Thursday, February 28, 2019 at 6:36:50 PM UTC-5, Mandolyte wrote: > > Something like this? > - Create a map of the "wanted" struct using the employee ID as the key for > each > - make the metrics maps too with date

[go-nuts] Re: golang program use lots of memory

2019-02-28 Thread Inada Naoki
https://golang.org/doc/go1.12#runtime > On Linux, the runtime now uses MADV_FREE to release unused memory. This is more efficient but may result in higher reported RSS. The kernel will reclaim the unused data when it is needed. To revert to the Go 1.11 behavior (MADV_DONTNEED), set the environm

[go-nuts] Re: processing complex csv

2019-02-28 Thread Mandolyte
Something like this? - Create a map of the "wanted" struct using the employee ID as the key for each - make the metrics maps too with date as the key. Be sure to use a consistent format if a string, such as -MM-DD. - as you range over the rows and insert or update the struct Then range of th

[go-nuts] processing complex csv

2019-02-28 Thread Ahsan Deliri
Hey gophers, So the problem is every week we get a new CSV file. It's got the same data sets for people, but also adds employees newly enrolled in the training program. The CSV file just gets bigger because new data for this week is added but sometimes, error corrections are made for metrics fr

[go-nuts] Re: How can I try debug.SetMaxHeap?

2019-02-28 Thread 'David Chase' via golang-nuts
I think you actually want this stack of CLs. Despite Gerrit's predictions of doom, in fact they cherry-pick cleanly onto tip, and it builds, and passes tests: git fetch https://go.googlesource.com/go refs/changes/90/66090/4 && git cherry-pick FETCH_HEAD git fetch https://go.googlesource.com/go r

Re: [go-nuts] Is Go a single pass compiler?

2019-02-28 Thread Jim Ancona
The first computer I ever programmed[1] had a Fortran compiler that stored its intermediate representation on paper tape. As you might imagine, the number of passes affected compilation speed a lot. I don't do compilers, but I suspect that other bottlenecks matter much more today. Jim [1] - https

Re: [go-nuts] golang program use lots of memory

2019-02-28 Thread 'David Golden' via golang-nuts
Hi. In general, the memory reported by the profile will be less than than the memory allocated by the OS. You can see this Stack Overflow article for some explanation. More specifically, I see that your sample program is

[go-nuts] Re: Performance comparison of Go, C++, and Java for biological sequencing tool

2019-02-28 Thread Louki Sumirniy
It shouldn't really be surprising. Go and Java share the use of interfaces, but Go's concurrency is far lighter weight, and on top, Java has the extra burden of a virtual machine before it actually hits the CPU as binary code. I suspect also that the Go version could handle a much greater level

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

2019-02-28 Thread Louki Sumirniy
Channels require goroutines. `<-variable` blocks the goroutine it is in and waits for another goroutine to do the opposite, being `channel <- value` You can't use channels without goroutines, and really, the main purpose for goroutines is exactly about moving things through channels. Goroutine

[go-nuts] runtime: android backtraces do not include go backtrace

2019-02-28 Thread ashishbhatia . ab
Issue https://github.com/golang/go/issues/25035 "runtime: android backtraces do not include go backtrace" was filed long back. It is reproducible and here is an example of the results. In my limited understanding, there are two issues here. 1. Backtrace includes just one entry rather than all

[go-nuts] CGO on Windows and Application Verifier

2019-02-28 Thread pierre . franco
Hello everyone, I wanted to know whether the issue of Application Verifier ( https://docs.microsoft.com/en-us/windows/desktop/win7appqual/application-verifier ) crashing when used on a C (or C++) program linked with a CGO-generated DLL. This happens with Golang 1.11.4 and 1.11.5 for sure. The

[go-nuts] Performance comparison of Go, C++, and Java for biological sequencing tool

2019-02-28 Thread 'Isaac Gouy' via golang-nuts
"We reimplemented elPrep in all three languages and benchmarked their runtime performance and memory use. Results: *The Go implementation performs best*, yielding the best balance between runtime performance and memory use. While the Java benchmarks report a somewhat faster runtime than the Go

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

2019-02-28 Thread howardcshaw
Sameer is correct, but to be clear - The *block* happens because the channel is empty, so the receive operation blocks forever. This happens in both of the cases you show. The *deadlock* happens because *all* goroutines are blocked and none can continue. So if you start some other goroutine tha

[go-nuts] net/http: expose dialing + writing errors from net package

2019-02-28 Thread Jérôme LAFORGE
Hello Gophers, (I have already asked this question at https://github.com/golang/go/issues/14203#issuecomment-467785036) I want to know whether the error on http.Get("http://some.where";) is produced before or after httpclient sent the request (e.g. during tcp dial, tls or write request body in

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

2019-02-28 Thread Sameer Ajmani
The deadlock happens because the channel is empty, so the receive operation blocks forever. The second version imports a package that may start new goroutines in its init functions. If so, those goroutines may not be deadlocked, but the main function is still blocked on the receive operation. It

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 consid

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

2019-02-28 Thread 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 consider it bad netiquette. Black on white is the most universally readable

[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) fmt.Print