æåãªã€ã³ã¿ãŒããã掻å家ã®ã¢ã¬ã¯ã»ã€ã»ã·ãã¬ãã¯æè¿ã以äžãæçš¿ããŸãã ïŒ
ãHotSpotã«GCãå®è£ ããã«ããã¹ãŠã®5ç§ã¬ã€ãã³ã·ãã³ãããŒã¯ãç²åŸããŠã¿ãŸãããã 100 GBã®ããŒãã¯10ç§éåç¶ããã®ã«ååã§ããã
ã¯ãŒã«ã§çŽ æŽããããžã§ãŒã¯-ç§ãã¡ã¯èããŠé£ã¹ã«è¡ããŸããã ãããŠããããã³ããæ»ã£ãåŸã圌ãã¯ããã«ãã¹ãŠã®ã°ããºã飲ã¿èŸŒãã ãã¹ã¯ãªãŒã³ã·ã§ãããããã«çŸããããã ïŒ
ãŸããç§ãã¡ã¯çããã©ãã·ã§ããã®æ¹æ³ãç¥ã£ãŠããŸãããïŒ
ãããŠ
ã³ãŒããç»å Ž
ãããŠãç©äºã¯æ¥æ¿ã«å€åãå§ããŸããã ã·ããªãŒããäœããäžè¬ã«å ¬éãããšã1ãæåŸã«ã¯ãã§ã«ã€ã³ã¿ãã¥ãŒã§ããã«ã€ããŠè³ªåããããšã«ãªã£ãŠããŸã ãéããæã§ãjavanetãéããšã...
JEPïŒEpsilon GCïŒä»»æã®äœãªãŒããŒãããã®ã¬ããŒãžïŒéïŒã³ã¬ã¯ã¿ãŒ
次ã«ãããã«æžãããŠããããšãç°¡åã«ç¹°ãè¿ããŸãã ç§ã¯æ£ç¢ºãªç¿»èš³ãããã®ãé¢åã§ãããææ³ã®æŠå£«ã¯ééããŠå ãèªãããšãã§ããŸã:)
ãªããŠãã£ããããªã¢ã¢ïŒ
ãã®æ©èœã§ã¯ãGCã¯æ°ããã¡ã¢ãªã®å²ãåœãŠã®ã¿ãèæ ®ããã¹ããŒãã¬ããŒãžã³ã¬ã¯ã·ã§ã³æŠç¥ãã¹ã³ã¢ãªã³ã°ã§ããŸãã 䜿çšå¯èœãªããŒããçµäºãããšããã«ãJVMåæ¢æé ãéå§ãããŸãã
ç®æš
å²ãåœãŠå¯èœãªã¡ã¢ãªã®éãå¶éããŠãå®å šã«ããã·ããªGCå®è£ ãæäŸããŸãã ãã®èŠè¿ããšããŠããã®ãããªGCã®ããã©ãŒãã³ã¹ã§æãäœããªãŒããŒããããåŸãããŸãã å®è£ ã¯ãä»ã®GCã«åœ±é¿ãäžããããJVMã«å€§ããªéããçãããããããã¹ãã§ã¯ãããŸããã
ããæ°
ããã©ãŒã®ãããã¯ã®äœå®¶ã®æš©å©ã«ã€ããŠãç§ã¯å°ãæšæž¬ããŸãã å®éããã¹ãŠã®äŒæ¥ãGoogleã§ãããšã¯éããŸããã 誰ããæå°éã®å®çšçãªè£œåãäœããããšæã£ãŠããã®éçºã®äžè©±ãããã ãã§ãã ããããå°æ¥çã«ã¯ããã¹ãŠãããé«åºŠãªãã©ãããã©ãŒã ã§æžãçŽãå¿ èŠããããŸãã ããããéçºè ã¯æ©ããéã䜿ãæãããŸãã ãããè¡ãã«ã¯ãG1ã®ãããªå·šå€§ãªãããžã§ã¯ããããã«ãããžã§ã¯ãã«ãã©ãã°ããå¿ èŠã¯ãããŸããã
ããŠãåè«ã¯ããŠãããæ¬æãããã«é²ããŸãããïŒ Epsilonã®ãããªãã®ãå®éã«åœ¹ç«ã€å Žåãå°ãªããšã4ã€ãããšæ³å®ãããŠããŸãã
ãŸããEpsilonã䜿çšãããšãä»ã®ããé«åºŠãªGCãæ¯èŒã§ããŸããããã¯ãã¢ã»ã³ããªã¡ã«ããºã èªäœã«ãã£ãŠå°å ¥ããããã°ã®çºèŠãšæ€åºã«åœ¹ç«ã¡ãŸãã
第äºã«ãçã®Baytebo ïŒããã¯åªãã§ã¯ãªãçšèªã§ãïŒïŒJavaã¢ããªã±ãŒã·ã§ã³ã®å Žåããã®ãããªGCã¯åã«çœ®ãæããããŸããã 次ã®ãã£ãŒããããŸãã¯ã¹ããŒããã€ã¬ã®ãã¡ãŒã ãŠã§ã¢ãæžããŠãããšæ³åããŠãã ãããã¬ããŒãžã³ã¬ã¯ã·ã§ã³ã®å®éã¯ã¢ããªã±ãŒã·ã§ã³ã®ãã°ãšèŠãªãããŸããã¬ããŒãžã³ã¬ã¯ã·ã§ã³ã®ä»£ããã«ããã©ãŒã«ããæ¹ãè³¢æã§ããã¹ããŒããã©ã³ãµãŒã¯ä»ã®ããŒã/ VMã®è² è·ãäžåè¡¡ã«ããŸã ãã©ã³ã¹ã®åããVMã®ãããã¯ãŒã¯ã䜿çšããŠããã€ã¬ã¯äœãæºåããå¿ èŠããããŸããïŒããããããããããã«ããã€ã¬ã眮ãæããŸãã ããã«ãã€ãã·ãã³ã䜿çšãããšãäžå¿ èŠãªéå£ãåãé€ãããšãã§ããŸã-ã±ãŒãã®ãã€ã©ã€ãã¯å®ç§ãªããã©ãŒãã³ã¹ã§ãã
第äžã«ãOpenJDKèªäœããã¹ãããããã«ããã®ã¡ã¢ãªã®è² è·äžå€éããã¹ãããããã«ãå²ãåœãŠãããã¡ã¢ãªãå¶éããæ段ããããšäŸ¿å©ã§ãã çŸåšããã®ãããªããŒã¿ã¯MXBeanããååŸãããããGCãã°ã«ãã£ãŠè§£æãããŸãã GCãéãããæ°ã®å²ãåœãŠã®ã¿ããµããŒãããŠããå Žåãããã¯OpenJDKéçºè ã®ãã¹ããæ¬åœã«ç°¡åã«ããŸãã ïŒã»ãšãã©ã®å Žåããã®èšäºã®èªè ã¯OpenJDKéçºè ã§ã¯ãããŸãããã次ã®ã€ã³ã¿ãã¥ãŒã§OpenJDKã«åæ Œããããšãã§ããŸããïŒ
第4ã«ãããã¯VM-GCã€ã³ã¿ãŒãã§ãŒã¹ã®çµ¶å¯Ÿæå°å€ã確ç«ããã®ã«åœ¹ç«ã¡ããã®åäœã®æ£ç¢ºãã®èšŒæãšããŠåœ¹ç«ã¡ãŸãã ããšãã°ã JDK-8163329ïŒãGCã€ã³ã¿ãŒãã§ãŒã¹ãïŒã®å Žåã«æçšãªãã®ïŒåç §ã«ãããããã¹ãã®å£ãåžæè ã¯Habrã«ç¿»èš³ã§ããŸãïŒã
詳现
ãŠãŒã¶ãŒã«ãšã£ãŠãEpsilonã¯-XXïŒ+ UnlockExperimentalVMOptions -XXïŒ+ UseEpsilonGCã䜿çšããŠæ¥ç¶ãããä»ã®OpenJDK GCã®ããã«èŠããŸãã
Epsilonã¯ãåäžã®é£ç¶ããã¡ã¢ãªã«ç·åœ¢çã«ã¡ã¢ãªãå²ãåœãŠãŸãã ããã«ãããVMã®æ¢åã®ã³ãŒããåå©çšã§ããããã¯ããªãŒTLABïŒã¹ã¬ããããŒã«ã«ã¢ãã±ãŒã·ã§ã³ãããã¡ïŒã®æãåçŽãªã³ãŒãã䜿çšã§ããŸãã TLABãçºè¡ãããšãããã»ã¹ã®åžžé§ã¡ã¢ãªãå®éã«å²ãåœãŠãããéã«ç¶æã§ããŸãã ãã®ç¶æ³ã§ã¯ãã¡ã¢ãªãšTLABã®å€§ããªéšåã®å²ãåœãŠã¯ããã»ã©å€ãããªããããåãã³ãŒãã§åŠçãããŸãã
Epsilonã¯å®éã®ã¢ã»ã³ããªãµã€ã¯ã«ãè¡ããªããããEpsilonã§äœ¿çšãããäžé£ã®ããªã¢ã¯å®å šã«ç©ºã§ãããããã£ãŠãEpsilonã¯ãªããžã§ã¯ãã®ã°ã©ãããªããžã§ã¯ãã®ããŒãã³ã°ããªããžã§ã¯ãã®ã³ããŒããã®ä»ãã¹ãŠã®äžèŠãªãžã£ã³ã¯ã«ã€ããŠæ°ã«ããŸããã çéå ¥ããããã©ãŒãã³ã¹ã®ã¿ïŒ
ã©ã³ã¿ã€ã ã€ã³ã¿ãŒãã§ã€ã¹ã®å¯äžã®éèŠãªéšåã¯EpsilonãTLABãçºè¡ããå Žæã§ããããããã®ããã©ãŒãã³ã¹ã¯äž»ã«TLABã®ãµã€ãºã«äŸåããŸãã ä»»æã®å€§ããªTLABãšä»»æã®å€§ããªããŒãããããããããã©ãŒãã³ã¹ãªãŒããŒãããã¯ä»»æã®å°ããªæ£ã®æ°ã§ãããããEpsilonãšããååã«ãªããŸãã Golangã®äœæè ãšãŠãŒã¶ãŒã¯ãgreenæã®çã§ç·è²ã«å€ããå§ããäžè¬çãªé«ªãåŒãã¡ããããšããããŸãã
ããããçµäºãããšãTLABãçºè¡ããããšã¯ã§ããªããªããäœããã®æ¹æ³ã§å埩ããããšã¯äžå¯èœã«ãªããŸãããããããŠãšã©ãŒã¬ããŒããå°å·ããã ãã§ãã ããã§ã¯ãä»ã®GCãè¡ãããšãšåæ§ã®ããšãã§ããŸãã
- éã¿ã®ãã説æã§OutOfMemoryErrorãã¹ããŒãã
- æããã³ãããŸãïŒãã€ãã®ããã«ã-XXã§ãªã³ã«ããŸãïŒ+ HeapDumpOnOutOfMemoryError
- JVMããããããããªãã·ã§ã³ã§äœããã®å€éšã¢ã¯ã·ã§ã³ïŒéåžžã-XXïŒOnError = ...ïŒãå®è¡ããããšã¯å°é£ã§ããããšãã°ããããã¬ãŒã®èµ·åãç£èŠã·ã¹ãã ãžã®éç¥ããŸãã¯å°ãªããšãSportlotoãžã®æçŽã®æžã蟌ã¿ãªã©ã§ãã
ãããã¿ã€ãã¯è»œè² è·ã§ãã¹ããããé«è² è·ã§èœäžããäºå®ã§ããã
UFOããããæŸããŸã§ãã³ãŒãã¯ãŸã ããã«ãããŸã ïŒ http : //cr.openjdk.java.net/~shade/epsilon/
代æ¿æ¡
代æ¿æ段ã¯ãããŸããã å°ãªããšãããã¹ãŠã®éå£ãåæžãããŸããã çå£ã«ã
çã«ãŠããŒã¯ãªGCãšã®åºäŒãããåŸãããåã³ãšå¹žçŠæããEpsilonã§äœ¿çšãããŠããè¬ç©ã®å¹žçŠæãšäŒŒãŠããã䌌ããããªãã£ããæãçã¿åºãããšãé¡ã£ãŠããŸãã
ãããã«ãããããªã¢ã«åé¡ããªãå Žåãã·ãªã¢ã«ãŸãã¯ãã©ã¬ã«ïŒå€ãïŒGCã¯åæ§ã®ããã©ãŒãã³ã¹ãããã¡ã€ã«ãæäŸã§ããŸã-ãã¡ãããã¬ããŒãžã³ã¬ã¯ã·ã§ã³ãéå§ãããªãããã«æ§æã§ããå ŽåïŒããšãã°ã巚倧ãªè¥ãgenå€ã®èšå®ããªãé©å¿ãã¥ãŒãªã¹ãã£ãã¯ãªã©ïŒã éžæè¢ã®æ°ãèãããšãæ©èœããããšãä¿èšŒããã®ã¯å°é£ã§ãã
Shenandoahãªã©ã®ææ°ã®GCãããã«æ¹åãããšãå®å šã«ããŒãªãã¬ãŒã·ã§ã³ã®GCã«æ¯ã¹ãŠãªãŒããŒããããç¡èŠã§ããã»ã©å°ããã¬ãã«ãŸã§æžå°ããå¯èœæ§ããããŸãã ãããçºçããå Žåã§ããEpsilonãå éšæ©èœ/ã¹ãã¬ã¹ãã¹ãã«äœ¿çšã§ããŸãïŒåŒéæã«å éšGCãã¹ããå®è¡ãããå ŽåïŒã
ãããæ©èœããŸããïŒ ãŸã£ããåæ³ã§ããïŒ
åŸæ¥ã®ãã¹ãã¯nafigãå¿ èŠãšãããEpsilonã«ã¯é©ããŠããŸããã ãããã®ã»ãšãã©ã¯ãããªããä»»æã®éã®ãŽããæããããšãã§ãããšä¿¡ããŠããŸãã ãããã£ãŠãEpsilonããã¹ãããã«ã¯ãæ°ãããã¹ããå®è¡ããå¿ èŠããããŸããã¡ã¢ãªå²ãåœãŠãå°ãªãã¿ã¹ã¯ã§åäœããããšã確èªããå¿ èŠããããŸããããŒãã䜿ãæãããããšããšã«ããã§ã¯ãªããäºæž¬ã©ããã«äœäžããŸãã hotspot / gc / epsilonã«ããæ°ããååãªjtregãã¹ãã®æ£ç¢ºæ§ãæ€èšŒããŸãã
Epsilonã®éçºäžã«å®è¡ããã1åéãã®ãã§ãã¯ã¯ãã€ã³ã¿ãŒããªã¿ãŒC1ããã³C2ã®ããã©ãŒãã³ã¹ç¹æ§ã瀺åããã®ã«ååã§ãã éçºã®æåããçŸåšã®å®è£ ã¯ããå®å®ããŠãããã¹ã¿ãŒãªãã¹ãã³ã³ã¯ãªãŒããã³ã«ãŒã匷åãããããããã«ãã¹ãããå¿ èŠã¯ãããŸããã
ãªã¹ã¯ãšä»®å®
ãŠãŒãã£ãªãã£ãšãµããŒãã®ã³ã¹ãã ãšã«ãã誰ããããå¿ èŠãšããªãã®ã§ããã®å®è£ ã¯ããããã®äŸ¡å€ããªããšä»®å®ããããšãã§ããŸãã äžæ¹ãçµéšã«åºã¥ããŠãå€ãã®Javaãšã³ã·ã¹ãã ãã¬ãŒã€ãŒã¯ãç¬èªã®ã«ã¹ã¿ã JVMããGCãåé€ããå®éšãè¡ããŸããã ãããã£ãŠãæ¢è£œã®ããŒãªãã¬ãŒã·ã§ã³GCãããå Žåãããã¯ã³ãã¥ããã£ã®ãã®éšåã«åœ¹ç«ã¡ãŸãã ãŸãããŸãã¯å°ãªããšãããŸã äž»æµã§ã¯ãªããšãã«ããŒãªãã¬ãŒã·ã§ã³GCã䜿çšããããšãèªãã«æãããšãã§ããŸãã å®è£ ã®å šäœçãªäœã³ã¹ããèãããšããªã¹ã¯ã¯æå°éã§ãã
åœæ°ã®æåŸ ã ãã®ã¬ããŒãžã³ã¬ã¯ã¿ãŒãå®éã«ã¬ããŒãžãåéããªãããšãèãããšã誰ãããããå±éºãªæ £è¡ãšèãããããããŸããã æ¬çªç°å¢ã§ã€ãã·ãã³ã誀ã£ãŠãªã³ã«ãããšãããŒãããªãŒããŒãããŒããçŽåŸã«ãäžå¿«ãªãã¥ãŒã¹ã衚瀺ãããŸãã èè ã¯ãæ©èœãå®éšçãã©ã°ã®äžã§å®è¡ãããŠããéãã€ãŸã-XXïŒ+ UnlockExperimentalVMOptionsãå¿ èŠãªéãå®éã®ãªã¹ã¯ã¯ãªããšæ³å®ããŠããŸãã
å®è£ ã®è€éãã äžè¬ã«ãä»ã®ãµãã·ã¹ãã ã§ã¯ãã³ãŒããåœåã®äºæ³ãããå€æŽããå¿ èŠãããç¶æ³ãæ³åã§ããŸããããšãã°ãã³ã³ãã€ã©ãŒãç¹å®ã®ãã©ãããã©ãŒã ã®ããã¯ãšã³ããªã©ã§ãã äžæ¹ããããã¿ã€ãã¯ãæåããã®ãã®ãããªãã¹ãŠã®å€æŽãå³å¯ã«åé¢ãããããšã瀺ããŠããŸãã ãããæ¬åœã®ãªã¹ã¯ã§ããããšãå€æããå Žåãäžèšã®JDK-8163329ïŒãGCã€ã³ã¿ãŒãã§ãŒã¹ãïŒã圹ç«ã¡ãŸãã
äŸåé¢ä¿
å€éšã³ãŒãã®å€æŽåæ°ãæžããããããã®äœæ¥ã¯JDK-8163329ïŒãGCã€ã³ã¿ãŒãã§ã€ã¹ãïŒã«äŸåããŠããŸãã äžè¬çãªã³ãŒãã®å€æŽãæå°éã§ããã°ãGCã€ã³ã¿ãŒãã§ã€ã¹ãå€æŽããå¿ èŠã¯ãããŸããã
ãããã«
æ£çŽãªãšãããç§ã¯ããããã¹ãŠæžãã®ã«ãšãŠãç²ããŠããŸãã ããã«çœ®ããŠãããŠãã ããã åãããªããšå ±ã«ãããŸãããã«ïŒ ã¬ããŒãžã³ã¬ã¯ã·ã§ã³ã®ãªãJavaã§ãæ°ããæããæªæ¥ã«å¿ èŠã«ãªããŸãã
PSïŒShipilevã«ã¯ãã®æçš¿ãžã®ãªã³ã¯ãããã圌ã¯ããªãããã©ããŒããŠããŸãããŠãŒã¶ãŒå