Live data from Hacker News

A new ProtoBuf generator for Go

vitess.io

31–40 of 78 posts

Re: A new ProtoBuf generator for Go

#31

Is there one for Kotlin yet? It's pretty pathetic that Google's own protocol lacks native support for its most popular operating system.

Yes, I was surprised by this. We ended up using the Java ones only two years ago because of the lack of a Kotlin generator. Google had a blog post talking about what a struggle it was for some reason, but meanwhile someone had already created a decent Swift generator.

Re: A new ProtoBuf generator for Go

#32
post #28

Earlier quoted context omitted.

Do I misunderstand what arenas are? I thought it was just "allocate this big array as a single allocation rather than N little allocations"? If so, how is that not supported in Go? (e.g., `arena := make([]Foo, 1000000000)`)

An arena allocator allows you to store many allocations _of different types_ in the same single chunk of memory, and then free all of them at one point in time.

Why can't you do this in Go? I'm 99% sure we can allocate a massive array of bytes using safe Go and use unsafe to cast a chunk of bytes to an instance of a type. This isn't type safe, but neither would the equivalent C code.

Re: A new ProtoBuf generator for Go

#33
post #17

Using CPU utilization as a performance metric can be extremely misleading. My favorite article on the subject is from Brendan Gregg: http://www.brendangregg.com/blog/2017-05-09/cpu-utilization-... A much better way to test the influence of the new compiler would be to test the actual throughput at which saturation is achieved (which is what the benchmark in the C++ grpc library measure to assess their performance).

In this case the regression also caused a 3% decrease in throughput.

Re: A new ProtoBuf generator for Go

#34
post #28

Earlier quoted context omitted.

An arena allocator allows you to store many allocations _of different types_ in the same single chunk of memory, and then free all of them at one point in time.

Why can't you do this in Go? I'm 99% sure we can allocate a massive array of bytes using safe Go and use unsafe to cast a chunk of bytes to an instance of a type. This isn't type safe, but neither would the equivalent C code.

That's what this whole thread is about: you can literally do just that.

Re: A new ProtoBuf generator for Go

#35
post #9

Earlier quoted context omitted.

GP meant 5 orders of magnitude below "20 ms". 20 ms is a lot of time. There is nothing one can do to a, say, a 1 kilo byte buffer that will cross 1 ms in any language. My own Go code doesn't cross more than few micros per message.

GP's root claim is that protobuf serialization/deserialization performance shouldn't matter, on an article where a user is specifically demonstrating that it does matter .

The usecase described in the article, and the usecase described in the top post in this thread aren't the same usecase. If you aren't throughput bound, a 5% regression in parse speed doesn't matter if your goal is to stay under 20ms and parsing takes 17 us. Sure it now takes 19 us, which is a regression of 2 us out of 20ms, or 1/10000th of your time.

Re: A new ProtoBuf generator for Go

#36
post #34

Earlier quoted context omitted.

Why can't you do this in Go? I'm 99% sure we can allocate a massive array of bytes using safe Go and use unsafe to cast a chunk of bytes to an instance of a type. This isn't type safe, but neither would the equivalent C code.

That's what this whole thread is about: you can literally do just that.

> That's what this whole thread is about: you can literally do just that

I don't know how you get that from the thread:

> Arenas are, however, unfeasible to implement in Go because it is a garbage collected language.

> If you are willing to use cgo, google already implemented one for gapid.

> there are other garbage collected languages like D, Nim and C# that offer the language features to do arenas without having to touch any C code.

It seems like the above statements implicitly or explicitly claim that this isn't feasible in Go without C.

Re: A new ProtoBuf generator for Go

#37
the biggest current problem with Go and ProtoBuf is swagger support when using it for API returns. Enums are not supported for example. The leniency of protojson can't be used in other languages that built on top of the swagger docs.

Re: A new ProtoBuf generator for Go

#39
post #34

Earlier quoted context omitted.

That's what this whole thread is about: you can literally do just that.

> That's what this whole thread is about: you can literally do just that I don't know how you get that from the thread: > Arenas are, however, unfeasible to implement in Go because it is a garbage collected language. > If you are willing to use cgo, google already implemented one for gapid. > there are other garbage collected languages like D, Nim and C# that offer the language features to do arenas without having to…

You are misunderstanding the thread, I just mentioned some of the languages I like (still waiting for Go's generics), and the comment I was replying to made an assert about an implementation that uses cgo.

Both of us are dismissing the assertion that "Arenas are, however, unfeasible to implement in Go because it is a garbage collected language."

You can do manually memory allocation via a syscall into the host OS, use unsafe to cast memory blocks to the types that you want and then clean it all up with defer, assuming the arena is only usable inside a lexical region, otherwise extra care is needed to avoid leaks.

Re: A new ProtoBuf generator for Go

#40
post #34

Earlier quoted context omitted.

That's what this whole thread is about: you can literally do just that.

> That's what this whole thread is about: you can literally do just that I don't know how you get that from the thread: > Arenas are, however, unfeasible to implement in Go because it is a garbage collected language. > If you are willing to use cgo, google already implemented one for gapid. > there are other garbage collected languages like D, Nim and C# that offer the language features to do arenas without having to…

I was proposing the cgo option because it's already implemented.

I _think_ allocating a slice of contiguous bytes and using unsafe pointers should work fine as long as you are very cautious about structs/vars with pointers into the buffer getting freed by the GC.

Post reply on HN