[go-nuts] Re: Why does one string concatenation escape, but the other not?

2021-06-22 Thread tapi...@gmail.com
Is this to avoid stack growing to fast if there are some stack allocations intervening with each other? On Wednesday, June 23, 2021 at 12:39:17 AM UTC-4 tapi...@gmail.com wrote: > > package main > > import "testing" > > var s33 = []byte{32: 'b'} > > var a = string(s33) > > func main() { > x

[go-nuts] Escape analysis result and benchmark result conflict

2021-06-22 Thread tapi...@gmail.com
The code: package concat import ( "testing" ) var s33 = []byte{32: 'b'} var a = string(s33) func Benchmark_e_33(b *testing.B) { for i := 0; i < b.N; i++ { _ = a + a // a + a does not escape } } "go test -gcflags=-m" shows: a + a does not escape but "go test -bench=.

Re: [go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread Vaibhav Maurya
I appreciate the whole discussion, it was really insightful. Since Golang is not my first language, I had a preconceived notion about key-value pair initialization. Here I would like to disagree with the syntax, it would be good that with the innovation in the language, the general idea of an

[go-nuts] Why does one string concatenation escape, but the other not?

2021-06-22 Thread tapi...@gmail.com
package main import "testing" var s33 = []byte{32: 'b'} var a = string(s33) func main() { x := a + a // a + a does not escape println(x) } func Benchmark_e_33(b *testing.B) { var x string for i := 0; i < b.N; i++ { x = a + a // a + a escapes to heap }

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-22 Thread Steven Penny
On Tue, Jun 22, 2021 at 4:31 PM 'Dan Kortschak' wrote: > Yes, trivial examples also exist. I thought one possible reason was `http#Response.Body` [1], because if a response contains `Content-Encoding: gzip`, then Go will automatically wrap the Body in a `gzip.Reader`. If that was the case, then a

[go-nuts] WinVerifyTrust WTD_STATEACTION_VERIFY wrong value

2021-06-22 Thread Federico GC
Hi all, I've been struggling a lot to replicate a C++ code that uses *WinVerifyTrustEx* function in go and I've found a discrepancy between the *WTD_STATEACTION_VERIFY* value defined in the file types_windows.go

Re: [go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread Rob Pike
That creates a slice 101 integers long, which probably isn't what you meant, which might help explain why you never came across it before. Smile. -rob On Wed, Jun 23, 2021 at 7:07 AM jake...@gmail.com wrote: > I'm surprised that I have never come across this as a way to create a > slice with

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-22 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-06-22 at 12:45 -0500, Steven Penny wrote: > Thanks for the help, but I found a much simpler example: > > https://play.golang.org/p/EcitH-85X6S Yes, trivial examples also exist. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread jake...@gmail.com
I'm surprised that I have never come across this as a way to create a slice with an initial length: x := []int{100:0} On Tuesday, June 22, 2021 at 12:43:17 PM UTC-4 axel.wa...@googlemail.com wrote: > Oh and also: > > Likewise, I think this only works for array literals; I don’t think >>

[go-nuts] Re: Generate benchmark binary

2021-06-22 Thread Thomas Pelletier
If anyone finds this, here is a proof of concept: https://github.com/pelletier/go-bb. -- 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

[go-nuts] Re: Specify local IP address in net.DialTCP throwing error bind: address already in use

2021-06-22 Thread Brian Candler
I'm afraid the question isn't related to the Go programming language at all. It's related to the operating system you're running on - which as far as I can see, you haven't mentioned. It's whatever the underlying system calls and TCP stack do. On Tuesday, 22 June 2021 at 16:40:16 UTC+1

Re: [go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread Bakul Shah
If you are familiar with C99’s designated initializers, this is similar but less general and less confusing. > On Jun 22, 2021, at 8:40 AM, Vaibhav Maurya wrote: > Hi, > > Please help me to understand the following syntax mentioned in the Golang > language specification document. > >

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-22 Thread Steven Penny
On Mon, Jun 21, 2021 at 6:52 PM 'Dan Kortschak' wrote: > https://play.golang.org/p/gwDnxVSQEM4 Thanks for the help, but I found a much simpler example: https://play.golang.org/p/EcitH-85X6S -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread David Riley
On Jun 22, 2021, at 12:42, Axel Wagner wrote: > >  > Oh and also: > >> Likewise, I think this only works for array literals; I don’t think (though >> again have not tried it) that you can declare slice literals with only >> selected members initialized. > > Works fine too:

Re: [go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread 'Axel Wagner' via golang-nuts
Oh and also: Likewise, I think this only works for array literals; I don’t think (though > again have not tried it) that you can declare slice literals with only > selected members initialized. Works fine too: https://play.golang.org/p/ANw54ShkTvY :) On Tue, Jun 22, 2021 at 6:41 PM Axel Wagner

Re: [go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread 'Axel Wagner' via golang-nuts
> > (I assume with a runtime rather than a compiler error, but I haven’t tried > it) Nope, compiler catches the overflow: https://play.golang.org/p/taorqygqxFz On Tue, Jun 22, 2021 at 6:39 PM David Riley wrote: > On Jun 22, 2021, at 11:39, Vaibhav Maurya wrote: > > > Hi, > > Please help me

Re: [go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread David Riley
On Jun 22, 2021, at 11:39, Vaibhav Maurya wrote: > > Hi, > > Please help me to understand the following syntax mentioned in the Golang > language specification document. > > https://golang.org/ref/spec#Composite_literals > > following is the search string for CTRL + F > // vowels[ch] is

Re: [go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread 'Axel Wagner' via golang-nuts
It's in the section you link to: The key is interpreted as a field name for struct literals*, an index for > array and slice literals*, and a key for map literals. (emphasis mine). The syntax allows you to specify keys for arrays and slices and interprets them as indices. Rune-literals (like

Re: [go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread Jan Mercl
On Tue, Jun 22, 2021 at 5:40 PM Vaibhav Maurya wrote: > https://golang.org/ref/spec#Composite_literals > > following is the search string for CTRL + F > // vowels[ch] is true if ch is a vowel \ > > Following declaration and initialization is confusing. > vowels := [128]bool{'a': true, 'e': true,

[go-nuts] Golang language specification Document: Composite Literals example is not understandable

2021-06-22 Thread Vaibhav Maurya
Hi, Please help me to understand the following syntax mentioned in the Golang language specification document. https://golang.org/ref/spec#Composite_literals following is the search string for CTRL + F // vowels[ch] is true if ch is a vowel \ Following declaration and initialization is

[go-nuts] Specify local IP address in net.DialTCP throwing error bind: address already in use

2021-06-22 Thread Chandan Pal
Written one TCP client which is used to create 10 TCP concurrent connections(holding for logger time) and enable only 10 ephemeral ports to use(49001 - 49010 ip_local_port_range file). func createConnection(c int, desAddr, desPort string) (brokerCon net.Conn, err error) { localips :=

Re: [go-nuts] unexpected stuck in sync.(*Pool).Get()

2021-06-22 Thread Robert Engels
With a 500k machine cluster I suggest getting professional Go support - someone experienced in troubleshooting that can sit with you and review the code and configuration to diagnose the issue. Personally it sounds like overallicated machines causing thrashing delays in the context switching.

Re: [go-nuts] unexpected stuck in sync.(*Pool).Get()

2021-06-22 Thread Peter Z
Sorry for a mistake: 'hyperthread closed', hyperthread is actually on. 在2021年6月22日星期二 UTC+8 下午10:01:48 写道: > I just checked the monitor data and found that the machine suffered from > high 'load average'(about 30+) at approximately the time the agent get > stuck. > A 24 cores(2 CPUs * 14

Re: [go-nuts] unexpected stuck in sync.(*Pool).Get()

2021-06-22 Thread Peter Z
I just checked the monitor data and found that the machine suffered from high 'load average'(about 30+) at approximately the time the agent get stuck. A 24 cores(2 CPUs * 14 cores), hyperthread closed machine with load average over 30 seems bad. But after the load average got down to below 1,

Re: [go-nuts] unexpected stuck in sync.(*Pool).Get()

2021-06-22 Thread Peter Z
> > He is stating he has a cloud cluster consisting of 500k machines - each > machine runs an agent process - each agent has 7000 Go routines. > Aha. Yes, this is what I mean. > Sorry, now I am completely confused. > > So, you have about 500,000 *processes *running this agent on each >>>

[go-nuts] string(aByteSlice) will duplicate undrelying bytes on stack if len(aByteSlice) <= 32

2021-06-22 Thread tapi...@gmail.com
The benchmark code: https://play.golang.org/p/qp6wQgqcHKW The result: Benchmark_CompareWithSwitch0Bytes-4328873778 3.619 ns/op 0 B/op 0 allocs/op Benchmark_CompareWithSwitch32Bytes-4 175067815 6.251 ns/op 0 B/op 0

Re: [go-nuts] unexpected stuck in sync.(*Pool).Get()

2021-06-22 Thread Robert Engels
He is stating he has a cloud cluster consisting of 500k machines - each machine runs an agent process - each agent has 7000 Go routines. > On Jun 22, 2021, at 7:07 AM, jake...@gmail.com wrote: > >  > Sorry, now I am completely confused. > >>> So, you have about 500,000 processes running

Re: [go-nuts] unexpected stuck in sync.(*Pool).Get()

2021-06-22 Thread jake...@gmail.com
Sorry, now I am completely confused. So, you have about 500,000 *processes *running this agent on each machine, >> and each process has around 7,000 gorouines? Is that correct? >> > > Yes, that's exactly what I mean. > but then you say: "Only one process per machine". Is there a language

Re: [go-nuts] unexpected stuck in sync.(*Pool).Get()

2021-06-22 Thread Peter Z
Only one process per machine. We use '*taskset -c $last_2nd_core,$last_3rd_core,$last_4th_core ./agent -c ../conf/agent.toml*' to start the agent. I wonder if it has any relationship with this problem ? 在2021年6月22日星期二 UTC+8 上午12:56:13 写道: > How many processes per machine? It seems like

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-22 Thread Brian Candler
https://xkcd.com/386/ :-) On Tuesday, 22 June 2021 at 07:19:19 UTC+1 axel.wa...@googlemail.com wrote: > On Tue, Jun 22, 2021 at 1:23 AM Steven Penny wrote: > >> OK, so all all these decades of experience, why cant anyone produce a >> small >> program to demonstrate the problem? > > > I must

Re: [go-nuts] What is the point of gzip Reader.Close?

2021-06-22 Thread 'Axel Wagner' via golang-nuts
On Tue, Jun 22, 2021 at 1:23 AM Steven Penny wrote: > OK, so all all these decades of experience, why cant anyone produce a small > program to demonstrate the problem? I must say, I'm impressed by Dan taking the time to actually provide one. My answer to this would have been: Because we would