[go-nuts] Instrumenting in Go and code generation

2020-05-24 Thread Sergey Kamardin
Hello Gophers, I just wanted to share an article and open source tool that I've finished recently. They both are about instrumenting (aka tracing) Go components. Article covers some background on it, while tool helps to generate boilerplate code to easily provide tracing hooks in your structs.

Re: [go-nuts] Stack based slice usage and unsafe

2019-05-27 Thread Sergey Kamardin
Hello Ian, Thank you for your answer. On Sun, 05/26/19, May 26, 2019 at 07:59:07PM -0400, Ian Lance Taylor wrote: > This is not valid. The rule is that SliceHeader is only valid when > inspecting an actual slice header. You have to write > > h.Data = uintptr(unsafe.Pointer()) > h.Len

Re: [go-nuts] Re: Stack based slice usage and unsafe

2019-05-26 Thread Sergey Kamardin
Hi Peter, Thank you for your answer. Actually it is not so – please see the rule (6) of the unsafe package documentation: https://golang.org/pkg/unsafe/ -- Regards, Sergey. On Sun, 05/26/19, May 26, 2019 at 09:43:13AM -0700, peterGo wrote: > Sergey Kamardin, > > Your code i

[go-nuts] Stack based slice usage and unsafe

2019-05-26 Thread Sergey Kamardin
Hello gophers, I have a question which relates mostly to the ideology of unsafe usage. In `github.com/gobwas/ws` WebSocket library I used an optimization for reading WebSocket frame headers into stack based slices (to reduce the number of heap allocations): func ReadHeader(r io.Reader)

Re: [go-nuts] Calling function with variadic arguments

2018-11-13 Thread Sergey Kamardin
Hi again, Sorry for my previous misunderstanding. Now I realized that there no ability in general to get the knowledge of how that slice of variadic arguments will be used inside hidden interface method implementation. Also, is it correct to think about variadic arguments just like about regular

Re: [go-nuts] Calling function with variadic arguments

2018-11-12 Thread Sergey Kamardin
ces). I mean, seems like that there no reason to allocate slice for passing N arguments even for an interface method call? Sergey. On Mon, 11/12/18, fff Nov 12, 2018 at 10:52:07AM -0800, Ian Lance Taylor wrote: > On Mon, Nov 12, 2018 at 4:24 AM, Sergey Kamardin wrote: > > > >

[go-nuts] Calling function with variadic arguments

2018-11-12 Thread Sergey Kamardin
Hello gophers, Does Go compiler has some optimizations for function and *method* calls with `variadic` arguments? For example, this simple benchmark: ``` package main import "testing" func Do(xs ...int) (s int) { for i, x := range xs { s += i + x }

Re: [go-nuts] Repeated functions with the same output in loops

2018-09-07 Thread Sergey Kamardin
> Note that calculating the length of a slice is a fast operation; it's > a single memory load. So, actually it just loads a slice header's field? On Thu, 09/06/18, fff Sep 06, 2018 at 12:56:36PM -0700, Ian Lance Taylor wrote: > On Thu, Sep 6, 2018 at 12:24 PM, mustafa katipoğlu >

[go-nuts] WebSocket implementation in Go

2018-08-05 Thread Sergey Kamardin
Hi Gophers, I have released a stable v1.0 version of https://github.com/gobwas/ws. It implements RFC6455 and supports streaming, manual memory management and other things for writing memory efficient WebSocket applications. By the way it deals with highload in production servers for almost two

Re: [go-nuts] db interface design

2018-05-21 Thread Sergey Kamardin
> 1. there are a lot of similar functions, for example NewBook and NewAuthor. > The difference is type of argument passed into the function. Is it a good > idea to combine those 2 functions with a generic New(interface{}) (string, > error) function and reflect the actual type inside? I would

[go-nuts] Re: Cgo: using syscall.Select

2018-05-19 Thread Sergey Kamardin
There are methods which are using raw file descriptors (such that https://godoc.org/github.com/mailru/easygo/netpoll#NewDesc). суббота, 19 мая 2018 г., 2:52:27 UTC+3 пользователь Juliusz Chroboczek написал: > > > You could also take a look > > at