[论文解读] NG2C: Pretenuring N-Generational GC for HotSpot Big Data Applications
NG2C 是 HotSpot JVM 的一种新型垃圾回收算法,通过基于生命周期分析的 N 代堆预分配机制,将对象直接预分配至对应代中,从而在大数据工作负载中显著减少对象复制与内存碎片,降低 GC 暂停时间。与 G1 和 CMS 相比,NG2C 在 Cassandra、Lucene 和 GraphChi 上实现了高达 96.45% 的最坏情况暂停时间减少,且无吞吐量或内存开销。
Big Data applications suffer from unpredictable and unacceptably high pause times due to Garbage Collection (GC). This is the case in latency-sensitive applications such as on-line credit-card fraud detection, graph-based computing for analysis on social networks, etc. Such pauses compromise latency requirements of the whole application stack and result from applications' aggressive buffering/caching of data, exposing an ill-suited GC design, which assumes that most objects will die young and does not consider that applications hold large amounts of middle-lived data in memory. To avoid such pauses, we propose NG2C, a new GC algorithm that combines pretenuring with an N-Generational heap. By being able to allocate objects into different generations, NG2C is able to group objects with similar lifetime profiles in the same generation. By allocating objects with similar lifetime profiles close to each other, i.e. in the same generation, we avoid object promotion (copying between generations) and heap fragmentation (which leads to heap compactions) both responsible for most of the duration of HotSpot GC pause times. NG2C is implemented for the OpenJDK 8 HotSpot Java Virtual Machine, as an extension of the Garbage First GC. We evaluate NG2C using Cassandra, Lucene, and GraphChi with three different GCs: Garbage First (G1), Concurrent Mark Sweep (CMS), and NG2C. Results show that NG2C decreases the worst observable GC pause time by up to 94.8% for Cassandra, 85.0% for Lucene and 96.45% for GraphChi, when compared to current collectors (G1 and CMS). In addition, NG2C has no negative impact on application throughput or memory usage.
研究动机与目标
- 解决在 HotSpot JVM 上运行的延迟敏感型大数据应用中不可预测且较高的 GC 暂停时间问题。
- 通过根据大数据工作负载中实际的对象生命周期分析,突破弱分代假设(即大多数对象寿命短暂)的局限性,使 GC 更适应真实工作负载特征。
- 通过将具有相似生命周期的对象分组至专用代中,减少对象复制与堆压缩,从而降低长暂停时间的根本原因。
- 设计一种在大幅降低最坏情况暂停时间的同时,仍保持高应用吞吐量和内存效率的 GC 解决方案。
- 通过配置分析工具自动实现基于生命周期感知的预分配,使开发者无需手动调优 GC。
提出的方法
- NG2C 扩展了垃圾优先(G1)GC,引入基于生命周期分析的 N 代堆结构,按对象生命周期特征分离对象。
- 基于对象生命周期记录器(OLR)工具收集的性能数据,对象在分配时即被直接预分配至合适的代中。
- 通过确保具有相似生命周期的对象被集中分配至同一世代,避免代间复制与堆压缩。
- 系统使用分析工具(OLR)分析应用行为,并自动生成分配点的注解,以指导预分配决策。
- NG2C 集成于 OpenJDK 8 HotSpot,修改对象分配与代管理机制,以减少复制与碎片。
- 设计保留了现有的 GC 机制(如记忆集与并发标记),仅聚焦于分配与代放置策略的优化。
实验结果
研究问题
- RQ1基于生命周期分析将对象预分配至多个代中,能否有效减少大数据工作负载中的 GC 暂停时间?
- RQ2将具有相似生命周期的对象分组至专用代中,能否减少对象复制与堆压缩?
- RQ3NG2C 是否能在显著降低最坏情况 GC 暂停时间的同时,维持高应用吞吐量与内存效率?
- RQ4NG2C 在延迟敏感型大数据应用中,相较于 G1 和 CMS 等现有收集器,性能提升程度如何?
- RQ5自动化生命周期分析能否在无需手动调优或应用特定配置的前提下,实现高效的预分配?
主要发现
- 与 G1 和 CMS 相比,NG2C 在 Cassandra 中将最坏观测到的 GC 暂停时间减少了高达 94.8%。
- 在 Lucene 中,NG2C 相较基线收集器将最坏情况暂停时间减少了 85.0%。
- 在 GraphChi 中,NG2C 将最坏情况暂停时间减少了 96.45%,在图处理工作负载中表现出卓越性能。
- 尽管分配复杂度有所增加,NG2C 仍保持与 G1 和 CMS 相当的应用吞吐量,且无明显内存开销。
- NG2C 相较于 G1 和 CMS,将对象复制减少了高达 89.2%,直接解决了长暂停的根本原因。
- 即使配置为最大吞吐量,NG2C 的暂停时间仍比 CMS 短 66%,比 G1 短 39%。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。