都内で働くSEの技術的なひとりごと / Technical soliloquy of System Engineer working in Tokyo

都内でサラリーマンやってます。SQL Server を中心とした (2023年からは Azure も。) マイクロソフト系(たまに、OSS系などマイクロソフト以外の技術も...)の技術的なことについて書いています。日々の仕事の中で、気になったことを技術要素関係なく気まぐれに選んでいるので記事内容は開発言語、インフラ等ばらばらです。なお、当ブログで発信、発言は私個人のものであり、所属する組織、企業、団体等とは何のかかわりもございません。ブログの内容もきちんと検証して使用してください。英語の勉強のため、英語の

.NET アプリケーションの高速化について探し始めてみた - その10 - ( RyuJIT(龍神) )

 C#VB.NET などの NET Framework 上で動くプログラムは、 いきなりネイティブ コードにコンパイルするのではなく、 中間言語 と呼ばれるものにコンパイルされます。中間言語は、プログラムの実行時に部分的にネイティブ コードにコンパイルされていきます。このような方式を JIT ( Just - In - Time ) コンパイルといいます。

 この JIT コンパイルを行っている .NET 標準の JIT コンパイラーの代わりとなるものが現われました。それは、『 RyuJIT ( リュウジット? ) 』です。RyuJIT とは 64 ビット OS に最適化された JIT コンパイラーです。今回の記事は、ここのブログを参考にしました。従来のコンパイラーと比べると、かなり高速化されているようです。( 次期 .NETFramework あたりで、標準の JIT コンパイラーになるのでしょうか。 .NETFramework 5.0 ですかね? )

The world is moving to 64-bit computing even though it isn’t always faster or more efficient than 32-bit. A lot of programs run faster on 32-bit than on 64-bit, for a variety of reasons. One example of this is the 64-bit JIT compiler in .NET. It does a great job of making your program run fast, but it’s not a fast program itself. All that’s about to change: a new, next-generation x64 JIT compiler that compiles code twice as fast is ready to change your impressions of 64-bit .NET code.

 RyuJIT は現在 CTP です。ここからダウンロードできます。試す価値はありそうです。ちなみに、RyuJIT のネーミングは、日本の『 龍神 』 を元にしたようです。りゅうじん、りゅうじと、りゅうじっと? もしや、だじゃれ?

File:Tamatori being pursued bya dragon.jpg

@John Mitas: en.wikipedia.org/.../Ryujin

I'll post some more nitty-gr?

 早速試してみたいと思います。RyuJIT は Windows 8.1 ( 64ビットのみ ) または Windows Server 2012 R2 で動作します。

You can download the RyuJIT installer now. RyuJIT only works on 64-bit editions of Windows 8.1 or Windows Server 2012 R2. Also, RyuJIT doesn’t change NGen on your system—we wanted to keep the CTP install clean. Lastly, if you enable RyuJIT while writing code, you’ll find that Edit & Continue doesn’t work on 64-bit (that’s so 2012!)

 自分のメインマシンにインストールするのは、若干気が引けるので、 Windows Azure 上の仮想マシンで試してみます。( Windows Server 2012 R2 を使用 ) インストーラーを起動します。龍神ぽいイラストがありますね。

f:id:koogucc11:20131019194219p:plain

 インストール完了です。

f:id:koogucc11:20131019194346p:plain

 検証なので、マシン全体で RyuJIT を有効にします。

 After installation, there are two ways to turn on RyuJIT. If you just want to enable RyuJIT for one application, set an environment variable: COMPLUS_AltJit=*. If you want to enable RyuJIT for your entire machine, set the registry key HKLM\SOFTWARE\Microsoft\.NETFramework\AltJit to the string "*". Both methods cause the 64-bit CLR to use RyuJIT instead of JIT64. And both are temporary settings—installing RyuJIT doesn’t make any permanent changes to your machine (aside from installing the RyuJIT files in a directory, that is.)

 下図の通り、レジストリを変更します。

f:id:koogucc11:20131019195131p:plain

 今後も このブログをチェックしないといけないですね。

Stay tuned to this blog for more on RyuJIT as it progresses from a CTP to become the One True .NET JIT Compiler™. If you want to dive more deeply into the geeky details behind RyuJIT’s development, you can do that at the .NET CodeGen blog. We’ll answer questions and explain design decisions there. (If you look right now, you’ll see a post that explains the funny codename!) And remember to send us mail at ryujit@microsoft.com after you download and install the CTP. We want to hear from you!

  いくつかの .NETFramework を使ったアプリを動作させてみましたが、動作に特に問題はみられませんでした。今度時間があるときに、テストアプリを作って速度検証してみます。( みたいと思います.... )