G1 GC中如何管理堆栈中的根节点

huangapple go评论77阅读模式
英文:

How roots from stack are managed in G1 GC

问题

Java在G1垃圾收集器中如何管理来自堆栈的Root对象?在垃圾收集(年轻或混合阶段)期间,它是否遍历所有变异器线程的堆栈,或者是否有类似于记忆集的其他数据结构(用于保存跨代指针的引用)以节省时间?是否有相关的文档?

英文:

How does Java manage Root objects from the stack in G1 garbage collector? Does it traverse the stacks of all the mutator threads while garbage collecting(young or mixed phase) or is there some other data structures similar remember sets (used to keep the reference of intergenerational pointers) to save time?
Is there any documentation of the same.

答案1

得分: 1

线程堆栈始终被扫描,不仅在 G1 中,而且据我所知,在JVM上实现的每个垃圾收集器中都是如此。垃圾收集器必须从一些已知的根开始,以找出什么是存活的,什么不是。在任何Java的GC中,这些根由各种部分组成,包括线程堆栈。

在每个周期,这些根会被扫描;毕竟它们将会被更改,并且在每个周期可能会有所不同。令人痛苦的是,在此实现之前,这是一个停止-世界阶段。而且 STW 阶段可能会因安全点轮询或线程数量而变得很大。在现实生活场景中(至少是我参与的那些场景),这并不是一个问题;这是一个快速的过程(使用 Shenandoah 2.0,我见过最大 15 ms 的暂停时间)。

remembered sets 执行了一种略有不同的 角色

英文:

Thread stacks are always scanned, not only in G1; but afaik in every other garbage collector implemented on the JVM. A GC has to start with some known roots in order to find out what is alive and what not. In case of any java's GC, these roots are made from various pieces, among others : thread stacks.

At every cycle, these are scanned; after all they will be changed and will be different potentially at each cycle. The painful part is that until this is implemented, this is a stop-the-world phase. And STW phases can get big due to safe point polling or number of threads. In real life scenarios (at least the ones that I have been involved with), this is not a concern; it's a fast process (with Shenandoah 2.0, I have seen max of 15 ms pause).

remembered sets fulfill a somehow different role.

huangapple
  • 本文由 发表于 2020年8月3日 18:52:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/63228120.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定