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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

A Guide to the Go Garbage Collector

233 点作者 ibraheemdev将近 3 年前

4 条评论

cube2222将近 3 年前
This is a really great guide! Nice to have something official and in-depth.<p>I have two tips I can share based on my experience optimizing OctoSQL[0].<p>First, some applications might have a fairly constant live heap size at any given point in time, but do a lot of allocations (like OctoSQL, where each processed record is a new allocation, but they might be consumed by a very-slowly-growing group by). In that case the GC threshold (which is based on the last live heap size) can be low and result in very frequent garbage collection runs, even though your application is using just megabytes of memory. In that case, using debug.SetGCPercent to modify that threshold at startup to be closer to 10x the live heap size will yield enormous performance benefits, while sacrificing very little memory.<p>Second, even if the CPU profiler tells you the GC is consuming a lot of time, that doesn&#x27;t mean it&#x27;s taking it away from your app, if it&#x27;s single-threaded. `go tool trace` can give you a much better overview of how computationally intensive and problematic the GC really is, even though reading it takes some getting used to.<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;cube2222&#x2F;octosql" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cube2222&#x2F;octosql</a>
评论 #32111640 未加载
评论 #32110632 未加载
omginternets将近 3 年前
Has anyone tried &quot;gc_details&quot;: true in VSCode? I&#x27;ve just gone through the configuration steps, but I&#x27;m not seeing anything obvious. What should I be looking for?<p>EDIT: found it at the top of the file.
hsn915将近 3 年前
I wonder if generics would allow custom allocators.<p>I haven&#x27;t tried it yet but it seems like an Arena&#x2F;bump allocator for example should be possible now.
评论 #32114920 未加载
erik_seaberg将近 3 年前
Hm, I was hoping for a roadmap that would talk about supporting generations and more tuning options.
评论 #32112903 未加载