摘要:序本文主要試用一下新引入的是一款及的垃圾收集器跟一樣也是面向的垃圾收集器,不過是基于來實現,而是基于來實現與相比,的是的但不是,而的是,因而能更好地減少與一樣,也是基于的,不同的是在邏輯上沒有分代,因而就沒有主要有如下幾個階段這里
序
本文主要試用一下JDK12新引入的ShenandoahGC
ShenandoahGCShenandoah是一款concurrent及parallel的垃圾收集器
跟ZGC一樣也是面向low-pause-time的垃圾收集器,不過ZGC是基于colored pointers來實現,而Shenandoah GC是基于brooks pointers來實現
與G1 GC相比,G1的evacuation是parallel的但不是concurrent,而Shenandoah的evacuation是concurrent,因而能更好地減少pause time
與G1 GC一樣,ShenandoahGC也是基于region的GC,不同的是ShenandoahGC在邏輯上沒有分代,因而就沒有young/old
GC cycleShenandoahGC主要有如下幾個階段:
這里包含Init Mark(Pause)、Concurrent Mark、Final Mark(Pause);這里使用到了White(not yet visited)、Gray(visited, but references are not scanned yet)、Black(visited, and fully scanned) Color算法進行markConcurrent evacuation
這個就是與G1不同的evacuation階段,它是concurrent的;這里用到了Brooks Pointers(object version change with additional atomically changed indirection)算法進行copy,Concurrent update references (optional)
這里包含Init update Refs(Pause)、Concurrent update Refs、Final update Refs(Pause)相關參數 Shenandoah開頭的參數
Final Mark或者Final update Refs之后都可能進行Concurrent cleanup,進行垃圾回收,reclaims region
bool ShenandoahAcmpBarrier = true {diagnostic} {default} bool ShenandoahAllocFailureALot = false {diagnostic} {default} uintx ShenandoahAllocSpikeFactor = 5 {experimental} {default} intx ShenandoahAllocationStallThreshold = 10000 {diagnostic} {default} uintx ShenandoahAllocationThreshold = 0 {experimental} {default} bool ShenandoahAllocationTrace = false {diagnostic} {default} bool ShenandoahAllowMixedAllocs = true {diagnostic} {default} bool ShenandoahAlwaysClearSoftRefs = false {experimental} {default} bool ShenandoahAlwaysPreTouch = false {diagnostic} {default} bool ShenandoahCASBarrier = true {diagnostic} {default} bool ShenandoahCloneBarrier = true {diagnostic} {default} uintx ShenandoahCodeRootsStyle = 2 {experimental} {default} bool ShenandoahCommonGCStateLoads = false {experimental} {default} bool ShenandoahConcurrentScanCodeRoots = true {experimental} {default} uintx ShenandoahControlIntervalAdjustPeriod = 1000 {experimental} {default} uintx ShenandoahControlIntervalMax = 10 {experimental} {default} uintx ShenandoahControlIntervalMin = 1 {experimental} {default} uintx ShenandoahCriticalFreeThreshold = 1 {experimental} {default} bool ShenandoahDecreaseRegisterPressure = false {diagnostic} {default} bool ShenandoahDegeneratedGC = true {diagnostic} {default} bool ShenandoahDontIncreaseWBFreq = true {experimental} {default} bool ShenandoahElasticTLAB = true {diagnostic} {default} uintx ShenandoahEvacAssist = 10 {experimental} {default} uintx ShenandoahEvacReserve = 5 {experimental} {default} bool ShenandoahEvacReserveOverflow = true {experimental} {default} double ShenandoahEvacWaste = 1.200000 {experimental} {default} uintx ShenandoahFreeThreshold = 10 {experimental} {default} uintx ShenandoahFullGCThreshold = 3 {experimental} {default} ccstr ShenandoahGCHeuristics = adaptive {experimental} {default} uintx ShenandoahGarbageThreshold = 60 {experimental} {default} uintx ShenandoahGuaranteedGCInterval = 300000 {experimental} {default} size_t ShenandoahHeapRegionSize = 0 {experimental} {default} bool ShenandoahHumongousMoves = true {experimental} {default} intx ShenandoahHumongousThreshold = 100 {experimental} {default} uintx ShenandoahImmediateThreshold = 90 {experimental} {default} bool ShenandoahImplicitGCInvokesConcurrent = true {experimental} {default} uintx ShenandoahInitFreeThreshold = 70 {experimental} {default} bool ShenandoahKeepAliveBarrier = true {diagnostic} {default} uintx ShenandoahLearningSteps = 5 {experimental} {default} bool ShenandoahLoopOptsAfterExpansion = true {experimental} {default} uintx ShenandoahMarkLoopStride = 1000 {experimental} {default} intx ShenandoahMarkScanPrefetch = 32 {experimental} {default} size_t ShenandoahMaxRegionSize = 33554432 {experimental} {default} uintx ShenandoahMergeUpdateRefsMaxGap = 200 {experimental} {default} uintx ShenandoahMergeUpdateRefsMinGap = 100 {experimental} {default} uintx ShenandoahMinFreeThreshold = 10 {experimental} {default} size_t ShenandoahMinRegionSize = 262144 {experimental} {default} bool ShenandoahOOMDuringEvacALot = false {diagnostic} {default} bool ShenandoahOptimizeInstanceFinals = false {experimental} {default} bool ShenandoahOptimizeStableFinals = false {experimental} {default} bool ShenandoahOptimizeStaticFinals = true {experimental} {default} bool ShenandoahPacing = true {experimental} {default} uintx ShenandoahPacingCycleSlack = 10 {experimental} {default} uintx ShenandoahPacingIdleSlack = 2 {experimental} {default} uintx ShenandoahPacingMaxDelay = 10 {experimental} {default} double ShenandoahPacingSurcharge = 1.100000 {experimental} {default} uintx ShenandoahParallelRegionStride = 1024 {experimental} {default} uint ShenandoahParallelSafepointThreads = 4 {experimental} {default} bool ShenandoahPreclean = true {experimental} {default} bool ShenandoahReadBarrier = true {diagnostic} {default} uintx ShenandoahRefProcFrequency = 5 {experimental} {default} bool ShenandoahRegionSampling = true {experimental} {command line} int ShenandoahRegionSamplingRate = 40 {experimental} {default} bool ShenandoahSATBBarrier = true {diagnostic} {default} uintx ShenandoahSATBBufferFlushInterval = 100 {experimental} {default} size_t ShenandoahSATBBufferSize = 1024 {experimental} {default} bool ShenandoahStoreCheck = false {diagnostic} {default} bool ShenandoahStoreValEnqueueBarrier = false {diagnostic} {default} bool ShenandoahStoreValReadBarrier = true {diagnostic} {default} bool ShenandoahSuspendibleWorkers = false {experimental} {default} size_t ShenandoahTargetNumRegions = 2048 {experimental} {default} bool ShenandoahTerminationTrace = false {diagnostic} {default} bool ShenandoahUncommit = true {experimental} {default} uintx ShenandoahUncommitDelay = 300000 {experimental} {default} uintx ShenandoahUnloadClassesFrequency = 0 {experimental} {default} ccstr ShenandoahUpdateRefsEarly = adaptive {experimental} {default} bool ShenandoahVerify = false {diagnostic} {default} intx ShenandoahVerifyLevel = 4 {diagnostic} {default} bool ShenandoahWriteBarrier = true {diagnostic} {default}
其中有一些是diagnostic用的,比如ShenandoahAcmpBarrier、ShenandoahAllocFailureALot、ShenandoahAllocationStallThreshold等Heuristics相關參數
ccstr ShenandoahGCHeuristics = adaptive {experimental} {default} uintx ShenandoahInitFreeThreshold = 70 {experimental} {default} uintx ShenandoahMinFreeThreshold = 10 {experimental} {default} uintx ShenandoahAllocSpikeFactor = 5 {experimental} {default} uintx ShenandoahGarbageThreshold = 60 {experimental} {default} uintx ShenandoahFreeThreshold = 10 {experimental} {default} uintx ShenandoahAllocationThreshold = 0 {experimental} {default} ccstr ShenandoahUpdateRefsEarly = adaptive {experimental} {default}
Heuristics主要用于告訴Shenandoah何時啟動一個GC cycle,其中ShenandoahGCHeuristics用于選擇不同的策略,其可選值有adaptive(默認)、static、compact、passive(diagnostic用)、aggressive(diagnostic用)
adaptive方式主要通過ShenandoahInitFreeThreshold(Initial remaining free heap threshold for learning steps)、ShenandoahMinFreeThreshold(free space threshold at which heuristics triggers the GC unconditionally)、ShenandoahAllocSpikeFactor(How much heap to reserve for absorbing allocation spikes)、XX:ShenandoahGarbageThreshold(Sets the percentage of garbage a region need to contain before it can be marked for collection)來設置合適啟動GC cycle
static方式主要是基于heap occupancy以及allocation pressure來決定是否啟動GC cycle,相關參數有:ShenandoahFreeThreshold(Set the percentage of free heap at which a GC cycle is started)、ShenandoahAllocationThreshold(Set percentage of memory allocated since last GC cycle before a new GC cycle is started)、ShenandoahGarbageThreshold
compact方式是continuous方式的,只要有allocation發生,上一個GC cycle結束之后就啟動新的GC cycle,相關參數有ConcGCThreads(Trim down the number of concurrent GC threads to make more room for application to run)、ShenandoahAllocationThreshold
passive方式是完全passive,當內存耗盡時觸發STW,通常用于diagnostic
aggressive方式是完全active的,上一個GC cycle結束之后就啟動新的GC cycle(有點類似compact方式),不過它會evacuate所有的live objects,通常用于diagnostic
Failure Modes當allocation failure發生的時候,Shenandoah有一些優雅的degradation ladder用于處理這種情況,如下:
Pacing(<10 ms)
ShenandoahPacing參數默認開啟,Pacer用于在gc不夠快的時候去stall正在分配對象的線程,當gc速度跟上來了就解除對這些線程的stall;stall不是無期限的,有個ShenandoahPacingMaxDelay(單位毫秒)參數可以設置,一旦超過該值allocation就會產生。當allocation壓力大的時候,Pacer就無能為力了,這個時候就會進入下一個step
Degenerated GC(<100 ms)
ShenandoahDegeneratedGC參數默認開啟,在這個Degenerated cycle,Shenandoah使用的線程數取之于ParallelGCThreads而非ConcCGThreads
Full GC(>100 ms)
當Degenerated GC之后還沒有足夠的內存,則進入Full GC cycle,它會盡可能地進行compact然后釋放內存以確保不發生OOM實例 啟動參數
-server -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC -XX:+UsePerfData -XX:+ShenandoahRegionSampling -XX:ParallelGCThreads=4 -XX:ConcGCThreads=4 -XX:+UnlockDiagnosticVMOptions -Xlog:age*,ergo*,gc*=infogc日志
[2019-03-21T15:12:53.771-0800][8707][gc] Consider -XX:+ClassUnloadingWithConcurrentMark if large pause times are observed on class-unloading sensitive workloads [2019-03-21T15:12:53.862-0800][8707][gc,init] Regions: 2048 x 1024K [2019-03-21T15:12:53.862-0800][8707][gc,init] Humongous object threshold: 1024K [2019-03-21T15:12:53.863-0800][8707][gc,init] Max TLAB size: 1024K [2019-03-21T15:12:53.863-0800][8707][gc,init] GC threads: 4 parallel, 4 concurrent [2019-03-21T15:12:53.863-0800][8707][gc,init] Reference processing: parallel [2019-03-21T15:12:53.864-0800][8707][gc ] Heuristics ergonomically sets -XX:+ExplicitGCInvokesConcurrent [2019-03-21T15:12:53.864-0800][8707][gc ] Heuristics ergonomically sets -XX:+ShenandoahImplicitGCInvokesConcurrent [2019-03-21T15:12:53.864-0800][8707][gc,init] Shenandoah heuristics: adaptive [2019-03-21T15:12:53.864-0800][8707][gc,heap] Initialize Shenandoah heap with initial size 128M [2019-03-21T15:12:53.865-0800][8707][gc,ergo] Pacer for Idle. Initial: 40M, Alloc Tax Rate: 1.0x [2019-03-21T15:12:53.883-0800][8707][gc,init] Safepointing mechanism: global-page poll [2019-03-21T15:12:53.883-0800][8707][gc ] Using Shenandoah [2019-03-21T15:12:53.884-0800][8707][gc,heap,coops] Heap address: 0x0000000780000000, size: 2048 MB, Compressed Oops mode: Zero based, Oop shift amount: 3 [2019-03-21T15:12:59.530-0800][14083][gc ] Trigger: Metadata GC Threshold [2019-03-21T15:12:59.532-0800][14083][gc,ergo ] Free: 1813M (1813 regions), Max regular: 1024K, Max humongous: 1855488K, External frag: 1%, Internal frag: 0% [2019-03-21T15:12:59.532-0800][14083][gc,ergo ] Evacuation Reserve: 103M (103 regions), Max regular: 1024K [2019-03-21T15:12:59.532-0800][14083][gc,start ] GC(0) Concurrent reset [2019-03-21T15:12:59.533-0800][14083][gc,task ] GC(0) Using 4 of 4 workers for concurrent reset [2019-03-21T15:12:59.533-0800][14083][gc ] GC(0) Concurrent reset 132M->132M(2048M) 0.441ms [2019-03-21T15:12:59.533-0800][15619][gc,start ] GC(0) Pause Init Mark (process weakrefs) (unload classes) [2019-03-21T15:12:59.533-0800][15619][gc,task ] GC(0) Using 4 of 4 workers for init marking [2019-03-21T15:12:59.541-0800][15619][gc,ergo ] GC(0) Pacer for Mark. Expected Live: 204M, Free: 1813M, Non-Taxable: 181M, Alloc Tax Rate: 0.4x [2019-03-21T15:12:59.541-0800][15619][gc ] GC(0) Pause Init Mark (process weakrefs) (unload classes) 7.568ms [2019-03-21T15:12:59.541-0800][14083][gc,start ] GC(0) Concurrent marking (process weakrefs) (unload classes) [2019-03-21T15:12:59.541-0800][14083][gc,task ] GC(0) Using 4 of 4 workers for concurrent marking [2019-03-21T15:12:59.619-0800][14083][gc ] GC(0) Concurrent marking (process weakrefs) (unload classes) 132M->134M(2048M) 78.373ms [2019-03-21T15:12:59.619-0800][14083][gc,start ] GC(0) Concurrent precleaning [2019-03-21T15:12:59.619-0800][14083][gc,task ] GC(0) Using 1 of 4 workers for concurrent preclean [2019-03-21T15:12:59.622-0800][14083][gc ] GC(0) Concurrent precleaning 134M->134M(2048M) 2.397ms [2019-03-21T15:12:59.622-0800][15619][gc,start ] GC(0) Pause Final Mark (process weakrefs) (unload classes) [2019-03-21T15:12:59.622-0800][15619][gc,task ] GC(0) Using 4 of 4 workers for final marking [2019-03-21T15:12:59.625-0800][15619][gc,stringtable] GC(0) Cleaned string table, strings: 13692 processed, 50 removed [2019-03-21T15:12:59.626-0800][15619][gc,ergo ] GC(0) Adaptive CSet Selection. Target Free: 204M, Actual Free: 1914M, Max CSet: 85M, Min Garbage: 0M [2019-03-21T15:12:59.626-0800][15619][gc,ergo ] GC(0) Collectable Garbage: 117M (97% of total), 8M CSet, 126 CSet regions [2019-03-21T15:12:59.626-0800][15619][gc,ergo ] GC(0) Immediate Garbage: 0M (0% of total), 0 regions [2019-03-21T15:12:59.626-0800][15619][gc,ergo ] GC(0) Pacer for Evacuation. Used CSet: 126M, Free: 1811M, Non-Taxable: 181M, Alloc Tax Rate: 1.1x [2019-03-21T15:12:59.626-0800][15619][gc ] GC(0) Pause Final Mark (process weakrefs) (unload classes) 4.712ms [2019-03-21T15:12:59.626-0800][14083][gc,start ] GC(0) Concurrent cleanup [2019-03-21T15:12:59.627-0800][14083][gc ] GC(0) Concurrent cleanup 134M->135M(2048M) 0.132ms [2019-03-21T15:12:59.627-0800][14083][gc,ergo ] GC(0) Free: 1810M (1810 regions), Max regular: 1024K, Max humongous: 1852416K, External frag: 1%, Internal frag: 0% [2019-03-21T15:12:59.627-0800][14083][gc,ergo ] GC(0) Evacuation Reserve: 102M (103 regions), Max regular: 1024K [2019-03-21T15:12:59.627-0800][14083][gc,start ] GC(0) Concurrent evacuation [2019-03-21T15:12:59.627-0800][14083][gc,task ] GC(0) Using 4 of 4 workers for concurrent evacuation [2019-03-21T15:12:59.643-0800][14083][gc ] GC(0) Concurrent evacuation 135M->145M(2048M) 15.912ms [2019-03-21T15:12:59.643-0800][15619][gc,start ] GC(0) Pause Init Update Refs [2019-03-21T15:12:59.643-0800][15619][gc,ergo ] GC(0) Pacer for Update Refs. Used: 145M, Free: 1810M, Non-Taxable: 181M, Alloc Tax Rate: 1.1x [2019-03-21T15:12:59.643-0800][15619][gc ] GC(0) Pause Init Update Refs 0.090ms [2019-03-21T15:12:59.643-0800][14083][gc,start ] GC(0) Concurrent update references [2019-03-21T15:12:59.643-0800][14083][gc,task ] GC(0) Using 4 of 4 workers for concurrent reference update [2019-03-21T15:12:59.652-0800][14083][gc ] GC(0) Concurrent update references 145M->147M(2048M) 9.028ms [2019-03-21T15:12:59.652-0800][15619][gc,start ] GC(0) Pause Final Update Refs [2019-03-21T15:12:59.652-0800][15619][gc,task ] GC(0) Using 4 of 4 workers for final reference update [2019-03-21T15:12:59.653-0800][15619][gc ] GC(0) Pause Final Update Refs 0.489ms [2019-03-21T15:12:59.653-0800][14083][gc,start ] GC(0) Concurrent cleanup [2019-03-21T15:12:59.653-0800][14083][gc ] GC(0) Concurrent cleanup 147M->21M(2048M) 0.088ms [2019-03-21T15:12:59.653-0800][14083][gc,ergo ] Free: 1924M (1924 regions), Max regular: 1024K, Max humongous: 1840128K, External frag: 7%, Internal frag: 0% [2019-03-21T15:12:59.653-0800][14083][gc,ergo ] Evacuation Reserve: 103M (103 regions), Max regular: 1024K [2019-03-21T15:12:59.653-0800][14083][gc,ergo ] Pacer for Idle. Initial: 40M, Alloc Tax Rate: 1.0x [2019-03-21T15:17:59.666-0800][14083][gc ] Trigger: Time since last GC (300009 ms) is larger than guaranteed interval (300000 ms)gc visualizer
有個shenandoah-visualizer工具可以用來可視化ShenandoahGC,可視化效果如下:
Shenandoah是一款concurrent及parallel的垃圾收集器;跟ZGC一樣也是面向low-pause-time的垃圾收集器,不過ZGC是基于colored pointers來實現,而Shenandoah GC是基于brooks pointers來實現;與G1 GC相比,G1的evacuation是parallel的但不是concurrent,而Shenandoah的evacuation是concurrent,因而能更好地減少pause time;與G1 GC一樣,ShenandoahGC也是基于region的GC,不同的是ShenandoahGC在邏輯上沒有分代,因而就沒有young/old
Shenandoah的GC cycle主要有Snapshot-at-the-beginning concurrent mark包括Init Mark(Pause)、Concurrent Mark、Final Mark(Pause)、Concurrent evacuation、Concurrent update references (optional)包括Init update Refs(Pause)、Concurrent update Refs、Final update Refs(Pause);其中Final Mark或者Final update Refs之后都可能進行Concurrent cleanup,進行垃圾回收,reclaims region
Heuristics主要用于告訴Shenandoah何時啟動一個GC,其中ShenandoahGCHeuristics用于選擇不同的策略,其可選值有adaptive(默認)、static、compact、passive(diagnostic用)、aggressive(diagnostic用);另外當allocation failure發生的時候,Shenandoah有一些優雅的degradation ladder用于處理這種情況,包括Pacing(<10 ms)、Degenerated GC(<100 ms)、Full GC(>100 ms)
docShenandoah GC
JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
Changes to Garbage Collection in Java 12
9 Garbage-First Garbage Collector
G1GC – Java 9 Garbage Collector explained in 5 minutes
devoxx-Nov2017-shenandoah(部分圖片來源于此pdf)
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/73823.html
摘要:序本文主要研究一下的使用。執行順序的話,先再,最后。內置了相關,可以用來解析文件,也可以在應用程序自定義事件發布出來可以采用命令啟動,也可以使用的開頭的命令在運行時操作,非常方便 序 本文主要研究一下Java Flight Recorder的使用。 命令 主要有5個命令,configure、check、start、dump、stop。執行順序的話,先start再dump,最后stop。...
摘要:的這個特性新增了兩個參數分別是及,設置為的話,表示禁用。語法層面引入了版本的層面引入了,引入,讓支持,對等新增方法方面引入了版本的,不過的沒有另外主要對及進行了改進其中對支持了,默認是開啟,使用可以禁用對于則新增支持以及特性 Java語言特性系列 Java5的新特性 Java6的新特性 Java7的新特性 Java8的新特性 Java9的新特性 Java10的新特性 Java11的新...
摘要:從版本開始,不再單獨發布或者版本了,有需要的可以自己通過去定制官方解讀官方細項解讀穩步推進系列六的小試牛刀一文讀懂的為何如此高效棄用引擎 Java語言特性系列 Java5的新特性 Java6的新特性 Java7的新特性 Java8的新特性 Java9的新特性 Java10的新特性 Java11的新特性 Java12的新特性 Java13的新特性 序 本文主要講述一下Java11的新...
序 本文主要研究一下Java11的HttpClient的基本使用。 變化 從java9的jdk.incubator.httpclient模塊遷移到java.net.http模塊,包名由jdk.incubator.http改為java.net.http 原來的諸如HttpResponse.BodyHandler.asString()方法變更為HttpResponse.BodyHandlers.of...
摘要:本文記錄了自己工作中所用到的自動化部署偷懶歷程,有需要的程序汪自行收藏。結論本文僅適合在自己負責的項目中簡單進行自動化的部署偷懶,基于本文,可以擴展發揮做一個自動化部署系統。 簡述 作為一只后臺狗,在使用Java為技術棧來開發后端服務應用的時候,或多或少的都需要自己手動部署。一開始,覺得寫完一次自己手動部署到服務器上,還覺得新鮮感還不錯,畢竟看著黑黑的terminal有種莫名的興奮。后...
閱讀 774·2023-04-25 15:13
閱讀 1395·2021-11-22 12:03
閱讀 824·2021-11-19 09:40
閱讀 1906·2021-11-17 09:38
閱讀 1711·2021-11-08 13:18
閱讀 654·2021-09-02 15:15
閱讀 1763·2019-08-30 15:54
閱讀 2633·2019-08-30 11:12