1.5G的内存容量有多快? [英] How fast is the go 1.5 gc with terabytes of RAM?

查看:181
本文介绍了1.5G的内存容量有多快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java不能使用兆兆字节的RAM,因为GC暂停时间太长(分钟)。随着Go GC的最新更新,我想知道它的GC暂停是否足够短,可用于大量的RAM,比如几TB。

这有没有任何基准呢?我们现在可以使用垃圾收集语言和这么多的RAM吗?




  • 现在不能在单个Go流程中使用TB的RAM。 Max在Linux上的容量为512 GB,而我所见过的大部分内容都是240 GB。

  • 对于当前的后台GC,GC 工作负载往往更重要您可以将GC工作负载理解为指针 * 分配率 / 备用RAM 。在使用大量RAM的应用程序中,只有指针很少或分配很少的应用程序才会具有较低的GC工作负载。






我同意inf的评论,认为巨大的堆值得向其他人询问测试)。 JimB指出,Go堆现在有512 GB的硬性限制,而18 GB 240 GB是我见过的最多的。

从 and



暂停时间为20ms的同一个应用程序在下暂停3-4ms 1.6,大约8GB堆和150M分配/分钟

使用Go进行聊天服务的Twitch报告说



1.8 将堆栈扫描从世界范围的停止阶段开始,大部分暂停时间远远低于1ms,即使在大堆中也是如此。 早期数字看起来不错。偶尔,应用程序仍然有代码模式,使得goroutine很难暂停,从而延长了所有其他线程的暂停时间,但通常可以说GC的后台工作现在通常比GC 暂停。






一些关于垃圾收集的一般性观察,并非特定于Go:





换言之,访问大量内存的应用程序可能仍然没有GC问题如果它只有几个指针(例如,它处理相对较少的大 []字节缓冲区),并且分配率较低时集合发生的频率较低(例如,因为你应用 sync.Pool 来重复使用内存,无论你在哪里通过RAM咀嚼最快)。 所以如果你查看涉及数百GB的非自然GC友好的内容时,我建议您考虑使用C语言编写的任何



  1. 将庞大的数据移出对象图。例如,您可以管理嵌入数据库中的数据,例如 bolt ,将其放入外部数据库服务中,或使用诸如 groupcache 或memcache,如果您需要更多的缓存而不是DB

  2. 运行一组较小的堆进程而不是一个较大的进程

  3. 只需仔细进行原型设计,测试和优化以避免内存问题。


Java cannot use terabytes of RAM because the GC pause is way too long (minutes). With the recent update to the Go GC, I'm wondering if its GC pauses are short enough for use with huge amounts of RAM, such as a couple of terabytes.

Are there any benchmarks of this yet? Can we use a garbage-collected language with this much RAM now?

解决方案

tl;dr:

  • You can't use TBs of RAM with a single Go process right now. Max is 512 GB on Linux, and most that I've seen tested is 240 GB.
  • With the current background GC, GC workload tends to be more important than GC pauses.
  • You can understand GC workload as pointers * allocation rate / spare RAM. Of apps using tons of RAM, only those with few pointers or little allocation will have a low GC workload.

I agree with inf's comment that huge heaps are worth asking other folks about (or testing). JimB notes that Go heaps have a hard limit of 512 GB right now, and 18 240 GB is the most I've seen tested.

Some things we know about huge heaps, from the design document and the GopherCon 2015 slides:

  • The 1.5 collector doesn't aim to cut GC work, just cut pauses by working in the background.
  • Your code is paused while the GC scans pointers on the stack and in globals.
  • The 1.5 GC has a short pause on a GC benchmark with a roughly 18GB heap, as shown by the rightmost yellow dot along the bottom of this graph from the GopherCon talk:

Folks running a couple production apps that initially had about 300ms pauses reported drops to ~4ms and ~20ms. Another app reported their 95th percentile GC time went from 279ms to ~10ms.

Go 1.6 added polish and pushed some of the remaining work to the background. As a result, tests with heaps up to a bit over 200GB still saw a max pause time of 20ms, as shown in a slide in an early 2016 State of Go talk:

The same application that had 20ms pause times under 1.5 had 3-4ms pauses under 1.6, with about an 8GB heap and 150M allocations/minute.

Twitch, who use Go for their chat service, reported that by Go 1.7 pause times had been reduced to 1ms with lots of running goroutines.

1.8 took stack scanning out of the stop-the-world phase, bringing most pauses well under 1ms, even on large heaps. Early numbers look good. Occasionally applications still have code patterns that make a goroutine hard to pause, effectively lengthening the pause for all other threads, but generally it's fair to say the GC's background work is now usually much more important than GC pauses.


Some general observations on garbage collection, not specific to Go:

Rephrased, an application accessing lots of memory might still not have a GC problem if it only has a few pointers (e.g., it handles relatively few large []byte buffers), and collections happen less often if the allocation rate is low (e.g., because you applied sync.Pool to reuse memory wherever you were chewing through RAM most quickly).

So if you're looking at something involving heaps of hundreds of GB that's not naturally GC-friendly, I'd suggest you consider any of

  1. writing in C or such
  2. moving the bulky data out of the object graph. For example, you could manage data in an embedded DB like bolt, put it in an outside DB service, or use something like groupcache or memcache if you want more of a cache than a DB
  3. running a set of smaller-heap'd processes instead of one big one
  4. just carefully prototyping, testing, and optimizing to avoid memory issues.

这篇关于1.5G的内存容量有多快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆