TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Go is about to get faster

212 点作者 is0tope超过 3 年前

10 条评论

xyzzy_plugh超过 3 年前
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 未加载
dilap超过 3 年前
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 未加载
vvern超过 3 年前
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 未加载
amelius超过 3 年前
Compiler question: what is the most worthy replacement for the Dragon Book, these days?
评论 #30046832 未加载
评论 #30062032 未加载
upsidesinclude超过 3 年前
Go Faster.<p>Real missed opportunity here
oblio超过 3 年前
Whaddya know :-o<p>It turns out that that complex technology was warranted?!?
评论 #30045145 未加载
评论 #30045313 未加载
评论 #30045088 未加载
评论 #30045158 未加载
native_samples超过 3 年前
<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_explore超过 3 年前
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 未加载
foldr超过 3 年前
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_explore超过 3 年前
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 未加载