锁定老帖子 主题:关于Azul 并发垃圾回收器(更新中)
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2011-03-26
最后修改:2011-03-27
题记: 总感觉JE讨论的帖子的东西都比较滞后,所以会有意多关注下infoQ上的东西,看看大洋彼岸的程序员们都在关心着什么。本文是说垃圾回收的,原文:http://www.infoq.com/articles/azul_gc_in_detail 根据个人体会和理解,筛选出了文章的重点. IntroductionAutomatic garbage collection frees the programmer from much of the worry about releasing objects that are no longer neededIt also prevents some kinds of common bugs occurring, including certain kinds of memory leaks, dangling pointer bugs (which occur when a piece of memory is freed while there are still pointers to it and one of those pointers is then used) and double free bugs (which occur when the program tries to free a region of memory that has already been freed and perhaps already been allocated again). 垃圾回收机制让程序员不用关心内存释放以及常见的内存错误,比如memory leak,dangling pointer,double free。
it does also have some problems. The most significant is that thus far, practical implementations of garbage collection in commercial Java runtimes have generally involved an unpredictable "pause" during collection. 但这种垃圾回收也存在一些问题,比如JVM的GC在垃圾回收过程中会不可预期地暂停应用线程#应该跟GC的单线程回收有关#
As Java programs have expanded in size and complexity, so the garbage collection pause has become an increasingly significant problem for Java software architects. 随着程序越来越复杂,这种回收的pause越来越频繁。
A widely used technique in enterprise Java to work around this is to distribute programs. This can both keep the heap size smaller, making the pauses shorter, and also allow some requests to continue whilst others are paused. Increasingly though, this means that Garbage Collector (GC) managed workloads are unable to take full advantage of the capabilities of the hardware on which they run.
一种普遍的解决方案是“云”,把程序拆分成集群,这样每台机器heap足够小,减少回收的次数,从而减少pause,且可持续响应用户的请求,但这样GC的回收从某种意义上来说没得到足够的利用。作者还认为当前GC的发展滞后于硬件的发展。
Collector MechanismsCommon Tasks要实现一个collector,必须要做到:
Parallelism and ConcurrencyGarbage collectors can be either single-threaded or parallel: 回收可以是单线程,也可以是多线程的
They are also either Stop-the-world or Concurrent: 所以GC也可以是并发的
Responsiveness and Sensitivity反应时间和敏感度
The Azul Garbage CollectorAzul's GPGC collector (which stands for Generational Pauseless Garbage Collector), included in its HotSpot-based JVM, is both parallel and concurrent. GPGC has been widely used in a number of production systems for several years now, and has been successful at removing or significantly reducing sensitivity to the factors that typically cause other concurrent collectors to pause.
说道这个GC在一些产品中应用了多年并成功避免了其他并发回收器的“失效”。
Azul用到的一些原理:
The Loaded Value Barrier“Self Healing”How the Azul Algorithm Works详细没看了,估计看了也不太明白。
Comparison with existing Garbage CollectorsHotSpot’s Concurrent Mark Sweep (CMS) is a mostly concurrent collector. It performs some garbage collection operations concurrently with program execution, but leaves some operations to long stop-the-world pauses. Tene described it as follows: Hotspot’s CMS collector uses a full, stop-the-world parallel new generation collector which compacts the new generation on every pass. Since young generation collection is very efficient, this stop-the-world pass typically completes very quickly - in the order of 100s of milliseconds or less. Oracle’s experimental Garbage First (G1) collector, which is expected to ship as part of Java 7, is an incrementally compacting collector that uses a snapshot-at-the-beginning (henceforth SATB) concurrent marking algorithm and stop-the-world compaction pauses to compact only parts of the heap in each pause. G1 allows the user to set pause time goals, and uses these goal inputs along with topology information collected during its mark phase in order to compact a limited amount of heap space in each pause, in an attempt to contain the amount of the heap references that need to be scanned during each pause. Tene explains that, given its experimental state, it is still early to tell how G1 will fare with real applications. According to Tene, while G1 is intended to incrementally improve upon CMS’s handling of fragmentation, its compactions are still performed in complete stop-the-world conditions, and its ability to limit the length of incremental compaction pauses strongly depends on an application’s specific heap topology and object relationships. Applications with popular objects or popular heap portions will still experience long stop-the-world pauses when the entire heap needs to be scanned for references that need remapping, and those long pauses, while less frequent, will be no shorter than those experienced by the current CMS collector. As Tene puts it: If a collector includes code that performs a full heap scan in stop-the-world conditions, that code is intended to run at some point, and application should expect to eventually experience such pauses. Whilst G1 attempts to improve determinism, it cannot guarantee it. Tene explained:
A previous InfoQ article provides more of the technical details. ConclusionWith the introduction of Zing, Azul has made pauseless garbage collection available in a pure software product on commodity hardware, making it more consumable and much easier to adopt. Pauseless garbage collection can:
Azul提供了一个持续的有效的内存回收。更有效地利用硬件资源,鼓励开发者充分使用内存,避免GC的一些额外的优化设置。 上面说到了Java7推出的G1,稍后继续。。 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
浏览 1718 次