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.

Shaving 40% Off Google’s B-Tree Implementation with Go Generics (2022)

114 pointsby 0xedbover 1 year ago

8 comments

kcudrevelcover 1 year ago
Hey, Google go b-tree implementation author here. A few important things:<p>- this implementation was done by me while I worked at Google and needed a good ordered tree. It is not and never was supported by Google, just open sourced by the company and written on company time.<p>- it now supports generics! Actually, iirc it did almost at the time that this article came out. In go 1.18 and higher, the original API uses a specialization of the generic underneath.
dangover 1 year ago
Discussed at the time:<p><i>Making Faster B-Trees with Go Generics</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31182645">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=31182645</a> - April 2022 (44 comments)
wtfishackernewsover 1 year ago
I got similar improvements when porting hashicorp&#x2F;golang-lru[1]<p><pre><code> name old time&#x2F;op new time&#x2F;op delta 2Q_Rand-16 1.22µs ±10% 0.52µs ± 8% -57.69% (p=0.000 n=20+19) 2Q_Freq-16 1.03µs ±10% 0.44µs ±12% -57.42% (p=0.000 n=18+20) ARC_Rand-16 1.51µs ± 9% 0.70µs ±15% -53.63% (p=0.000 n=20+20) ARC_Freq-16 1.22µs ±12% 0.54µs ± 7% -56.20% (p=0.000 n=20+20) LRU_Rand-16 401ns ± 9% 215ns ± 6% -46.46% (p=0.000 n=20+20) LRU_Freq-16 376ns ±13% 194ns ± 7% -48.51% (p=0.000 n=19+20) </code></pre> [1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;hashicorp&#x2F;golang-lru&#x2F;pull&#x2F;111">https:&#x2F;&#x2F;github.com&#x2F;hashicorp&#x2F;golang-lru&#x2F;pull&#x2F;111</a>
jeffbeeover 1 year ago
This may be confusing to those familiar with Google&#x27;s libraries. The baseline is the Go BTree, which I personally never heard of until just now, not the C++ absl::btree_set. The benchmarks aren&#x27;t directly comparable, but the C++ version also comes with good microbenchmark coverage.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;btree">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;btree</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;abseil&#x2F;abseil-cpp&#x2F;blob&#x2F;master&#x2F;absl&#x2F;container&#x2F;btree_set.h">https:&#x2F;&#x2F;github.com&#x2F;abseil&#x2F;abseil-cpp&#x2F;blob&#x2F;master&#x2F;absl&#x2F;contai...</a>
Pannoniaeover 1 year ago
This feels like such a non-news. They&#x27;ve pretty much created a language which is deliberately dumbed down to be 20 years behind other languages, then they are proud that they could speed it up with a feature that was fairly well-known almost 20 years ago.<p>Also the obsession with not providing tools for the programmer to use the stack, and rely on compiler internals to not heap-allocate everything.
评论 #37579661 未加载
评论 #37579606 未加载
评论 #37580425 未加载
评论 #37579651 未加载
评论 #37580618 未加载
评论 #37579797 未加载
评论 #37579604 未加载
评论 #37579560 未加载
softwarebewareover 1 year ago
The headline is dismal. Now writers can’t even be bothered to write what the improvement is? 40% of ______? “…Just trust us, 40% of something is ‘shaved’ …it’s good we promise.”
评论 #37580171 未加载
muglugover 1 year ago
(2022)
评论 #37579704 未加载
haolezover 1 year ago
Another way of seeing it is that &quot;40% of the code became imaginary&quot;, in the sense that you have to figure out what the macro is expanding to.<p>I&#x27;m not against generics. I was just wondering myself in a boring afternoon :)
评论 #37579370 未加载
评论 #37579600 未加载
评论 #37579401 未加载
评论 #37579284 未加载
评论 #37579542 未加载