JITコンパイルはじめの一歩
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

JITコンパイルはじめの一歩

on

  • 151 views

2014/10/27 関ジャバ HotSpot meetingで@jyukutyoが発表した「JITコンパイルはじめの一歩」の資料です。

2014/10/27 関ジャバ HotSpot meetingで@jyukutyoが発表した「JITコンパイルはじめの一歩」の資料です。

Statistics

Views

Total Views
151
Views on SlideShare
144
Embed Views
7

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 7

https://twitter.com 7

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

JITコンパイルはじめの一歩 Presentation Transcript

  • 1. -,7⏯␯␍⏠␧ ⎰⎙⏂⎯λഽ #MXNXWRァ⎙⏆⎐⎢⏈ア ݠ୉۝λ 1
  • 2. ߢډࣅѻ
  • 3. 阪田 浩一 文学部哲学科卒 3 @jyukutyo 著書 3冊 関西Javaエンジニアの会 (関ジャバ) 発起人・運営 Fight the Future http://jyukutyo.hatenablog.com/ フリュー株式会社 所属 プリ機と連携する 画像SNS「ピクトリンク」 開発・運用に従事. 会員数800万人! ScalaMatsuri スポンサー企業! エンジニア歴11年 35歳 SI業界での客先常駐 9年 Web系? 2年強 塾講師アルバイト
  • 4. -90ຢ ⎢⎌⏊
  • 5. ⎰ ܞ௟⎯౎಺ࠋ⎯ ય⎨݂ࠜƧ
  • 6. ⏉⏎⎘⎐⎋Ա⎅⎘⎿⎚
  • 7. ⎿⎛⎰ ⎋⎖⏊⎅
  • 8. -,7⏯␯␍⏠␧⎤⎧ъを
  • 9. ٶව⎫଑զ⎨⎰
  • 10. -,7␕⍬⏵⎯щ২␚⏳␯⎰ ߹۱ঽ⎬ ু␌⏠␄⏯⍬␅⏓ ␚⏳␯⏯⍬␅⎬ ബԀ⎚⏌ァんア
  • 11. ⎔⎔⎨⎰ -,7⏯␯␍⏠␧⏓ ߹۱ߗ⎬ ஓଯ⏯␯␍⏠␧⎚⏌ ⎩⎅⎇Τය⎨छ⏂⎿⎚
  • 12. -XVW,Q7LPH⏯␯␍⏠␧ ! ␝⏹⏿␅⎍څ⎴ࡥ⎖⏍⎠⎩⎎⎬ ␝⏹⏿␅⎯␌⏠␄⏯⍬␅⏓⏯␯␍⏠␧⎘⎧ ␉⏠␂⏟␒⎫␚⏳␯⏯⍬␅⎬ബԀ⎚⏌
  • 13. ␝␦⏿␄
  • 14. ⏯␯␍⏠␧݌⏀⎯ ⏯⍬␅⏓څ⎴ࡥ⎚⎯⎨る ߹۱⎍ਙ⎅
  • 15. ␃␝␦⏿␄
  • 16. ␝⏹⏿␅⏓⏯␯␍⏠␧⎚⏌ ࡽ๲⎬ ੒⎎⎫⏦⍬␌⍬␔⏿␅⎍ ⎃⏌
  • 17. ⎔⎯⏯␯␍⏠␧⎯ ⏻⏠␛␯⏬⎨ ݂଱ш⏃߹޵⎚⏌
  • 18. -90⎨⎰߹۱ߗ⎬ ␓␩␑⏝⏠␦␯⏬⎘る
  • 19. ⏯␯␍⏠␧⎬ખ⎚⏌ ⏯⍬␅⏓౜ઐ⎚⏌
  • 20. 最適化の種類 § ␝⏹⏿␅څ⎴ࡥ⎘⎯⏠␯␥⏠␯ш § ੺λ␃⏟⏵␍⏿⏽ § ֩૳ೱഇߧ⎯ݪ࢑ § ␧⍬␓わ⏞␯␩⍬␦␯⏬ § ౮Ξ⏽⏣⏿⏫ݪ࢑ § ␃⏿␅⏯⍬␅⎯ݪ࢑ § ␃⍬⏻わ␑␩⍬ѽॾ
  • 21. ຶア ␝⏹⏿␅⎯⏠␯␥⏠␯ш
  • 22. څ⎴ࡥ⎘⎧⎅⏌ ␝⏹⏿␅⎯ඕਹ⏓ څ⎴ࡥ⎘ٴ⎬ ⏯␐⍬⎚⏌
  • 23. ⏠␝⍬⏴⎘⏅⎚⎅
  • 24. ⎔⏍⎬⏉⎤⎧ ъ⎍⏉⎅⎯⎌をを
  • 25. ࢡ⎖⎫ࡽ๲⎯ࣟ܄る ␝⏹⏿␅⏓څ⎴ࡥ⎚ ⏯⏵␄⎯൘⎍ ۿ⎐⎫⏌
  • 26. ␃␑⏥␧␄⎨⎰ ␌⏠␄රභ⎯ ␌⏠␄⏯⍬␅⏓ԥ⏁ ␝⏹⏿␅⎍਻࣐⎩⎫⏌ ǩॴଯ⎫␧⍬␧
  • 27. ⎠⎡るஓଯ⎫␙␦⏳⍬⏃ ⎃⏌⎯⎨る ਻࣐⎰ ⏞␓␦⏭⍬⏳␣␯⎕⎩⎬ ബш⎚⏌
  • 28. ຶア ੺λ␃⏟⏵␍⏿⏽
  • 29. ␙␦␞⍬␑⏟⏿⏫⎫ ␝⏹⏿␅څ⎴ࡥ⎘⎬⎋⎅⎧る ދࢻ⎚⏌ؠ⎍ബ⏐⏊⎫⎅ ⎩২଑⎘る
  • 30. щ২␝⏹⏿␅٠ݲ⏓ ⏵␧⍬⎚⏌ ァ⏦⍬␌⍬␥⏠␅⎍ ޡๆ⎖⏍⏌⎌⏓ ⏽⏣⏿⏫⎘⎫⎅ア
  • 31. ੯݂଱ш
  • 32. ੺λ␃⏟⏵␍⏿⏽⎯২଑⎩ β⎇ؠ⎯⏠␯⏵⏻␯⏵ ⎨⎃⎤⎠ࣟ܄⎫⎪
  • 33. ⏯␯␍⏠␧⎘⎠⏯⍬␅⏓ ෌ڹ⎬⎘⎧ ⏠␯⏻␓␦⏻⎬෸⏌ ァ⎿⎠⎰݁⏯␯␍⏠␧⎚⏌ア
  • 34. ⎥⎿⏋
  • 35. ⎥⎯␝⏹⏿␅⎬਻⎘⎧ ੯݂଱ш⎩ ݁⏯␯␍⏠␧⎍ ،⏋റ⎖⏍⏌⎔⎩⏃ ⏉⎐⎃⏌⎔⎩
  • 36. ⏯␯␍⏠␧わ␞⍬␅
  • 37. λ୞⎰ෳ⎬⎘⎠ FOLHQW VHUYHU ⏦␓⏳␣␯
  • 38. FOLHQWゐ& ⏯␯␍⏠␧ࡽ๲⎰ਙ⎅ १ढ़⎖⏍⏌⏯⍬␅⎰ಅҼଯઢ⎅ VHUYHUゐ& ⏯␯␍⏠␧ࡽ๲⎰ઢ⎅ १ढ़⎖⏍⏌⏯⍬␅⎰ਙ⎅
  • 39. FOLHQWゐ& § ステップ1(インタプリタ) § 実行しながらホットなメソッドを検出する § ステップ2(ネイティブ) § ホットと判断したメソッドをJITコンパイル し、実行する
  • 40. VHUYHUゐ& § ステップ1(インタプリタ) § 実行しながらプロファイリングする § ステップ2(ネイティブ) § ホットと判断したメソッドをステップ1で取 得したプロファイリングデータを使ってJIT コンパイルし、実行する § プロファイリングデータを取得するため にインタプリタのフェーズが長い
  • 41. -90⏤␯⏴␇⏞ ⎠⏌⏃⎯ ⎔⏍⏓ޡ⎅ഇ⎒⎮⎱ ⎫⏊⏔ん
  • 42. ⎞⏔⎫ߗ੐⏃ ⎃⏋⎿⎘⎠Ƨ
  • 43. ⏃⎇⎔⏔⎫ ⏦␓⏳␣␯ ޡ⎅⎿⎜⏔
  • 44. ܞ⎰ ߢஓଯ⎬ ຑ൘⎩⏃ޡ⎤⎧⎅⎿⎚
  • 45. ҕ৥ؠ⏯␯␍⏠␧ -'.⎨஖௡ァ⏦␓⏳␣␯ǩ⎨ޱ଑⎍಩์ア -'.X⎿⎨␌⏿⏫␙⍬␄ -'.⎨⎰␃␑⏥␧␄⎨ยڹ ! ǩ;;7LHUHG&RPSLODWLRQ
  • 46. અଯ⎬ٿ⎇⎩る
  • 47. Քஓߗ⎬⎰ &⏓ਪ⎐ޡ⎅る ਙ⎐Քஓ⎚⏌
  • 48. ।࣢⎬ஓݩ⎚⏌⏉⎇⎬ ⎫⏍⎱&⏓␝⏠␯⎬ޡ⎅る ␍␑⏥⍬␚␯⏵⏓ۿ⏂⏌
  • 49. ⏃⎇ࢢ⎘ ࣏⎘⎐٪⏌⎩る
  • 50. ⏠␯⏻␓␦⏻⎨⎰⎫⎐ &⎯ઓҕ⎨ ␓␩␑⏝⏠␦␯⏬⎚⏌ ⏉⎇⎬⎚⏌
  • 51. ⏯␯␍⏠␧␨␕␧ § level 0:インタプリタ § level 1:C1 フル最適化 § プロファイリングなし § level 2:C1 呼び出しとループのプロファ イリング § level 3:C1 フルプロファイリング § level 4:C2
  • 52. ⏯␯␍⏠␧⎯ ࡽ๲൘൚
  • 53. &&⎍⎞⏍⎟⏍ ⏩␡⍬⏓ߖ⎥
  • 54. &&⎍⎞⏍⎟⏍ ⏩␡⍬⏓ߖ⎥
  • 55. ⏩␡⍬⎯ૠ⎖⎬Ы⎙⎧ ᪭ખ⎫⎪⏓ ૛य़⎚⏌
  • 56. ⏯⍬␅⏩␟⏿⏳␡௅⎬ ⏯␯␍⏠␧ڤ⎯ ⏯⍬␅⎍జટ⎖⏍⏌⎩る
  • 57. ⏠␯⏻␓␦⏻わ␞⍬␅⎌⏊ ⏯␯␍⏠␧⎖⏍⎠⏯⍬␅⏓ ޡๆ⎚⏌␞⍬␅⎬ উ⏋੃⎉⏌
  • 58. ⎔⏍⎰る␙⏠␯⏻ࢆ⎎Ԁ⎉ SRLQWHUVZL]]LQJ
  • 59.  ⎩څ⎱⏍⏌ ⎔⎩⏃⎃⏌
  • 60. ⏯␯␍⏠␧␨␕␧⎯সΫ § level 0 -> 3 -> 4(理想的) § 0 -> 2 -> 3 -> 4(C2のキューが長いとき) § 0 -> 3 -> 1(C2コンパイルができないメ ソッドのとき)?? § 0 -> 4(C1でコンパイルできない、インタ プリタでプロファイリングしてC2する)
  • 61. ໓ਞ݁⏯␯␍⏠␧
  • 62. λ୞⏯␯␍⏠␧⎘⎠⎃⎩⏃ ␓␩␑⏝⏠␦␯⏬⏓ ਞ⎒⏌
  • 63. ⎖⏊⎫⏌݂଱ш⎯ я௾ड़⎍⎃⏍⎱る ⏯⍬␅⏓݁⏯␯␍⏠␧ ⎚⏌
  • 64. 2Q6WDFN UHSODFHPHQW ァ265ア
  • 65. ␧⍬␓⎯ય⎨ ஔλ⎯␝⏹⏿␅⏓ څ⎴ࡥ⎘⎧⎅⏌ ⏉⎇⎫ࣟ܄
  • 66. ␧⍬␓⎯݂ય⎬ ⏠␯⏻␓␦⏻⎌⏊ ⏯␯␍⏠␧⎘⎠⏯⍬␅⏓ ޡ⎇⏉⎇⎬ উ⏋੃⎉⏌
  • 67. -,7⏯␯␍⏠␧⎯ ҷ௨൘൚
  • 68. ;;3ULQW&RPSLODWLRQ ! 75 1 3 java.lang.Math::min (11 bytes) 75 3 3 java.lang.String::charAt (29 bytes) 76 2 3 java.lang.AbstractStringBuilder::ensureCapacityInternal (16 bytes) 76 4 n 0 java.lang.System::arraycopy (native) (static) 77 5 3 java.lang.Object::<init> (1 bytes) 77 6 3 java.lang.String::hashCode (55 bytes) 77 7 3 java.lang.String::indexOf (70 bytes) 78 8 3 java.lang.String::length (6 bytes) 78 9 3 java.lang.AbstractStringBuilder::append (50 bytes) 78 10 3 java.lang.String::getChars (62 bytes) 78 11 3 java.lang.String::equals (81 bytes)
  • 69. ⏯␯␍⏠␧⎖⏍⎠ ␝⏹⏿␅⎩ ߗԝる⏯␯␍⏠␧␨␕␧⎍ ⏐⎌⏌
  • 70. ;;3ULQW7LHUHG(YHQWV ! 0.047899: [call level=0 [java.lang.Object.<init>()V] @-1 queues=0,0 rate=n/a k=1.00,1.00 total=128,0 mdo=0(0),0(0) max levels=0,0 compilable=c1,c1-osr,c2,c2-osr status=idle] 0.048180: [loop level=0 [sun.nio.cs.UTF_8$Decoder.decode([BII[C)I] @20 queues=0,0 rate=n/a k=1.00,1.00 total=29,1024 mdo=0(0),0(0) max levels=0,0 compilable=c1,c1-osr,c2,c2-osr status=idle] 0.048348: [loop level=0 [sun.nio.cs.UTF_8$Decoder.decode([BII[C)I] @20 queues=0,0 rate=n/a k=1.00,1.00 total=45,2048 mdo=0(0),0(0) max levels=0,0 compilable=c1,c1-osr,c2,c2-osr status=idle] 0.048414: [loop level=0 [java.lang.String.hashCode()I] @24 queues=0,0 rate=n/a k=1.00,1.00 total=73,1024 mdo=0(0),0(0) max levels=0,0 compilable=c1,c1-osr,c2,c2-osr status=idle] 0.049419: [call level=0 [java.lang.String.hashCode()I] @-1 queues=0,0 rate=n/a k=1.00,1.00 total=128,1302 mdo=0(0),0(0) max levels=0,0 compilable=c1,c1-osr,c2,c2-osr status=idle] 0.049514: [call level=0 [java.lang.Object.<init>()V] @-1 queues=0,0 rate=n/a k=1.00,1.00 total=256,0 mdo=0(0),0(0) max levels=0,0 compilable=c1,c1-osr,c2,c2-osr status=idle] 0.049557: [compile level=3 [java.lang.Object.<init>()V] @-1 queues=0,0 rate=n/a k=1.00,1.00] !
  • 71. ⏉⏋࣏ݔ⎬ ٪⏍⏌
  • 72. ⎖⏊⎬࣏ݔ⎬ ٪⏌⎬⎰
  • 73. ;;/RJ&RPSLODWLRQ ! ;0/␑⏥⍬␚⏿␄⎨ࡥ⏌ ;;8QORFN'LDJQRVWLF902SWLRQV ⏓ஔߗ⎬঎଑⎚⏌಩์⎃⏋ !
  • 74. KRWVSRWBSLGORJ ! <nmethod compile_id='2' compiler='C2' entry='0x000000010508d220' size='1504' address='0x000000010508d0d0' relocation_offset='296' insts_offset='336' stub_offset='688' scopes_data_offset='736' scopes_pcs_offset='864' dependencies_offset='1456' handler_table_offset='1464' nul_chk_table_offset='1488' method='java/lang/String indexOf (II)I' bytes='70' count='366' backedge_count='6418' iicount='366' stamp='0.122'/> !
  • 75. ⏃⎇஬⏂⎿⎜⏔Ƨ
  • 76. ␀⍬␧⏓ޡ⎋⎇ん
  • 77. -,7:DWFK KWWSVJLWKXEFRP$GRSW2SHQ-'.MLWZDWFK
  • 78. ⏷⏿␄⏞⏿␓⎰ FORQH⎘⎧ PYQSDFNDJH ๆΤ⎖⏍⎧⎅⏌ ODXQFK8,VK EDW
  • 79.  ⏓߹۱⎚⏌⎡⎒
  • 80. ૝ԑ੺ん
  • 81. ␩⏬⏓ѽॾ⎚⏌⎩⎎⎰
  • 82. ;;7UDFH&ODVV/RDGLQJ ⎨⏫␥⏵␩⍬␅ߗ⎯ ࣣൎ⏃ࡥ⎚
  • 83. ⎖⏊⎬
  • 84. +RW6SRW⎯ ௅ೱ⏦␓⏳␣␯ ;;3ULQW$VVHPEO ⏓⎥⎒⏍⎱ ⏞⏷␯␒␦⎯⏯⍬␅⏓ ٪⏍⏌
  • 85. ǩ+RW6SRWGLVDVVHPEOHHU ァ+6',6ア ⎍ധ୘಩์ KWWSVNHQDLFRPSURMHFWVEDVHKVGLV -'.⎫⏊␑⏝⏠␧⏓-$9$B+20(MUHOLEVHUYHU⎹ ⏯␐⍬⎚⏌
  • 86. ␃␞
  • 87. ⎕॥૗ ⎃⏋⎍⎩⎇ ⎕⎗⎅⎿⎘⎠ん