TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Go is about to get faster

212 pointsby is0topeover 3 years ago

10 comments

xyzzy_plughover 3 years ago
I don&#x27;t believe Go is about to get faster, at least not in an especially unique way compared to past releases.<p>Historically the Go compiler has been seeing performance improvements every release, so historically, Go has always been getting faster.<p>When it comes to Generics, the benefits are not so straightforward as simply recompiling with a new binary. I just rebuilt one of our larger services with Go 1.17 and compared it to 1.18 and the benchmarks come out roughly the same after variance. There is a slight improvement, but what&#x27;s interesting is that we don&#x27;t use generics anywhere.<p>My employer has a blanket ban on Generics in Go until at least the next release. I know others that do too. There is also nothing in our code base that is screaming to be rewritten with Generics. We collectively thought about it and no one could come up with <i>anything</i> worthwhile. Internally, we&#x27;re still not sure when they&#x27;re even warranted. Sure, there&#x27;s a few three line for-loops that could be removed, but none of those are in a hot path. Yawn.<p>If Go generics radically change the Go ecosystem overnight, they will ruin the language. The ecosystem prefers stability and compatibility over features, and it&#x27;s pervasive and <i>good</i>. I update Java and JavaScript dependencies regularly and it&#x27;s a fucking nightmare compared to Go.<p>Lastly, Go had attracted a large community of developers who eschew unnecessary abstractions. It&#x27;s lovely and refreshing. I can&#x27;t say the same about Rust or Swift or Scala, where complexity is sometimes celebrated as simplicity when it&#x27;s really just convenience wearing lipstick.
评论 #30047299 未加载
评论 #30046139 未加载
评论 #30046285 未加载
评论 #30046266 未加载
评论 #30053746 未加载
dilapover 3 years ago
Not really fair. You could already get this performance, when you cared, by writing the specialized datastructure for the specific types you cared about. So sure, generics let you write type-agnostic libraries that don&#x27;t pay a boxing&#x2F;unboxing penalty, but that&#x27;s not really news!
评论 #30045674 未加载
vvernover 3 years ago
Deques are great. I think there&#x27;s two ways I&#x27;d consider designing this library differently:<p>1) The resizing seems worse to me than a linked-list of fixed-size ring buffers which use a sync.Pool. 2) (more out there) some of the time when I&#x27;ve implemented this sort of thing, it&#x27;s been to allocate memory for unmarshaling. It might be nice to have a mechanism to store values and allocate pointers.
评论 #30047264 未加载
评论 #30047626 未加载
ameliusover 3 years ago
Compiler question: what is the most worthy replacement for the Dragon Book, these days?
评论 #30046832 未加载
评论 #30062032 未加载
upsidesincludeover 3 years ago
Go Faster.<p>Real missed opportunity here
oblioover 3 years ago
Whaddya know :-o<p>It turns out that that complex technology was warranted?!?
评论 #30045145 未加载
评论 #30045313 未加载
评论 #30045088 未加载
评论 #30045158 未加载
native_samplesover 3 years ago
<i>&quot;This is encouraging news for a language already known to be unusually both fast and easy&quot;</i><p>Hmm it&#x27;s not known for that, is it? Go is known to be quite slow due to a weak compiler and a GC that optimizes for latency over throughput. And is Go really easier than a language like Java or in the dynamic world, JavaScript? It sure does seem to have a lot of weird edge cases and potholes to trip over.<p>Anyway I see a bunch of comments saying generics shouldn&#x27;t make anything faster. They can make code go faster in combination with specialization and value types. It&#x27;s one of the reasons C++ can go very fast whilst still supporting higher level abstractions, albeit at the cost of generated code size. It&#x27;s also the reason they&#x27;re adding value types and specialized generics to the JVM. I don&#x27;t know if Go is doing C++&#x2F;Rust style specialization or not, but it at least has the potential to do so.
评论 #30045342 未加载
评论 #30045562 未加载
评论 #30045394 未加载
评论 #30045517 未加载
评论 #30046910 未加载
评论 #30048324 未加载
评论 #30045586 未加载
londons_exploreover 3 years ago
Generics shouldn&#x27;t make something faster... If they do, then there is a bug or missed optimization in the compiler.
评论 #30045135 未加载
评论 #30045235 未加载
评论 #30045688 未加载
评论 #30045129 未加载
评论 #30045675 未加载
评论 #30046030 未加载
评论 #30045489 未加载
评论 #30045142 未加载
评论 #30045121 未加载
foldrover 3 years ago
Something fishy here. A generic data structure is exactly the kind of code that you <i>wouldn’t</i> expect to perform better with generics. At most you’re getting the benefits of unboxing and the absence of a single conditional jump for the type check when you convert back from interface{}. But that shouldn’t make much difference to a series of tests that just push and pop items for a queue. I suspect that any realistic code using this data structure would see no tangible performance benefit. These tests are probably just picking up the cost of an extra allocation required to box a primitive type as an interface.<p>If you’ll excuse the blog spam, I did a dive into the performance of interface{} here: <a href="https:&#x2F;&#x2F;adrummond.net&#x2F;posts&#x2F;gogenerics" rel="nofollow">https:&#x2F;&#x2F;adrummond.net&#x2F;posts&#x2F;gogenerics</a><p>(The blog post was written before it was certain that Go would get generics.)
评论 #30045160 未加载
评论 #30045266 未加载
londons_exploreover 3 years ago
All those times in the table seem... Slow...<p>For example, BenchmarkPushFront-10 takes 9 ns... That should consist of one write to memory (to update the pointer in the object). With decent compiler optimizations and a modern out of order CPU, I think we ought to be expecting one of those per clock cycle, so we ought to be seeing performance of 0.5ns. Perhaps even faster if the compiler manages to vectorize stuff (although I&#x27;m not aware of any compiler that can vectorize memory allocations).
评论 #30045148 未加载
评论 #30045217 未加载