[go-nuts] proposal: Generics — Assertions and Conversions

2021-09-18 Thread cxr
```go // Generics definitions. Keyword interface also ok, generic better. generic MyGen(It, *St, ...) { // type assertions It.(type) int, MyInt // only one type no need // interface assertions St.(interface) io.Reader // one or more // method assertions (St)

Re: [go-nuts] The right way for golang binary to reduce iTLB cache miss

2021-09-18 Thread robert engels
I can’t imagine the app has 34 mb of code in the hot path where this would matter - so I assume the application is partitioned with various Go routines doing a “type” of work. Which encounters a problem with the Go design. You can’t partition Go routines, and you can’t set cpu/core affinity

[go-nuts] Re: Generating go code using go templates

2021-09-18 Thread Denis Cheremisov
Templates is the worst approach to code generation IMO. Take a look how they do this in protoc-gen-go: https://github.com/protocolbuffers/protobuf-go/blob/b92717ecb630d4a4824b372bf98c729d87311a4d/cmd/protoc-gen-go/internal_gengo/main.go#L83 I am using very similar approach, albeit I prefer

Re: [go-nuts] The right way for golang binary to reduce iTLB cache miss

2021-09-18 Thread rmfr
I have tried to disable the inline during compiling, but it results in no big difference. On Saturday, September 18, 2021 at 9:26:45 PM UTC+8 ren...@ix.netcom.com wrote: > I will add that over aggressive inlining can cause this - it explodes the > binary size. > > On Sep 18, 2021, at 7:37 AM,

Re: [go-nuts] The right way for golang binary to reduce iTLB cache miss

2021-09-18 Thread rmfr
The problem is this application is a quite big Golang project. It has about 500, 000 lines of Golang codes and didn't even count these required 3-rd party libraries. On Sunday, September 19, 2021 at 8:47:44 AM UTC+8 rmfr wrote: > One of our Golang applications has a very huge binary size and

Re: [go-nuts] The right way for golang binary to reduce iTLB cache miss

2021-09-18 Thread rmfr
One of our Golang applications has a very huge binary size and the size of the .text segment itself in the elf is approximately *34MB*. The iTLB load miss reaches about *87%* of all iTLB cache hits. >> Is there any advice for big Golang applications to reduce the iTLB cache miss? Two solutions

[go-nuts] Re: AST: Understanding the differences between functions and methods

2021-09-18 Thread Tajmeet Singh
Oh yes! Thank you so much :) On Saturday, 18 September 2021 at 19:23:17 UTC+1 seank...@gmail.com wrote: > I believe the Recv field does what you want? > > On Saturday, September 18, 2021 at 8:20:19 PM UTC+2 tjgur...@gmail.com > wrote: > >> Hi, >> >> I was working on a tool for internal use

[go-nuts] Re: Where are the golang.org docs on channels?

2021-09-18 Thread Sean Liao
See the concurrency section of the tour: https://tour.golang.org/concurrency/2 And the concurrency section of Effective Go: https://golang.org/doc/effective_go#channels And the Share Memory by Communicating codewalk: https://golang.org/doc/codewalk/sharemem/ Which are all linked from the doc

[go-nuts] Where are the golang.org docs on channels?

2021-09-18 Thread Dean Schulze
The only mention of channel in the offical docs is a link to a YouTube video . Aren't there some docs from golang.org on channels? -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] Re: AST: Understanding the differences between functions and methods

2021-09-18 Thread Sean Liao
I believe the Recv field does what you want? On Saturday, September 18, 2021 at 8:20:19 PM UTC+2 tjgur...@gmail.com wrote: > Hi, > > I was working on a tool for internal use where I had to work with the go's > abstract syntax tree specially with the FuncDecls. I wanted to filter the > ast to

[go-nuts] AST: Understanding the differences between functions and methods

2021-09-18 Thread Tajmeet Singh
Hi, I was working on a tool for internal use where I had to work with the go's abstract syntax tree specially with the FuncDecls. I wanted to filter the ast to only function declarations without methods. I was wondering if there is a way to distinguish between normal functions and structure

Re: [go-nuts] The right way for golang binary to reduce iTLB cache miss

2021-09-18 Thread robert engels
I will add that over aggressive inlining can cause this - it explodes the binary size. > On Sep 18, 2021, at 7:37 AM, Jesper Louis Andersen > wrote: > > On Fri, Sep 17, 2021 at 11:09 AM rmfr > wrote: > One of our Golang applications has a very huge binary

Re: [go-nuts] The right way for golang binary to reduce iTLB cache miss

2021-09-18 Thread Jesper Louis Andersen
On Fri, Sep 17, 2021 at 11:09 AM rmfr wrote: > One of our Golang applications has a very huge binary size and the size of > the .text segment itself in the elf is approximately *34MB*. The iTLB > load miss reaches about *87%* of all iTLB cache hits. > > Is there any advice for big Golang

Re: [go-nuts] Z algorithm in string package

2021-09-18 Thread Brian Candler
A tradeoff with this algorithm is the extra memory allocation required. Say you're using int32 to represent the substring length, then a string of length N and pattern length P needs a temporary memory allocation of size 4N+4P+4. Hence I'm not sure this is a good fit for string.Index,

Re: [go-nuts] Z algorithm in string package

2021-09-18 Thread vl4deee11
I think z algo can be third party lib. But i try to optimize strings.Index with z algo. Later i can show benchmarks. Thanks for your help! пятница, 17 сентября 2021 г. в 22:07:00 UTC+3, Ian Lance Taylor: > On Fri, Sep 17, 2021 at 12:03 PM vl4deee11 wrote: > > > > Yes, this algorithm is mainly