Live data from Hacker News

The Go Compiler Needs to Be Smarter

lemire.me

71–80 of 119 posts

Re: The Go Compiler Needs to Be Smarter

#71

Earlier quoted context omitted.

If there's only one backing type being looked up. If there's more than one, the inline cache thrashs like they're saying.

JRuby has had polymorphic inline caches for like a decade and CRuby will actually cache multiple types in the method cache as long as they cache the same method since https://github.com/ruby/ruby/pull/2583

JRuby is JVM and not really what I'm talking about.

And still on CRuby if you have any dynacism, you thrash your cache.

Re: The Go Compiler Needs to Be Smarter

#72
post #70
post #69

Earlier quoted context omitted.

Vague statements without sources are not facts. And even without sources comparing Go to Java and .NET doesn't even make sense in the context.

Since it is so hard for you to use Google, here you go: https://cr.openjdk.java.net/~vlivanov/talks/2017_Vectorizati... https://www.codeproject.com/Articles/1223361/Benchmarking-NE... https://clearlinux.org/blogs-news/performant-containerized-g... Now go play with your facts.

Intel doesn't directly advice for neither of the 3 methods. It simply states that handcrafting assembly code is faster which is always the case anyway.

So everybody can see how dishonest pjmlp is towards Go, here is their interpretation of Intel's conclusion:

> Intel has recently published an article on using Go, their advice? Manually use cgo or Go Assembly for the AVX.

.

.

And here is the actual Intel conclusion from the link:

> The examples show how to use Intel AVX-512 with Go to improve application performance using three different methods: direct access with Go assembly, using the Go cgo interface with intrinsics for Intel AVX-512, and via indirect access with 3rd party libraries such as Gonum.

> Each method showed that using Intel AVX-512 improved Go application performance, with shorter execution times and improved date throughput overall. Using Go assembly with direct access to the CPU instruction set was faster than indirect access using cgo or Gonum.

> Clear Linus OS makes it easy to use Intel AVX-512 in Go because Clear Linux OS provides a deeply optimized software stack, including Intel AVX-512 enabled software.

.

.

To say pjmlp's interpretation was uncharitable is an understatement.

Re: The Go Compiler Needs to Be Smarter

#73
post #34

Earlier quoted context omitted.

Those optimizations could be taken advantage of via gccgo. Also many other languages keep having backend issues, because those optimizations are too focused on C and C++ code semantics.

> Also many other languages keep having backend issues, because those optimizations are too focused on C and C++ code semantics. Attribute it to LLVM monoculture.

Attribute it to benchmarks people care about being written in C/C++ (with maybe a dash of Fortran). e.g., SPEC CPU.

Re: The Go Compiler Needs to Be Smarter

#74
post #62

"I do not mind that Go lacks exceptions or generics. These features are often overrated." I agree 100%. I've used them both in C++. I hope Go never gets them.

Generics, I would certainly be ecstatic for if it was done in a way that is novel and feels Go-like, so not Java or C# or C++'s implementations. This has certainly been the stance of the Go team since the beginning of time. It has never been "anti-generics" it's always been "we've studied all the generics implementations out there, and didn't feel like any one of them were good enough, so rather than shoehorn them in, we are being patient." This approach needs to be celebrated more.

Exceptions, OTOH, I hope never see the light of day in Go. Curse them.

Re: The Go Compiler Needs to Be Smarter

#75
post #15

Go mostly has been only picking up easy wins so far. I haven't seen any attempt to go further than that. Which is fair strategy for first few years since everything comes with a cost. But, people now expect to see more obviously specially the more it's being compared to more sophisticated languages and compilers.

The language should remain unsophisticated; it's meant for coding at scale, for reading at an even larger scale. Sophistication is not a target, and expressing logic in a more compact form will mainly make it harder to read and understand, which for the kinds of things they write with it, the code that still has to be understood 30+ years down the line, is super important.

Re: The Go Compiler Needs to Be Smarter

#76
post #28

Earlier quoted context omitted.

> But, people now expect to see more obviously [..] I don't. I mean, yay for improvements, but it's already working great for my usecases.

Same here. Go is now my daily driver and main language, and I'm perfectly satisfied with it. Quite the opposite of expecting more, I'm very fearful on what may change or be added in go-2 (which is actually a reason why I'm currently learning C, just in case).

Personally, if Go takes a bad turn, I'm likely to just go back to JVM languages.

Not Scala though, they went overboard with that one.

Re: The Go Compiler Needs to Be Smarter

#77
post #40

Does it really, though? Go really isn't meant for number crunching, or any CPU-bound code, really. I think it's just fine for a language to not strive to emit the fastest possible code. I don't mind having an ecosystem where build times are fast in return for less optimized code. We already have plenty of languages that do the opposite (Rust, C++, Haskell, ...), and I would personally hate to see Go's compilation/lin…

Hmm I disagree, Go is a language that should have workload that is CPU bound, Go is not Python or Ruby it's more C++ in that case. It can do heavy computation, I think it's just a balance of compiler optimization vs compile time.

Re: The Go Compiler Needs to Be Smarter

#78
post #62

"I do not mind that Go lacks exceptions or generics. These features are often overrated." I agree 100%. I've used them both in C++. I hope Go never gets them.

This is going to sound a bit like "no true generics" but if you think of C++ templates as macros less so than generics you might be more open to seeing how other languages do it in a way that encourages better engineering.

Re: The Go Compiler Needs to Be Smarter

#79
post #62

"I do not mind that Go lacks exceptions or generics. These features are often overrated." I agree 100%. I've used them both in C++. I hope Go never gets them.

C++ doesn't have generics. It has templates, which is essentially a macro system—there is no type checking, and a new instance of the code is generated at the source/AST level for every combination of template parameters. If that is your only experience with "generics" then it's no wonder that you have a negative opinion of them, but that is no reason to oppose the implementation of proper generics in other languages. Java has true generics with interfaces and such but they were retrofitted into a language with a less expressive type system, so there are gaps in the implementation. A better example would be traits in Rust, or typeclasses in Haskell.

Re: The Go Compiler Needs to Be Smarter

#80
post #28

Earlier quoted context omitted.

> But, people now expect to see more obviously [..] I don't. I mean, yay for improvements, but it's already working great for my usecases.

What are your usecases, if you don't mind me asking? I am considering replacing our HTTP-heavy processes currently written in C++ with Go. However, after reading this thread I'm not so sure. Compilation time isn't that big of an issue for us, but having a simpler way of doing networking would be a win. I can't tell if that ease of use would be trumped by poor performance.

Pretty new to the language myself but it might be worth it to just dive in yourself and see. I imagine getting a proof of concept wouldn't take too long given how easy go is to learn, great builtin benchmarking, and the (from what I've heard) exceptional net/http library.
Post reply on HN