èªåã¡ã¢ãªç®¡çã¡ã«ããºã ã§æãäžè¬çã«äœ¿çšããããã©ãããã©ãŒã ã®1ã€ã¯Javaã§ãã ããããèªåã¡ã¢ãªç®¡çã¯ãããã°ã©ãã®ããŒãã¯ãŒã¯ã«å¿«é©ãããããããã ãã§ãªããããé »ç¹ã«çŽé¢ããªããã°ãªããªããã®æ¬ ç¹ããããããŸããã èšå€§ãªæ°ã®ãã©ã³ã¶ã¯ã·ã§ã³ãåŠçã§ããææ°ã®ãã«ããŠãŒã¶ãŒã¢ããªã±ãŒã·ã§ã³ã«ã¯ãããªãã®ããŒããŠã§ã¢ãªãœãŒã¹ãå¿ èŠã§ããããã®ãµã€ãºã¯ãããŸã§æ³åããããšããå°é£ã§ããã ãã ããåé¡ã¯ãããã®ãªãœãŒã¹ã®ãµã€ãºã§ã¯ãªããäºå®ãã»ãšãã©ã®ææ°ã®JVMã«ååšããã¬ããŒãžã³ã¬ã¯ã¿ãŒã¯ã倧éã®ã¡ã¢ãªã§å¹ççã«åäœã§ããªããšããããšã§ãã
ã¬ããŒãžã³ã¬ã¯ã¿ãŒã¯ã¡ã¢ãªãã¯ãªã¢ããããã»ã¹ãèªååããããã°ã©ããŒã®å€ãã®é çã®çš®ãåãé€ãã代ããã«1ã€ã®å€§ããªåé¡ãå°å ¥ããŸã-ã©ã®GCã¡ã«ããºã ã䜿çšããã©ã®ããŒããµã€ãºãæé©ãïŒ å¿ èŠä»¥äžã«ããŒããäœæããäžå®ã®ãäžçåæ¢ãã®äžæåæ¢ã«é¥ã£ãå Žåãå¿ èŠä»¥äžã«äœæããªããšããã¡ã¢ãªäžè¶³ããšã©ãŒã衚瀺ãããŸãã ããã¯ãã¹ãŠãããŒãã®ãµã€ãºã倧ãããªããšãã¬ããŒãžã³ã¬ã¯ã¿ãŒãã¡ã¢ãªãã¯ãªã¢ããŠããã©ã°ããã®ã«æéãããããšããäºå®ã«ãã£ãŠè€éã«ãªããŸãã ããã«ããã2ã4GBãè¶ ããããŒãã䜿çšããå Žåãããžãã¹ã«ãšã£ãŠäžæåæ¢ãéèŠã«ãªããæ°ç§ãŸãã¯æ°åãããããšããããŸãããã®éãã¡ã¢ãªã¯ãªãŒãã³ã°ããã»ã¹ãå®äºãããŸã§ãã¹ãŠã®ã¹ã¬ããã匷å¶çã«åŸ æ©ããŸãã å¿çæéãé·ããªããäžå®å®ã«ãªããã¹ã«ãŒããããäœäžããŸãã倧èŠæš¡ãªWebããŒã¿ã«ãé»ååååŒãŸãã¯éèŠãªããžãã¹ã¯ãªãã£ã«ã«ãªã¢ããªã±ãŒã·ã§ã³ã®åéã§åãäŒæ¥ã§ã¯ãããã¯åãå ¥ããããŸããã
倧ããªãµã€ãºã®ããŒãaã«å¯ŸåŠããã«ã¯ãããã€ãã®æ¹æ³ããããŸãããã®ãã¡ã®1ã€ã¯ãæ°åãŸãã¯æ°çŸã®ã€ã³ã¹ã¿ã³ã¹ããããã€ããããããŒãaãšãªã¢å€ã«ããŒã¿ãä¿åãããããããšã§ãã ãã®èšäºã§ã¯ãããã«è§Šããããªãã®ã§ãä»åŸã®è°è«ã®ããã«æ®ããŠãããŸãã ãããã®ã¡ãœããã¯ãããããå®çŸããããã«å¿ èŠãªéçºè ãšç®¡çè ã®å€ãã®äœæ¥ãæå³ãããããéåžžã«é«äŸ¡ã§ãã ç§ãã¡ã¯ãJVMã®ãã¬ãŒã ã¯ãŒã¯å ã«çãŸãããæéããç¥çµããéãè²»ãããããµããŒãã®ããã®ãèŠåŽããåé¿çãæãã€ããŸããã
äžè¬çãªJVMã®GCã«ã¯ããã€ãã®åäœã¢ãŒããããããããã®ããã€ãã¯ããã¹ãŠã®ã¹ã¬ãããåæ¢ãããããããäžçåæ¢ãã®äžæåæ¢ãççž®ããããã«ç¹å¥ã«èšèšãããŠããããšã¯åšç¥ã®äºå®ã§ãã ããã§ããæè¡çãªçç±ã§ãããã®äžæåæ¢ãé€å€ããããšã¯ã§ããŸãããã1ã€äŸå€ããããŸããããã«ã€ããŠã¯ä»¥äžã§èª¬æããŸãã ã€ãŸããæè¯ã®å Žåã§ããGCãã¡ã¢ãªã®ã¯ãªã¢ãå®äºãããŸã§ã¹ã¬ããã¯åŸ æ©ããå¿ èŠããããŸãã ãŸããŸãåãå ¥ããããªããªãããšãå€ããããžãã¹ã¯åŸ ã€ããšãã§ããŸããã
ãã®èšäºã§ã¯ãæãäžè¬çãªJVMã®æŠèŠãç°¡åã«èª¬æãããšãšãã«ããããã®JVMã倧ããªããŒããæã€GCãå¹æçã«æ©èœãããããã«æäŸããã¡ãœããã«ã€ããŠèª¬æããŸãã ãªãœãŒã¹ã®èšªåè ã¯JVMã®ããŒãã®æŠå¿µã«ç²ŸéããŠããããããäœã§ããããç¥ã£ãŠãããšæããŸãã ãªããžã§ã¯ãã®çæã«ã€ããŠèª¬æããããšã«ãæå³ããããŸãããè¥ãäžä»£ã«å±ãããªããžã§ã¯ãã¯ãå€ãã®å Žåå°éäžèœã«ãªããã¡ã¢ãªããåé€ããããšæ³å®ãããããšã«æ³šæããŠãã ããã ããŒãã®æç»ãè¡ããŸãïŒ
äœæ¥ã§GCã䜿çšããäž»ãªã¢ã«ãŽãªãºã ïŒ
ããŒã¯ã¹ã€ãŒãã³ã³ãã¯ã
ãããŒã¯ãïŒæªäœ¿çšã®ãªããžã§ã¯ããããŒã¯ããŸãã
ã¹ã€ãŒãïŒãããã®ãªããžã§ã¯ãã¯ã¡ã¢ãªããåé€ãããŸãã
ãã³ã³ãã¯ããïŒãªããžã§ã¯ãã¯ãã³ã³ãã¯ããã§ã空ãã¹ããããå æããŸããããã«ãããã倧ããªããªããžã§ã¯ããäœæããå¿ èŠãããå Žåã«ã¹ããŒã¹ã解æŸãããŸãã
3ã€ã®ã¹ããããã¹ãŠãéããŠããäžçãåæ¢ãããäžæåæ¢ããããŸãã
ã³ããŒã³ã¬ã¯ã¿ãŒ
ãfromãããã³ãtoãé åã䜿çšããŠã1ã€ã®ãã¹ã§3ã€ãã¹ãŠã®ã¢ã¯ã·ã§ã³ãå®è¡ããŸãã ããã¯æ¬¡ã®ããã«çºçããŸããäœæ¥ã®éå§æã«ããµãã€ããŒã¹ããŒã¹ã®1ã€ã§ãããToãã¯ç©ºã§ããã1ã€ã®ãFromãã«ã¯ä»¥åã®ã¢ã»ã³ããªãçãæ®ã£ããªããžã§ã¯ããå«ãŸããŸãã ã¬ããŒãžã³ã¬ã¯ã¿ãŒã¯ãEdenã§çããŠãããªããžã§ã¯ããæ€çŽ¢ããŠToã¹ããŒã¹ã«ã³ããŒããçããŠãããè¥ããïŒã€ãŸããæå®ãããæ°ã®ã¬ããŒãžã³ã¬ã¯ã·ã§ã³ãæ®ããŠããªã人ïŒãFromã¹ããŒã¹ããã³ããŒããŸãã å®å®ããã®å€ããªããžã§ã¯ãã¯ãå€ãäžä»£ã«ç§»åããŸãã ã¢ã»ã³ããªãFrom spaceããã³To spaceå€æŽããŒã«ã®åŸãEdenãšãªã¢ã¯ç©ºã«ãªããOldäžä»£ã®ãªããžã§ã¯ãã®æ°ãå¢å ããŸãã çããŠãããªããžã§ã¯ãToã®ã³ããŒäžã«ã¹ããŒã¹ããã£ã±ãã«ãªããšãçãæ®ã£ãã¬ããŒãžã³ã¬ã¯ã·ã§ã³ã®æ°ã«é¢ä¿ãªããToã¹ããŒã¹ã«ååãªã¹ããŒã¹ããªãã£ãEdenããã³Fromã¹ããŒã¹ã®æ®ãã®çããŠãããªããžã§ã¯ããOldäžä»£ã«ç§»åããŸãã
ãã®ã¢ã«ãŽãªãºã ã䜿çšãããããã¬ããŒãžã³ã¬ã¯ã¿ãŒã¯ãã¹ãŠã®çããŠãããªããžã§ã¯ããããã¡ã¢ãªé åããå¥ã®ã¡ã¢ãªé åã«ã³ããŒããã ããªã®ã§ããã®ãããªã¬ããŒãžã³ã¬ã¯ã¿ãŒã¯ã³ããŒãšåŒã°ããŸãã æããã«ãã³ããŒã¬ããŒãžã³ã¬ã¯ã¿ãŒãæ©èœããããã«ã¯ãã¢ããªã±ãŒã·ã§ã³ã«ã¯åžžã«ã©ã€ããªããžã§ã¯ããã³ããŒããã空ãã¡ã¢ãªé åãå¿ èŠã§ãããã®ãããªã¢ã«ãŽãªãºã ã¯ãã¢ããªã±ãŒã·ã§ã³ã¡ã¢ãªã®åèšãµã€ãºã«å¯ŸããŠæ¯èŒçå°ããã¡ã¢ãªé åã«äœ¿çšã§ããŸãã
æ¢åã®GCã®äž»ãªæ¬ ç¹ã¯ãäžæåæ¢ã®å¿ èŠæ§ã§ãã ãããã®äžæåæ¢ã¯ãã¡ã¢ãªã®æçåã«ããé¿ããããªãã€ãã³ãã®çµæã§ãã ãããããã»ãŒåæãïŒã»ãšãã©ã®å ŽååæïŒã¬ããŒãžã³ã¬ã¯ã·ã§ã³ã¢ã«ãŽãªãºã ã䜿çšããŠããé ããæ©ãããå€ãäžä»£ã«å±ããé åãéåžžã«æçåãããæ°ãããªããžã§ã¯ãã®ã¡ã¢ãªéãäžååã«ãªããšããäºå®ã«ééããŸãããmark-sweep-compactãã¢ã«ãŽãªãºã ã®åŒã³åºãã«ã€ãªãããã¢ããªã±ãŒã·ã§ã³ãåæ¢ããŸãïŒãã®ã€ãã³ããæéå ã«é ãããæ¹æ³ããã1ã€ãããŸããããã«ã€ããŠã¯åŸã§è©³ãã説æããŸãïŒã ãäžçãæ¢ãããäžæåæ¢ãåŒãèµ·ããå¥ã®ã¿ã¹ã¯ã¯ãã©ãã«ä»ãã§ãã ã»ãšãã©ã®äžŠè¡GCã¯ã2ã€ã®æ®µéã§çããŠãããªããžã§ã¯ããããŒã¯ããŸã-æåã®æ®µéã¯ãã¹ã¬ããã®åäœãšåæã«ããŒã¯ãå«ã¿ã䞊è¡ããŒã¯ãšåŒã°ããŸãã 2çªç®ã®æ®µéã¯åã©ãã«ä»ãïŒæ³šéïŒã§ããæåã®æ®µéãéãããšãã«ãã¢ããªã±ãŒã·ã§ã³ããªã³ã¯ãå€æŽããããæ°ãããªããžã§ã¯ããäœæãããããå¯èœæ§ããããããããã確èªããå¿ èŠããããŸãã ãã®æç¹ã§ãGCã¯ãäžçãåæ¢ãããäžæåæ¢ãèšå®ããäœãå€æŽããããããã§ãã¯ããŸãã ãã®ã¢ãããŒãã«ãããå°æ°ã®çªç¶å€ç°ã§ãäžçãåæ¢ãããããŒãºã®åèšæéãççž®ã§ããŸãããå€æ°ã®ãªããžã§ã¯ãã絶ããäœæããã³å€æŽãããŠããå Žåã¯ããŸã圹ã«ç«ã¡ãŸããã
ããã§ã¯ãæãäžè¬çãªGCã®è¡šã瀺ããŸãã
ãã¢ããªã·ãã¯ãã¯ãäžä»£å šäœãéè·¯ã§æµåãããªããã°ãªããªãããšãæå³ããŸãã
ãã»ãšãã©ã®å Žåãåæã-ã»ãšãã©ã¯åæã§ãåæãšã¯ããã¢ããªã±ãŒã·ã§ã³ã¹ã¬ããã®æäœããšããèæ¯ãæããŸãã
Javaä»®æ³ãã·ã³ | ã³ã¬ã¯ã¿ãŒå | è¥ãäžä»£ | æ§äžä»£ |
Oracle HotSpot | ParallelGC | ã¢ããªã·ãã¯ãäžçãæ¢ããã³ã㌠| ã¢ããªã·ãã¯ãã¹ãããã¶ã¯ãŒã«ããããŒã¯/ã¹ã€ãŒã/ã³ã³ãã¯ã |
Oracle HotSpot | CMS | ã¢ããªã·ãã¯ãäžçãæ¢ããã³ã㌠| ã»ãšãã©ã®å Žåããå§çž®ãã䌎ããªãåæããã©ã°ã«ããââãäžçãåæ¢ããŸãã |
Oracle HotSpot | G1ïŒã¬ããŒãžãã¡ãŒã¹ãïŒ | ã¢ããªã·ãã¯ãäžçãæ¢ããã³ã㌠| ã»ãšãã©ã®å Žåãããã©ã°äžã«äººæ°ã«åºã¥ãå°åã®ãå§çž®ããšåæã«ãäžçãåæ¢ãããŸã |
Oracle JRockit | åçãªã¬ããŒãžã³ã¬ã¯ã¿ãŒ | ã¢ããªã·ãã¯ãã¹ãããã»ã¶ã»ã¯ãŒã«ããã³ã㌠| æé©åã®éã«äººæ°ãåºæºã«ãããªãŒãžã§ã³ã®ãå§çž®ãã䌎ãåæãŸãã¯äžŠè¡ã®ããŒã¯/ã¹ã€ãŒãã«ãããäžçãåæ¢ããŸã |
IBM j9 | ãã©ã³ã¹ã®ãšãã | ã¢ããªã·ãã¯ãã¹ãããã»ã¶ã»ã¯ãŒã«ããã³ã㌠| ã»ãšãã©ã®å Žåãããã©ã°äžã«äººæ°ã«åºã¥ãå°åã®ãå§çž®ããšåæã«ãäžçãåæ¢ãããŸã |
IBM j9 | æé©å | ã¢ããªã·ãã¯ãã¹ãããã»ã¶ã»ã¯ãŒã«ããã³ã㌠| ãã©ã¬ã«ããŒã¯/ã¹ã€ãŒããããã©ã°ã¡ã³ããŒã·ã§ã³ã«ããäžçãåæ¢ããŸã |
ã¢ãºãŒã« | C4ïŒç¶ç¶ç䞊è¡å§çž®ã³ã¬ã¯ã¿ãŒïŒ | æé©åãšåæ | æé©åãšåæ |
ããã€ãã®è©³çŽ°ã«ã€ããŠèª¬æããŸãã
Oracle HotSpot ParallelGC
ããã©ã«ãã§HotSpotã®GCã è¥ãäžä»£ã«ã¯ãã¢ããªã·ãã¯ãäžçåæ¢ã¢ã«ãŽãªãºã ïŒCopying CollectorïŒãå€ãäžä»£ã«ã¯ãã¢ããªã·ãã¯ãäžçåæ¢ã¢ã«ãŽãªãºã ïŒMark / Sweep / CompactïŒã䜿çšããŸãã
Oracle HotSpot CMS
GCã¯ãããã©ã°ãè¡ããã«ãããŒãã³ã°ãšã¯ãªãŒãã³ã°ãåæã«è¡ãããšã§ãå€ãäžä»£ã§äœæ¥ãããšãã«çºçããäžæåæ¢ãå¯èœãªéãæé€ããããšããŠããŸãã ãã ããOGé¢é£ã®ã¡ã¢ãªé åã倧ããæçåããããšããã«ãstop-the-worldã«ããããã©ã°ãåŒã³åºãããŸãã
CMSã¬ããŒãžã³ã¬ã¯ã·ã§ã³ãµã€ã¯ã«ã¯ããã€ãã®ã¹ããŒãžã§æ§æãããäž»ãªã¹ããŒãžã¯æ¬¡ã®ãšããã§ãã
ã»åæããŒã¯ïŒCMSã¯ãéåžžã«çãäžçåæ¢ã§å§ãŸããŸãããã®éãã¬ããŒãžã³ã¬ã¯ã¿ãŒã¯ãã¢ããªã±ãŒã·ã§ã³ã«ãã£ãŠäœæããããªããžã§ã¯ããžã®ããããã«ãŒããªã³ã¯ãèŠã€ããŸãã
ã»åæããŒã¯ïŒãã®æ®µéã§ãCMSã¯ã«ãŒããªããžã§ã¯ãããå°éå¯èœãªãã¹ãŠã®ãªããžã§ã¯ããã€ãŸããã¬ããŒãžã³ã¬ã¯ã¿ãŒã«ãã£ãŠåé€ãããã¹ãã§ã¯ãªããã¹ãŠã®ããªãã³ã°ããªããžã§ã¯ããããŒã¯ããŸãã ãã®æ®µéã¯ãã¢ããªã±ãŒã·ã§ã³ãšåæã«å®è¡ãããŸãã
ã»åããŒãã³ã°ïŒæ³šéïŒïŒåæããŒãã³ã°ãã§ãŒãºã®éãã¢ããªã±ãŒã·ã§ã³ãããŒã¯åŒãç¶ãåäœãããã®æç¹ã§æ°ãããªããžã§ã¯ããäœæãããªã³ã¯ãå€æŽã§ããããããã®æ®µéã®çµãããŸã§ã«ããã¹ãŠã®çããŠãããªããžã§ã¯ããããŒãã³ã°ãããä¿èšŒã¯ãããŸããã ãã®åé¡ã解決ããããã«ãCMSã¯ã¢ããªã±ãŒã·ã§ã³ãããäžåºŠäžæåæ¢ããŠããŒãã³ã°ãå®äºããåã®ã¹ãããã§ãŠãŒã¶ãŒã¹ã¬ããã«ãã£ãŠå€æŽããããã¹ãŠã®ãªããžã§ã¯ãããã§ãã¯ããŸãã åããŒãã³ã°ã«ã¯ããªãã®æéããããããããã«ãããã»ããµãã·ã³ã§ã¯ããã®æ®µéã¯è€æ°ã®äžŠåã¹ã¬ããã«ãã£ãŠå®è¡ãããŸãã
ã»åæã¹ã€ãŒãïŒåããŒãã³ã°ãã§ãŒãºã®å®äºåŸãã¢ããªã±ãŒã·ã§ã³å ã®ãã¹ãŠã®çããŠãããªããžã§ã¯ããããŒã¯ãããåæã¯ãªãŒãã³ã°ãã§ãŒãºäžã«ãCMSã¯èŠã€ãã£ããã¹ãŠã®ã¬ããŒãžïŒãã¹ãŠã®ããŒã¯ãããŠããªããªããžã§ã¯ãïŒãåé€ããŸãã ãã®æé ã§ã¯ãã¢ããªã±ãŒã·ã§ã³ãäžæåæ¢ããå¿ èŠã¯ãããŸããã
ãããã£ãŠãCMSã¯ãOldGenãã¯ãªãŒãã³ã°ãããã¹ãŠã®äœæ¥ãããã€ãã®éšåã«åå²ãããã®äžéšãã¢ããªã±ãŒã·ã§ã³ãšåæã«å®è¡ã§ãããããé·æéã®äžçåæ¢ãåé¿ãããŸãã åæã«ãã¢ã«ãŽãªãºã ã®ç¹æ§ã«ãããCMSã«ãã£ãŠå®è¡ãããäœæ¥ã®åèšéã¯ãã·ãŒã±ã³ã·ã£ã«ã¬ããŒãžã³ã¬ã¯ã¿ãŒãšæ¯èŒããŠå€§ãããªããŸãïŒããšãã°ãåããŒãã³ã°ã®å¿ èŠæ§ã®ããïŒããã®çµæãCMSã䜿çšãããšãã¢ããªã±ãŒã·ã§ã³ã®å šäœçãªããã©ãŒãã³ã¹ããããã«äœäžããå ŽåããããŸãã
IBM J9 optthruputã¯ãã»ãŒåãããšãè¡ããŸãã
Oracle HotSpot G1GCïŒã¬ããŒãžãã¡ãŒã¹ãïŒ
äžä»£å¥ã®ã¬ããŒãžã³ã¬ã¯ã¿ãŒã§ãããåäœåçã¯ç°ãªããŸãã ãã¹ãŠã®ããŒãã¯ãåºå®ãµã€ãºã®é åã«åå²ãããŸãã é åã®ã»ããã¯åçã«çæããããšãã³ããµãã€ããŒã¹ããŒã¹ããŸãã¯å€ãäžä»£ïŒOGïŒã«ãªããŸãã ãªããžã§ã¯ãã1ã€ã®é åã«åãŸããªãå Žåãé£æ¥ããäžé£ã®é åã«æ ŒçŽãããã巚倧ããšåŒã°ããŸãã äžéšã®å°åã¯ä»ã®å°åããã人æ°ããããšæ³å®ãããŠããŸãã ã¡ã¢ãªã¯ãªãŒãã³ã°æé ãå®è¡ãããšã次ã®ããšãçºçããŸãã
1ïŒGCãè¡ãããå°åãéžæãããŸã-è¥ãäžä»£å šäœãšãçãç©ããªãå€ãäžä»£ã®äººæ°ã®ãªãå°å
2ïŒæ°ãããªããžã§ã¯ããšå€æŽããããªã³ã¯ããã£ããããããã®åããŒãã³ã°ãã¹ãããã¶ã¯ãŒã«ãã¯çæéèšå®ãããŸãã
3ïŒãToããšããŒã¯ãããé åãžã®ã³ããŒãããã«ãããéšåçãªãå§çž®ãããããŸãã
ãŸããèšæ¶ã»ãã-é åãããªããžã§ã¯ããžã®ãªã³ã¯ã®å Žæã«é¢ããæ å ±ããããŸããããã«ãããã¡ã¢ãªã®ããŸããŸãªéšåã§ããã€ãã®ç¬ç«ããé åã䜿çšããããããæŸæ£ããããšãã§ããŸãã ç¡æãªã¹ãã ãã®GCã¯ã以åã®ãã®ããã倧ããªããŒãã§æ©èœããååãšããŠã10ã15 GBã®ãµã€ãºã®ããŒãã«å¯ŸããŠèš±å®¹å¯èœãªããã©ãŒãã³ã¹ãæäŸã§ããŸãã ããã«ãããããããèšå€§ãªæ°ã®ãã°ãšãG1ã人æ°ã®ããå°åã®åŒ·åãªæçåã«ããäžçãæ¢ããããåŸãªããšããäºå®ãšåæ§ã«ããã®é åã¯å¢ããŸããã ãã®GCã®ãã1ã€ã®æ¬ ç¹ã¯ãä»ã®GCãšæ¯èŒããŠæ倧ã¹ã«ãŒããããäœäžããããšã§ãã
IBM J9 Balancedã¯åãããšãè¡ããŸãã
ã¢ãºãŒã«c4
ãã®ã¬ããŒãžã³ã¬ã¯ã¿ãŒã¯ããã®èª¬æã§æ¬¡ã®ããšã宣èšããŠãããããæ倧ã®é¢å¿ãåŒãèµ·ãããŸãã
ã Azul JVMãæèŒãããç¬èªã®C4ã¢ã«ãŽãªãºã ïŒContinuously Concurrent Compacting CollectorïŒã䜿çšããå®å šã«ããã¯ã°ã©ãŠã³ãã®åæã¬ããŒãžã³ã¬ã¯ã¿ãŒã C4ã¯ãè¥ãäžä»£ãšå€ãäžä»£ã®äž¡æ¹ã®äžä»£ãåæã«æé©åããŸãã ä»ã®ã¢ã«ãŽãªãºã ãšã¯ç°ãªãããã»ãšãã©ã®å Žååæãã§ã¯ãããŸããããå®éã«ã¯åžžã«ã¢ããªã±ãŒã·ã§ã³ã¹ã¬ããã§åæã«åäœããŸãã stop-the-worldãåŒã³åºãããããšã¯ãããŸããã C4ã¯Loaded Value BarrierïŒLVBïŒã䜿çšããŠåãªã³ã¯ããã§ãã¯ããå€æŽãããåãªã³ã¯ã¯ãèªå·±ä¿®åŸ©ãã¡ãœããã䜿çšããŠãã£ãããããŸãã C4ã¯ããã¹ãŠã®ãªã³ã¯ãåäžã®GCãã¹ã§ã©ãã«ä»ããããããã«ããŸãã ãŸãããªããžã§ã¯ãã®ç§»åãä¿èšŒããããªããžã§ã¯ããžã®ãªã³ã¯ãã¢ããªã±ãŒã·ã§ã³ãšåæã«å€æŽãããŸãããã®æäœã劚ããããšãªãããäžçãåæ¢ãããããšããããŸãã ã
ãŸãããã®è£œåã®èª¬æã«ã¯ãGCã®çŸåšã®å®è£ ãšæ¯èŒãã以äžã®ã°ã©ãããããŸãã
ã¹ã«ãŒãããïŒ
å¿çæéå¥ïŒ
ã¹ã«ãŒãããã«äžå®ã®ããªãã£ããããã»ãšãã©ã®å Žåã䞊åGCã®æ¹ãåªããŠããããšãããããŸããå¿çæéãšããŒããµã€ãºã瀺ãã°ã©ãã§ã¯ããã¹ãŠã®ã±ãŒã¹ã§Azul C4ã確å®ã«å è¡ããŠããããšãããããŸãã ãã ãããããã®ã°ã©ããåã«èŠãã ãã§ããåŸæ¥ã®ãGCãšæ¯èŒããŠãã®ãããªå€§ããªéããã©ãããçããã®ããç解ã§ãã詳现ãæãäžããŠèããªãã®ã¯ééã£ãŠããã§ããããã ãããè¡ãã«ã¯ãAzul C4ãåäœããã¢ã«ãŽãªãºã ã解æããå¿ èŠããããŸãã
äžèšã§ããäžçåæ¢ãããŒãºã®çºçã«ã€ãªãã2ã€ã®äž»ãªçç±ã«ã€ããŠè¿°ã¹ãŸããã ããã¯ãå€ãäžä»£ã®ã¡ã¢ãªé åã®æçåãšã çããŠãããªããžã§ã¯ãã®ããŒãã³ã°ã§ã ã ã¡ã¢ãªãæé©åããªããšãé ããæ©ãããã¡ã¢ãªäžè¶³ããçºçããŸããã¢ããªã±ãŒã·ã§ã³ãšåæã«ã¡ã¢ãªãæé©åãããšã誀ã£ãããŒã¿ãååŸãããŸãã ããŒãã³ã°ã®å ŽåããçããŠããããªããžã§ã¯ããã¡ã¢ãªããåé€ããå±éºæ§ãããããã®çµæãã¢ã¯ã»ã¹ã§ããªããšããã¡ãã»ãŒãžã衚瀺ãããŸãã
ãããã®åé¡ã解決ããããã«ãAzul C4ã¬ããŒãžã³ã¬ã¯ã¿ãŒã¢ã«ãŽãªãºã ã¯ãããããèªã¿åãããªã¢ã®ããŒããŠã§ã¢ããŒã¹ã®ãšãã¥ã¬ãŒã·ã§ã³ã䜿çšããŸãã Azul C4ã§ã¯ãLVBïŒLoad Value BarrierïŒãšåŒã°ããã¬ããŒãžã³ã¬ã¯ã¿ãŒãšã¢ããªã±ãŒã·ã§ã³ã䞊è¡ããŠåäœããããšãä¿èšŒããã®ã«åœ¹ç«ã¡ãŸãã
ãŸããAzul C4ã¯2ã€ã®äžä»£ã䜿çšããŸããæãè¥ãäžä»£ãšå€ãäžä»£ã§ããããã®äžä»£ãå æããã¡ã¢ãªã¯ã¢ããªã±ãŒã·ã§ã³ãšåæã«æé©åãããŸãã äžã®å³ã¯ããŽãããããã«ããããã®äž»ãªæé ã瀺ããŠããŸãã ãããã®3ã€-MarkãRelocateãRemapããããŸãã ãªããããšããŒã¯ã¯åæã«å®è¡ã§ããããšã«æ³šæããŠãã ããã å段éã§äœãèµ·ãããŸããïŒ
ããŒã¯
ãã®æ®µéã§ãã«ãŒããªããžã§ã¯ãããå°éå¯èœãªãã¹ãŠã®ãªããžã§ã¯ããã¡ã¢ãªå ã§ããŒã¯ãããŸãã ãã®ãããªãªããžã§ã¯ãã¯ãçããŠããããšããŒã¯ãããä»ã®ãã¹ãŠã®ãªããžã§ã¯ãã¯ãæ»ãã§ãããããšãæå³ããã¯ãªãŒãã³ã°ã§ããŸãã ã¢ããªã±ãŒã·ã§ã³ãšåæã«å®è¡ããããäžçãæ¢ãããäžæåæ¢ãåŒãèµ·ãããŸããã äžè¬ã«ãCMSã®ãåæããŒã¯ãã¹ããŒãžã«äŒŒãŠããŸãããããã€ãã®éèŠãªéãããããŸãã ãŸããã©ãã«ä»ãã«å ããŠãAzul C4ã¯ã¡ã¢ãªã®åããŒãžã®ãã©ã€ãããªããžã§ã¯ãã®æ°ãã«ãŠã³ãããŸãã ãã®æ å ±ã¯ããã«ãã¡ã¢ãªå ã§è»¢éããã³ããã©ã°ããããŒãžãéžæããããã«äœ¿çšãããŸãã 次ã«ãAzul C4ã¢ã«ãŽãªãºã ã¯ã64ããããªã³ã¯ã§ã¢ãŒããã¯ãã£çã«äºçŽãããNMTãããã䜿çšããŠãã©ã€ããªããžã§ã¯ãã®ãã¹ãŠã®ãªã³ã¯ã远跡ããŸãã ãã®ããããNMTïŒNot Marked ThroughïŒã¯ãGCãããã¹ãããå ŽåããŸãã¯ãããŒã¯ãªãããšããŠãªã³ã¯ããããŒã¯æžã¿ããšããŠããŒã¯ããããšãç®çãšããŠããŸãã ãããã£ãŠãAzul C4ã¯ãå°éå¯èœãªãã¹ãŠã®ãªããžã§ã¯ãããã©ã€ãããšããŠããŒã¯ãããŸãããééããããã¹ãŠã®ãªã³ã¯ããããŒã¯ã¹ã«ãŒããšããŠããŒã¯ããŸãã Markã¹ããŒãžãéå§ããããšããã«ãNMTãããããnot mark throughãã«èšå®ããããªã³ã¯ãã远跡ãããããšããã¢ããªã±ãŒã·ã§ã³ã¹ã¬ããã¯ãLVBã®ãèªã¿åãããªã¢ãã«ãã£ãŠã€ã³ã¿ãŒã»ãããããŸãã ãã®ããªã¢ã®ããŒããŠã§ã¢ãšãã¥ã¬ãŒã·ã§ã³ã¯NMTãããã®æ©èœãèªèããŠãããã¢ããªã±ãŒã·ã§ã³ã¹ã¬ããããnot mark throughããšããŒã¯ããããªã³ã¯ã«ã¢ã¯ã»ã¹ããªãããã«ããŸãã ã¢ããªã±ãŒã·ã§ã³ã¹ã¬ããã®ããããããããè¡ãããšãããšãããã»ããµã¯GCãžã®å²ã蟌ã¿ïŒãã©ããïŒãåŒãèµ·ãããŸãã å²ã蟌ã¿ã¯ããããåŒãèµ·ãããç¶æ³ã次ã®ããã«åŠçããŸãïŒãªã³ã¯ãGCãªã¹ãã«å ¥ããNMTãããããããŒã¯ã¹ã«ãŒãäœçœ®ã«å ¥ããæå¹æ§ãªã³ã¯ãããŒãããããªããžã§ã¯ãã®NMTãããããã§ãã¯ããŸãïŒãããŒã¯ã¹ã«ãŒãç¶æ ã§ãªããã°ãªããŸããïŒã å²ã蟌ã¿ãåŠçããããšãã¢ããªã±ãŒã·ã§ã³ã¹ã¬ãããåéããŸãã ãã®ã¡ã«ããºã ã䜿çšãããšããã¹ãŠã®ãçããŠããããªããžã§ã¯ãã1åã®ãã¹ã§ããŒã¯ã§ããŸããåã©ãã«ä»ãïŒCMSã®ããã«ïŒããäžçã®åæ¢ããåŒãèµ·ããããšã¯ãããŸããã ãŸãããã®äžæèªäœã®åŠçäžã«äžæã®åå ãé€å»ãããšããã»ã«ãã¡ãã£ã±ãŒã·ã§ã³ãã®å¹æããããŸãã åãçç±ãåã³äžæãåŒãèµ·ããããšãèš±å¯ããŠããªããããã©ããªã³ã°ã«é¢ããæçµçãã€äºæž¬å¯èœãªäœæ¥ç¯å²ãä¿èšŒãããŸãã
äžè¬ã«ãå²ã蟌ã¿ã¡ã«ããºã ã«ããã1åã®ãã¹ã§ãã©ã€ãããªããžã§ã¯ãã®ããŒãã³ã°ãå¯èœã«ãªããåæã«ãäžçã®åæ¢ãããŒãºãçºçããŸããã
åé 眮
ãã®æç¹ã§ãGCã¯ããããªããžã§ã¯ããå æããŠããã¡ã¢ãªã解æŸããŸãã åæã«ã圌ã¯ãçããŠããããªããžã§ã¯ããå¥ã®ã¡ã¢ãªé åã«è»¢éããããã«ãã£ãŠæé©åãšå§çž®ãè¡ããŸãã å¹çãé«ãããããAzul C4ã¯ããããããªããžã§ã¯ãã®æ°ãæ¯èŒçå€ãããŒãžãæåã«ã¯ãªã¢ããããã«ãæåŸã®æ®µéïŒããŒã¯ïŒã§ã«ãŠã³ãããããªããžã§ã¯ãã®æ°ã䜿çšããŸãã ãããã®ããŒãžã«ã¯ãçããŠããããªããžã§ã¯ããã»ãšãã©ãªãã®ã§ããããã®è»¢éã«ã¯çãæéãããããåæã«æåã®æ®µéã§ããå€ãã®ã¡ã¢ãªã解æŸããŠãã¢ããªã±ãŒã·ã§ã³ã§äœ¿çšã§ããããã«ããŸãã ããããããªããžã§ã¯ãã«ãã£ãŠå æãããŠããã¡ã¢ãªãå®å šã«ã¯ãªã¢ããããšãã¹ããŒãžã¯çµäºããŸãã åæã«ããçããŠããããªããžã§ã¯ãã¯ãéåžžã«æçåãããããŒãžããã®ã¿è»¢éãããŸãã
ã¹ããŒãžã®éå§æã«ãã¡ã¢ãªã®ç¹å®ã®ããŒãžãžã®ã¢ã¯ã»ã¹ãå¶éããããã«ã¡ã¢ãªä¿è·ã¡ã«ããºã ã䜿çšããŠãã¬ããŒãžã³ã¬ã¯ã¿ã¯ãã©ã€ãããªããžã§ã¯ãã®ã¡ã¢ãªã®ä»ã®ããŒãžãžã®è»¢éãéå§ããŸãã éå§ã¢ãã¬ã¹ãšæ°ããã¢ãã¬ã¹ã«é¢ããæ å ±ã¯ããFromãã¹ããŒã¹ãšã¯å¥ã«åãåºããããForwarding Pointersããæã€ç¹å¥ãªé åã«ä¿åãããŸãã ãã¹ãŠã®ãçããŠããããªããžã§ã¯ãã転éããããšããã«ãã¢ããªã±ãŒã·ã§ã³ã¹ã¬ãããç©çã¡ã¢ãªã䜿çšã§ããããã«ãªããŸãã LVBã¯ããã©ã€ãããªããžã§ã¯ãã®è»¢éãŸãã¯ãã®ãªããžã§ã¯ãã®ã¢ãã¬ã¹ã®åå®çŸ©ã®ããã»ã¹ãè¡ãããã¡ã¢ãªããŒãžãžã®ã¹ã¬ãããžã®ã¢ã¯ã»ã¹è©Šè¡ã決å®ããããã«äœ¿çšãããŸãã ã¹ããªãŒã ã³ãŒã«ãã€ã³ã¿ãŒã»ãããããªã³ã¯ã®å€ãTranslation Look-aside BufferïŒTLSïŒå ã®ãªã³ã¯ãšæ¯èŒããŸãã å€ãçŸåšé²è¡äžã®ãªã³ã¯ãšäžèŽããå Žåãå²ã蟌ã¿ãåŒã³åºãããŸãã ãã®å²ã蟌ã¿ã¯ã次ã®ã¢ã¯ã·ã§ã³ãå®è¡ããŸããForwardingPointersé åã®æ å ±ã䜿çšããŠããªããžã§ã¯ããæ¢ã«ç§»åãããŠãããã©ãããå€æãããŸãã ãªããžã§ã¯ããæ¢ã«æ°ããã¡ã¢ãªããŒãžã«ç§»åãããŠããå Žåããªããžã§ã¯ããžã®æ°ãããªã³ã¯ãã¹ããªãŒã ã«è¿ãããããŒãããããªããžã§ã¯ããžã®ãªã³ã¯ã®ã¢ãã¬ã¹ãåå®çŸ©ãããå°æ¥æ°ãããªã³ã¯ã䜿çšãããããã«ãªããŸãã ãªããžã§ã¯ãããŸã 移åãããŠããªãå Žåãå²ã蟌ã¿ã¯ãã¬ããŒãžã³ã¬ã¯ã¿ããã®ãªããžã§ã¯ãã®ããã¡ã¢ãªããŒãžãåŠçããã®ãåŸ ããã«ããã®ãªããžã§ã¯ãã移åããŸãã ãã®åŸããããŒãåéããŸãã åã®æ®µéãšåããèªå·±æ²»çãã®å¹æã䜿çšãããšã決å®è«çãªæéæ ã§éåã®æ®µéãå®äºããããšãã§ããŸãã ãŸããã¡ã¢ãªå ã®ãªããžã§ã¯ãã移åããã¹ããããç¶è¡ããããããä»ããããŒãã³ã°ã¹ããããå®è¡ããæ¹ãå¹ççã§ãããšã¬ããŒãžã³ã¬ã¯ã¿ã決å®ããå Žåã移åã¹ããŒãžã匷å¶çã«å®äºããããšãã§ããŸãã
ãã®æ®µéãèãããšããã¢ã«ãŽãªãºã ãšå²ã蟌ã¿ã¡ã«ããºã ã®ãã®åäœã«ãããã¹ã¬ããã¯ã¬ããŒãžã³ã¬ã¯ã¿ãŒãã¢ãã¬ã¹ã®ç§»åãšæžãæãã®åŠçãå®äºãããŸã§åŸ æ©ãããã¬ããŒãžã³ã¬ã¯ã¿ãŒããããŒãšå®éã«åæã«åäœãããåæ¢- the-worldãäžæåæ¢ã
ãªããã
ãã®æ®µéã§ã¯ã移åããããã¹ãŠã®ãªããžã§ã¯ãåç §ã®ã¢ãã¬ã¹æžãæããå®äºãã移åããããªããžã§ã¯ãã®ããŒãå ã®å€ãå Žæãžã®åç §ããªãããšãä¿èšŒãããŸãã ãããã®ãªã³ã¯ã¯ãåå®çŸ©æ®µéã®æåã«ååšããå ŽåããããŸããããã¯ãããŒãã«ã移ååŸã«ã¹ã¬ãããã¢ã¯ã»ã¹ããªãã£ããªããžã§ã¯ããžã®ãªã³ã¯ãå«ãŸããŠããå¯èœæ§ãããããã§ãã ã¢ãã¬ã¹æžãæããã§ãŒãºãå®äºãããšãã¡ã¢ãªä¿è·ã¡ã«ããºã ãç¡å¹ã«ãªããForwarding Pointersé åã¯äžèŠã«ãªããŸãã ã¢ãã¬ã¹ã®æžãæãã¯æ¬¡ã®ããã«å®è¡ãããŸããheap-eå ã®ãã¹ãŠã®ãã©ã€ãããªããžã§ã¯ããã¹ãã£ã³ãããããããæ°ããã¡ã¢ãªããŒãžã«ç§»åããããªããžã§ã¯ããæãå Žåããªã³ã¯ãåå®çŸ©ãããŸãã ãã®æ®µéã¯ããŒãã³ã°æ®µéãšäžèŽããåæã«å®è¡ãããŸãã ããŒãã³ã°ããã»ã¹ã¯ãçããŠãããªããžã§ã¯ããæ€åºããŠããŒã¯ããNMTãããããããŒã¯ã¹ã«ãŒããšããŠèšå®ããŸãã åæã«ãã¢ãã¬ã¹åå²ãåœãŠããã»ã¹ã¯ã移åããããªããžã§ã¯ããžã®ãªã³ã¯ãèŠã€ããæ°ããã¢ãã¬ã¹ã«åŸã£ãŠããããåå®çŸ©ããŸãã ããŒãã³ã°ããã³ã¢ãã¬ã¹æžãæãããã»ã¹ã®ããã»ã¹å šäœãéããŠããèªã¿åãããªã¢ãã¡ã«ããºã ã¯ã転éããããªããžã§ã¯ãã«ã¢ã¯ã»ã¹ããã¢ããªã±ãŒã·ã§ã³ã¹ã¬ãããããã£ããããç¶ããæ°ãããã±ãŒã·ã§ã³ã¢ãã¬ã¹ãã¹ããªãŒã ã«è¿ãå²ã蟌ã¿ãåŒãèµ·ãããŸãã
ãããã£ãŠãAzul C4ã¯ããäžçåæ¢ãã®äžæåæ¢ãåŒãèµ·ããããšãªããã¢ãã¬ã¹ã®æžãæãã ãã§ãªããåæããŒãã³ã°ãå®è¡ã§ããŸãã
Azul C4ã¢ã«ãŽãªãºã ã®çè«çãªèª¬æãèŠçŽãããšãã¢ããªã±ãŒã·ã§ã³ãã¬ããŒãžã³ã¬ã¯ã¿ãŒãšåæã«åäœããããšãæ¬åœã«å¯èœã«ããŠãããšèšããŸãã LVBã¡ã«ããºã ã¯ãJVMã®å šäœçãªã¹ã«ãŒãããããããã«äœäžãããŸããããäžçåæ¢ãã®äŒæ¢ãå®å šã«æé€ããŠãå¿çæéãæå°éã«å®å®ãããŸãã ã€ã³ã¿ãŒãããäžã§ãµãŒãã¹ãæäŸããããšãå°éãšããäŒæ¥ããå¿çæéãããžãã¹ã«ãšã£ãŠéèŠãªã¢ããªã±ãŒã·ã§ã³ã«ãšã£ãŠãAzul C4ã¯æãé åçãªJVMã®ããã«èŠããŸãã
ããã«ãããããããçè«ã¯å®è·µã«ãã£ãŠç¢ºèªãããªããã°ãªããŸããã 人çã§ã¯ãAzul JVMã¯ããŒããŠã§ã¢ãšããŠãä»®æ³ãã·ã³ãšããŠãæäŸãããŸãã Azul Vega 3ããŒããŠã§ã¢ãã©ãããã©ãŒã ã¯ãéèäŒç€Ÿã§ãã§ã«ç¢ºç«ãããŠããŸãã ä»®æ³Azul JVMã®å®è£ ã¯ãäžéšã¯x86ããŒããŠã§ã¢ã«å±éã§ãããšããäºå®ãäžéšã¯JavaããŒã¹ã®ã¢ããªã±ãŒã·ã§ã³ã«åããããã¿ã¹ã¯ãããæ·±å»ã«ãªã£ãŠãããšããäºå®ã«ãããäžçã§äººæ°ãåããŠããŸãã ãšããã§ãAzul C4ã¯Azul JVMã®å¯äžã®å©ç¹ã§ã¯ãããŸãããAzulã競åä»ç€Ÿãšåºå¥ããããã€ãã®éãããããŸãã ãããã®å©ç¹ã®è©³çŽ°ãªèª¬æã«ã¯ããã®èšäºã«å¿ èŠãªã ãã®ã¹ããŒã¹ãå¿ èŠã§ãããããã£ãŠãAzul JVMå šè¬ãæ€èšã§ããå¥ã®èšäºã«æ®ããŠããããšããå§ãããŸãã ååã«ããå Žå-ããã¯DirectPathVMTMããªããã£ãã¹ãã£ãã¯ã¹ã¬ããã®åæå®è¡ãã¢ããªã±ãŒã·ã§ã³å®è¡ã®ç£èŠãšãããã¡ã€ãªã³ã°ã§ãã
Azul Systemsã®Webãµã€ãã§ã¯ãAzul-aã®å©ç¹ãå¿çšãããŠãã人çã®äºäŸãå€æ°èŠãããšãã§ããŸãã
Azul JVMã䜿çšããŠããäŒæ¥
å人çãªç·Žç¿ããã倧äŒæ¥ã®ååŒäŒç€Ÿã§ããAzul JVMã®å®è£ äŸã玹ä»ã§ããŸãã
JVMæ§æïŒ
ãã€ãã£ãæ§æ | ã¢ãºãŒã«æ§æ |
-Xms2g -Xmx2g
-XXïŒ+ UseConcMarkSweepGC -XXïŒ+ UseParNewGC -XXïŒTargetSurvivorRatio = 80 -XXïŒCMSInitiatingOccupancyFraction = 85 -XXïŒSurvivorRatio = 8 -XXïŒMaxNewSize = 320m -XXïŒNewSize = 320m -XXïŒMaxTenuringThreshold = 10 | -Xms3g âXmx3g |
äžèšã®ãã¹ãŠããŸãšãããšãAzul C4ã§å®è£ ãããã³ã³ã»ããã¯å®éã«å®éã«æ©èœããæ倧1ãã©ãã€ãã®ãµã€ãºã®ããŒããæã€ããšãã§ããããŒããµã€ãºã®èšå®ãšGCã®èª¿æŽã«äŒŽãé çã解æ¶ã§ããŸããå®å®ããæå°éã®ã¢ããªã±ãŒã·ã§ã³å¿çæéãå®çŸããŸãã
Azul C4 AlgorithmããŒã¿ã·ãŒã