弱いメモリモデル環境におけるJava volatile最適化手法の評価

Bibliographic Information

Other Title
  • Evaluating Optimization Techniques for Java Volatile Variables on Weak Memory Model Platforms

Search this article

Abstract

Javaのvolatile変数はノンブロッキングなアルゴリズムやConcurrentHashMapなどのライブラリを実装する際によく使用される.Java言語仕様では,1つのvolatile変数へのアクセスは逐次一貫性を持つと定めている.したがって,弱いメモリモデル環境ではJVM内やJIT生成コード中に適切なメモリバリアを挿入する必要があり,不適切に処理されれば再現性の低いバグを引き起こすことになる.一方,メモリバリアはオーバヘッドが高いので,このオーバヘッドを減らすことはJavaランタイムの重要な最適化手法の1つである.POWERアーキテクチャなどのプロセッサでは,複数のメモリ同期命令を適切に組み合わせてメモリバリアを実装する.メモリ同期命令の組合せ方は,書き込み側とメモリ側のメモリアクセス・パターンによって変わる場合があり,それに応じてオーバヘッドも変わる.本研究では,POWERアーキテクチャ用のOpenJDKとOpen J9においてvolatile変数アクセスのメモリバリア実装の最適化手法を比較し,Javaプログラムの実行速度への影響を評価した.

Java volatile variables are commonly used to implement non-blocking algorithms and libraries, such as ConcurrentHashMap. Java language specification requires all accesses to a volatile variable need to be sequentially consistent. This means Java VM and JIT compiled code need to put memory fences appropriately on the weak memory model platforms, otherwise Java programs cause hard-to-reproduce intermittent problems. However, memory fences often cause large overhead, so reducing the fence overhead is one of effective optimization techniques for Java. Some processor architectures, such as the POWER architecture, provide multiple memory synchronization instructions. An appropriate combination of those instructions for implementing a memory fence depends on how threads access memory, and the overhead can vary accordingly. In this research, we investigated how memory fence for volatile variables are efficiently implemented in OpenJDK and Open J9 for the POWER platform and evaluated how the difference of implementation affects performance of Java programs.

Journal

Details 詳細情報について

Report a problem

Back to top