SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Javaで使えるもう一つのコンパイル方式 - AOT
… を無理やりWindowsでやってみた話
【東京】JJUG ナイトセミナー: 年送りビール&LT大会 2017/12/27
松原 正和
https://a5m2.mmatsubara.com
松原正和 - 自己紹介
A5:SQL Mk-2の作者
・SQL&ER図ツール
双子のパパ
・5歳になったよ
本人
https://a5m2.mmatsubara.com
20年開発してます。
JJUG CCC 2017 Fall (2017/11/18)にて
西川彰広さんのセッション「Javaで使えるも
う一つのコンパイル方式 - AOT」が大変面白
かったです。
https://a5m2.mmatsubara.com
Java 9から導入された
AOTコンパイル方式のお話。
AOTコンパイラとは
AOTコンパイラの役割
・これまではアプリケーション開始時にJavaインタプリタが動作
→その後JITコンパイル
・事前にAOTコンパイラでclassファイルをネイティブコードに
変換
・アプリケーション起動時にインタプリタ動作で時間がかかる
のを抑制する
https://a5m2.mmatsubara.com
やってみたい!!
…だが、Java 9ではLinux版のみ!。
俺はWindowsプログラマなんだ!!。
…でも、あきらめない!。
我々にはWindows Subsystem for Linux があるじゃあないか!!。
※ Windows Subsystem for Linuxとは
Windows 上でLinuxカーネルをエミュレーションし、その上で
Ubuntuとか動かしたりする。仮想化ではない。
https://a5m2.mmatsubara.com
20年来の。
やってみた!!
手持ちのソートアルゴリズムとか動かしてみる。
・10,000,000件の乱数ソートを10回動かすベンチマーク
https://a5m2.mmatsubara.com
JITコンパイルだと、
アルゴリズムに
よって初回実行が
遅いことがある。
コマンド
■AOTコンパイルは jaotcコマンド
■実行時オプション
$ jaotc --output ../mmsort.so mmsort/*.class
$ java -classpath bin -XX:AOTLibrary=./mmsort.so mmsort.SortTest mmsort.Mas4Sort
10000000 R I 10
共有ライブラリ形式で出力される
-XX:AOTLibraryオプションで指定
https://a5m2.mmatsubara.com
結果
・AOTなし(JITコンパイル)
初回実行:7.6秒前後、2回目以降:5.0~5.1秒前後
・AOTコンパイル
初回実行:8.1~8.2秒前後、2回目以降: 8.1~8.2秒前後
https://a5m2.mmatsubara.com
なんで?
Windows Subsystem for Linuxのせい?
…でもないらしい。
そもそも、JITコンパイルは「実行時の情報を利用できる」から、
高速に動くという能書きだったはず。
https://a5m2.mmatsubara.com
CPU中心の処理はパフォーマンス低下はほとんどない。
ファイル操作はまだ苦手みたい。
プロセス生成が遅いという話も。
なんで?…その2
そもそもJITコンパイルは次の5つの段階がある。
一般的にレベルは 0→3→4と変化するらしい。
レベル2とレベル4じゃAOTコンパイル勝てない…。
レベル (Tier) コンパイラ 動作モード
0 インタプリタ
1
C1 クライアントレベル
プロファイリングなし
2 基本的なプロファイリング使用
3 全てのプロファイリング使用
4 C2 サーバーレベル
AOTコンパイル
方式はレベル2
相当らしい。
https://a5m2.mmatsubara.com
AOTコンパイル
はレベル2相当
JITコンパイルは
最終的にレベル
4になる
でももうちょっと何とか…
デフォルトでは、AOTコンパイルしたらJITコンパイラは働かない
モードらしい。オプション指定でJITコンパイラも併用できる。
■AOTコンパイルのオプションを変える
$ jaotc --compile-for-tiered --output ../mmsort.so mmsort/*.class
段階的なコンパイル…つまりJITコ
ンパイルを併用するオプション
https://a5m2.mmatsubara.com
何とかした結果
・AOTなし(JITコンパイル)
初回実行:7.6秒前後、2回目以降:5.0~5.1秒前後
・AOTコンパイル(--compile-for-tieredつき)
初回実行:7.3秒前後、2回目以降: 5.0~5.1秒前後
初回実行がちょっとだけ速くなった。2回目
以降はJITコンパイラ並み!!。
https://a5m2.mmatsubara.com
まとめ…というか感想
・AOTコンパイルはJITコンパイルより遅い。
・…というか、JITコンパイルは優秀。
・AOTコンパイル使いどころ難しい…効果もそれほど…。
・まだ出たばかりの機能、サポートもない。これからいろいろ改
善されてくはず。
・Windows のAOT対応はJava 10かららしい。
・Windows Subsystem for Linux結構使える。
https://a5m2.mmatsubara.com
Copyright © 2017 松原正和
ご清聴ありがとうございました。
https://a5m2.mmatsubara.com

Weitere ähnliche Inhalte

Empfohlen

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

Empfohlen (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Javaで使えるもう一つのコンパイル方式 AOT … を無理やりwindowsでやってみた話

Hinweis der Redaktion

  1. 10s プログラミングを習い始めの頃、皆一回くらいはソートアルゴリズムを学んだことがあるはず…。
  2. 30s
  3. 「にしかわあきひろ」さんのセッション
  4. 20年来の…例のアレのこと。
  5. AOTコンパイルは実行する環境か、同じ構成の環境でコンパイルしなければならないらしい。
  6. 考察ってほどではない。 MacもJava 10かららしいよ(なげやり)。
  7. 10s