JP2019152911A - Information processing apparatus, information processing method and computer program - Google Patents
Information processing apparatus, information processing method and computer program Download PDFInfo
- Publication number
- JP2019152911A JP2019152911A JP2018035569A JP2018035569A JP2019152911A JP 2019152911 A JP2019152911 A JP 2019152911A JP 2018035569 A JP2018035569 A JP 2018035569A JP 2018035569 A JP2018035569 A JP 2018035569A JP 2019152911 A JP2019152911 A JP 2019152911A
- Authority
- JP
- Japan
- Prior art keywords
- snapshot
- information processing
- native code
- processing apparatus
- jit
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Abstract
Description
本発明は、中間コードで記述されたプログラムを実行するための情報処理装置、情報処理方法およびコンピュータプログラムに関する。 The present invention relates to an information processing apparatus, an information processing method, and a computer program for executing a program described in an intermediate code.
従来から、中間コードにより記述されたプログラムを実行するための仮想マシン技術が知られている。仮想マシンは、仮想マシン用のコードである中間コードを実行するインタプリタを備える。しかし、インタプリタを用いたプログラムの実行処理速度は遅い。そこで、中間コードをネイティブコードに変換する方法(以下、コンパイルと記す)が普及している。ネイティブコードは、仮想マシンが動作しているCPUで直接実行可能なデータ形式であり、コンパイル後のプログラムは高速に動作する。 Conventionally, a virtual machine technique for executing a program described by an intermediate code is known. The virtual machine includes an interpreter that executes intermediate code that is code for the virtual machine. However, the execution processing speed of a program using an interpreter is slow. Therefore, a method of converting intermediate code into native code (hereinafter referred to as compilation) has become widespread. The native code has a data format that can be directly executed by the CPU in which the virtual machine is operating, and the compiled program operates at high speed.
コンパイル方法としては、AOT(Ahead Of Time)コンパイルとJIT(Just In Time)コンパイルがある。AOTコンパイルでは、仮想マシンがプログラムをロードする前にコンパイル処理がなされる。しかし、AOTコンパイルでは実行状態に応じたコンパイルができないため、最適なコンパイルを実現できない。 Compiling methods include AOT (Ahead Of Time) compilation and JIT (Just In Time) compilation. In AOT compilation, compilation processing is performed before the virtual machine loads a program. However, since AOT compilation cannot be performed according to the execution state, optimal compilation cannot be realized.
一方、JITコンパイルでは、中間コードでプログラムをロードした後、実行時にネイティブコードにコンパイルする。そのため、コンパイル後の動作は速いものの、最初の実行時にはコンパイルの処理が必要なため、実行時の負荷が高くなってしまう。そこで、JITコンパイルの処理の負荷を低減する方法として、特許文献1および特許文献2には、JITコンパイル結果を再利用する方法が開示されている On the other hand, in JIT compilation, a program is loaded with intermediate code and then compiled into native code at the time of execution. For this reason, although the operation after compilation is fast, a compilation process is required at the first execution, which increases the load at the time of execution. Therefore, as a method for reducing the processing load of JIT compilation, Patent Literature 1 and Patent Literature 2 disclose a method of reusing a JIT compilation result.
特許文献1では、JITコンパイルされたプログラムのネイティブコードを記憶装置に保持しておき、次回起動時に参照する。しかし、JITコンパイルを行ったときのデバイスの状態と次回起動時のデバイスの状態が異なると、保持するネイティブコードが再利用できない。 In Patent Document 1, the native code of a JIT-compiled program is held in a storage device and is referred to at the next startup. However, if the device state at the time of JIT compilation is different from the device state at the next startup, the retained native code cannot be reused.
特許文献2では、プログラム中のメソッド1つに対して、複数のネイティブコードを保持し、起動中の状態に応じてネイティブコードを選択して再利用する。しかし、ネイティブコードの参照はメソッド単位で行うため、プログラム中の各メソッドを実行するたびに保持するネイティブコード群から選択する処理が必要となり、プログラムの実行速度が遅くなることがある。 In Patent Document 2, a plurality of native codes are held for one method in a program, and the native codes are selected and reused according to the activated state. However, since the native code is referred to in units of methods, it is necessary to select a native code group to be held every time each method in the program is executed, and the execution speed of the program may be slow.
本発明は上記の課題に鑑みてなされたものであり、ネイティブコードを適切に利用し、コンピュータプログラムの実行速度を向上させることを目的とする。 The present invention has been made in view of the above problems, and an object of the present invention is to appropriately use native code and improve the execution speed of a computer program.
アプリケーションを実行する情報処理装置であって、前記アプリケーションをネイティブコードにコンパイルするコンパイル手段と、前記コンパイルによって生成されたネイティブコード群を保持する保持手段と、前記情報処理装置の状態を取得する取得手段と、前記情報処理装置の状態に基づいて、前記ネイティブコード群からネイティブコードを選択して利用する利用手段と、を有することを特徴とする。 An information processing apparatus for executing an application, the compiling means for compiling the application into native code, the holding means for holding a native code group generated by the compilation, and the acquisition means for acquiring the state of the information processing apparatus And using means for selecting and using a native code from the native code group based on the state of the information processing apparatus.
本発明によれば、ネイティブコードを適切に利用し、コンピュータプログラムの実行速度を向上させることが出来る。 According to the present invention, it is possible to appropriately use native code and improve the execution speed of a computer program.
以下、添付の図面を参照して、本発明の好適な実施形態を詳細に説明する。 Hereinafter, preferred embodiments of the present invention will be described in detail with reference to the accompanying drawings.
(実施形態1)
図1は、一般的な情報処理装置101のハードウェア構成の一例を示す図である。図1に示されるように情報処理装置101は、ハードウェア構成として、CPU11を含む。
(Embodiment 1)
FIG. 1 is a diagram illustrating an example of a hardware configuration of a general information processing apparatus 101. As illustrated in FIG. 1, the information processing apparatus 101 includes a
CPU11が、記憶装置13に記憶されている後述するアプリケーションやプログラム実行環境等の各々に対応するコンピュータプログラムに基づき処理を行うことによって、後述する各機能、又はフローチャートを実現する。
The
また、CPU11には、バス10を介して、入力装置12、記憶装置13、表示装置14及び外部接続IF15が接続されている。入力装置12は、情報を入力するキーボード及び/又はマウスである。記憶装置13は、例えば、ROM、RAM、ハードディスク装置等を含み、上述した各プログラム以外に、プログラムに基づく処理で用いられるデータ等を記憶する。表示装置14は、画面等を表示するディスプレイである。外部接続IF15は、ネットワークインタフェース、外部機器との各種接続インタフェースである。
Further, an
尚、CPU11はプログラムを実行することで各種の手段として機能することが可能である。なお、CPU11と協調して動作するASICなどの制御回路がこれらの手段として機能してもよい。また、CPU11と情報処理装置101の動作を制御する制御回路との協調によってこれらの手段が実現されてもよい。また、CPU11は単一のものである必要はなく、複数であってもよい。この場合、複数のCPU11は分散して処理を実行することが可能である。また、複数のCPU11は単一のコンピュータに配置されていてもよいし、物理的に異なる複数のコンピュータに配置されていてもよい。なお、CPU11がプログラムを実行することで実現する手段が専用の回路によって実現されてもよい。
The
次に、情報処理装置101上に構築するシステム構成について、図2を用いて説明する。図2は、情報処理装置101のシステム構成の一例を示す図である。 Next, a system configuration built on the information processing apparatus 101 will be described with reference to FIG. FIG. 2 is a diagram illustrating an example of a system configuration of the information processing apparatus 101.
オペレーティングシステム201は、システム全体の基盤となるソフトウェアである。仮想マシン202は、オペレーティングシステム201上のプロセスでありながら、自身の上でアプリケーションが動作する環境を提供するソフトウェアである。アプリケーション203は仮想マシン202で実行されるプログラムであり、中間コードによって構成されている。
The
次に、仮想マシン202の具体的な構成を、図3を用いて説明する。図3は仮想マシン202が備える機能を示す図である。仮想マシン202は、中間コードを実行するインタプリタ301を備える。また、仮想マシン202は、中間コードをネイティブコードにコンパイルするJITコンパイラ302を備える。JITコンパイラ302は、コンパイルしたネイティブコードをJITコードキャッシュ303に格納する。通常、JITコードキャッシュ303は、記憶装置13中の特定のメモリ領域である。もしメモリでなくハードディスクなどの記憶装置13中の不揮発性記憶領域にすると、アクセスが遅くなって処理が遅くなってしまう。
Next, a specific configuration of the
次に、再利用するために保存するスナップショットの構成を、図4を用いて説明する。図4は、記憶装置13上に保存したスナップショット401の構成を示す図である。スナップショット401は、機器の状態に応じて複数保存されうる。スナップショット401はネイティブコード群402を備える。ネイティブコード群402は、仮想マシン202の実行中にJITコードキャッシュ303に保存されるネイティブコードの集合である。また、スナップショット401は、ネイティブコード中のアドレスを機器の状態に適した値に変換するためのアドレス変換テーブル403を備える。また、スナップショット401は、スナップショットの適用開始条件404、適用停止条件405、削除条件406を備える。
Next, the configuration of a snapshot stored for reuse will be described with reference to FIG. FIG. 4 is a diagram showing the configuration of the
仮想マシン202は、機器の状態を取得する機器状態取得手段304を備える。機器の状態には、例えば機器のネットワーク設定状態や、機器の起動モードがある。また、仮想マシン202は、仮想マシン202上で実行しているプログラムを監視するための実行プログラム監視手段305を備える。また、仮想マシン202は、スナップショット401を管理するスナップショット管理手段306を備える。スナップショット管理手段306は、複数のスナップショット401をスナップショット管理テーブル801によって管理する。図8にスナップショット401を管理するテーブルの一例を示す。
The
具体的に、本実施形態における仮想マシン202はJRE(Java Runtime Environment)とする。JREとは、Java(登録商標)言語で開発されたソフトウェアを実行するために必要なソフトウェアのセットである。JREは、クラスライブラリ、JavaVM(Java言語にて記述されたアプリケーションを実行するためのソフトウェア)、及びJREを搭載する端末固有のポーティングレイヤを含む。以降では、情報処理装置101を機器と記す。
Specifically, the
JITコンパイルでは、Javaプログラムのメソッドをネイティブコードに変換する。JITコンパイルの処理の負荷を低減するには、以前のJITコンパイルで作成したネイティブコードの再利用が有効となる。しかし、機器の設定によっては、以前のネイティブコードを再利用できない。例えば、ネットワーク設定がIPv4アドレスであるときには、IPv4アドレス用のメソッドが実行される。一方、ネットワーク設定がIPv6アドレスであるときには、IPv6アドレス用のメソッドが実行される。そのため、IPv4アドレス設定のときに作成されたネイティブコードは、IPv6アドレス設定のときに再利用できない。そこで、機器の状態に応じたJITコンパイル結果を保存しておき、選択して再利用する仕組みが必要となる。また、再利用をメソッド単位で行うと、メソッドを実行する度に保存したネイティブコードを取得するオーバヘッドが生じ、機器が高速に動作できない。高速に動作するためには、実行するメソッド群に対応するネイティブコード群を一度に取得する仕組みが必要となる。 In JIT compilation, Java program methods are converted to native code. In order to reduce the processing load of JIT compilation, it is effective to reuse the native code created by the previous JIT compilation. However, depending on the device settings, the previous native code cannot be reused. For example, when the network setting is an IPv4 address, a method for the IPv4 address is executed. On the other hand, when the network setting is an IPv6 address, a method for the IPv6 address is executed. For this reason, the native code created when setting the IPv4 address cannot be reused when setting the IPv6 address. Therefore, it is necessary to have a mechanism for storing the JIT compilation result corresponding to the state of the device, selecting it, and reusing it. In addition, if reuse is performed in units of methods, an overhead for acquiring the stored native code every time a method is executed occurs, and the device cannot operate at high speed. In order to operate at high speed, a mechanism for acquiring a group of native codes corresponding to a group of methods to be executed at a time is necessary.
これらの仕組みを実現する実施形態を、図5、図8を用いて説明する。図5は機器の起動処理のフローチャートである。図8はスナップショット管理テーブルの例を示す図である。 An embodiment for realizing these mechanisms will be described with reference to FIGS. FIG. 5 is a flowchart of device activation processing. FIG. 8 is a diagram illustrating an example of a snapshot management table.
本実施形態では、以前の起動時にJITコンパイルしたネイティブコードを利用して起動する方法について説明する。機器の起動が開始されると、オペレーティングシステム201が起動する。そして、アプリケーション203を実行するための仮想マシン202の起動が開始される。仮想マシン202は、機器状態取得手段304によって、機器の状態を取得する(S501)。また、スナップショット管理手段306によって、スナップショット管理テーブル801を取得する(S502)。そして、仮想マシン202はスナップショット作成指示があるかを確認する(S503)。スナップショット作成指示としては、記憶装置13上に機器を操作するユーザが作成するフラグファイルや、仮想マシン202の起動時に与えるオプション値などが考えられる。例えば工場で機器を生産するときに、工員がスナップショット401の作成指示をだして機器を再起動することで、スナップショット401を作成する。
In the present embodiment, a method for starting using native code compiled by JIT at the previous start-up will be described. When the activation of the device is started, the
ステップS503においてスナップショット作成指示がある場合、仮想マシン202は機器の起動処理を実行する(S504)。起動処理では、機器のUIや各種機能を実現するアプリケーション203を起動する。これらの処理において、インタプリタ301で頻繁に実行されるメソッドは、JITコンパイラ302によってJITコンパイルされる。コンパイルされたネイティブコードはJITコードキャッシュ303に格納される。機器の起動処理は、機器のUIが操作可能となり、基本機能をユーザが利用できるようになった段階で完了する。仮想マシンが機器の起動処理が完了したことを検知するには、機器上で動作する複数のアプリケーション203を管理するアプリケーション管理フレームワークが発行する起動完了イベントを受信する方法がある。機器の起動処理が完了すると、仮想マシン202はスナップショット401を作成する(S505)。スナップショット401の作成処理については、後述する。以降では、起動完了イベントを受信したときを、起動完了と記す。
If there is a snapshot creation instruction in step S503, the
ステップS503においてスナップショット作成指示がない場合、仮想マシン202はスナップショット管理テーブル801を参照して、状態に応じたスナップショット401があるかを確認する(S506)。確認は、スナップショット管理テーブル801内のスナップショット401の適用開始条件を参照し、現在の機器の状態に応じるものがあるかどうかを調べることで行う。状態に応じたスナップショット401がない場合、仮想マシン202はスナップショット401の作成条件を満たしているかを確認する(S512)。スナップショット401の作成条件について、通常なら作成しても問題ない。しかし、メンテナンスモードで機器が起動している場合や、スナップショット401を保存するだけの空き容量が記憶装置13にない場合には、スナップショット401を作成しないほうが望ましい。また、実施形態2に示すように、累積したJITコンパイル処理の時間を閾値と比較して、スナップショット401を作成すべきか判断する場合もある。そこで、ステップS512において、新規に作成してもよいかを確認する。
If there is no snapshot creation instruction in step S503, the
ステップS512において、スナップショット401の作成条件を満たしている場合、ステップS504を実施する。ステップS512において、スナップショット401の作成条件を満たしていない場合、ステップS504と同様に機器の起動処理を行い(S513)、機器の起動は完了する。
If the creation conditions for the
ステップS506において状態に応じたスナップショット401がある場合、スナップショット管理手段306は、そのスナップショット401を選択する(S507)。
If there is a
そして、スナップショット管理手段306は、選択したスナップショット401のネイティブコード群402をJITコードキャッシュ303に展開する(S508)。展開においては、アドレス変換テーブル403を参照して、ネイティブコード群402に含まれるアドレスを現在の起動状態に適したアドレスに変換する。また、スナップショット管理テーブル801で、選択したスナップショットの適用中の状態は「○」にする。
Then, the
そして、選択したスナップショット401が有効に機能しているかを確認するために、適合度の確認を行う。適合度を確認するために、仮想マシン202は実行プログラム監視手段305によって実行プログラムの監視を開始する(S509)。監視では、仮想マシン202上で実行されるメソッドや、実行されるアプリケーション203を監視する。そして、ステップS504と同様に機器の起動処理を行う(S510)。起動処理が完了すると、選択したスナップショット401の適合度の確認を行う(S511)。適合度の確認処理については、後述する。
Then, in order to confirm whether or not the selected
次に、スナップショット401の作成処理について、図6を用いて説明する。図6はスナップショット401の作成処理のフローチャートである。図8のスナップショット管理テーブル801が空の状態、かつ機器のネットワーク設定がIPv4アドレスの設定である状態でステップS505から作成処理が開始されるとする。
Next, the creation process of the
スナップショット401の作成を開始すると、スナップショット管理手段306はJITコードキャッシュ303からネイティブコード群402を取得する(S601)。しかし、このネイティブコードには、オペレーティングシステム201がロードしたライブラリのアドレスのように、起動の度に値が変わるものが含まれる。そこで、ネイティブコード群402に含まれるアドレスを次回起動時に変換して適用できるように、スナップショット管理手段306はアドレス変換テーブル403を作成する(S602)。
When the creation of the
さらにスナップショット管理手段306は、機器状態取得手段304で取得した機器の状態から、適用開始条件を設定する(S603)。本実施形態で作成したネイティブコードは、機器の起動時、かつネットワーク設定がIPv4である状態で作成したものである。そこで、「機器の起動時、かつネットワーク設定がIPv4である状態」をスナップショット401の適用開始条件とする。また、実行プログラム監視手段305によって取得したプログラムの履歴と、JITコンパイラ302から取得するJITコンパイル処理の履歴を照合する。そして、JITコンパイル処理が多数発生するきっかけとなるプログラムを適用開始条件に設定する方法も考えられる。
Further, the
また、スナップショット管理手段306は、適用停止条件を設定する(S604)。適用停止条件は、利用中のスナップショット401が実際に機器で実行されるプログラムと対応しないことを判定する条件として利用する。機器の起動時に作成したスナップショットは、起動完了後の動作でしか実行されないメソッドに対応するネイティブコードを含んでいない。そのため、適用停止の条件として、「機器の起動が完了した時」を設定する。また、例えばスナップショットを作成後に203がアップデートされた場合、そのスナップショットを適用しても、スナップショットに含まれないメソッドが多く実行されることがありえる。このような場合にはスナップショットの適用を停止することが望ましい。そこで、スナップショットの適用停止条件に、「スナップショットに含まれないメソッドの実行回数が500回以上の時」を設定する。スナップショットに含まれないメソッドの実行回数の集計は、実行プログラム監視手段305が行う。
Further, the
そして、スナップショット管理手段306は、スナップショット管理テーブル801内の既存のスナップショットの更新が必要かどうかを判定する(S605)。判定方法としては、適用開始条件が同一であるスナップショット401が、スナップショット管理テーブル801内に存在するかどうかを確認する方法が単純である。
Then, the
ステップS605において更新が必要と判定すれば、既存のスナップショットを作成したスナップショットで更新する(S606)。具体的には、スナップショット管理テーブル801内の既存のスナップショット401のネイティブコード群402とアドレス変換テーブル403を、新しいものに更新する。更新では、適用開始条件が同一のスナップショットを更新するので、適用開始条件404の更新は不要である。また、適用停止条件405と削除条件406も、基本的に更新は不要である。
If it is determined in step S605 that updating is necessary, the existing snapshot is updated with the created snapshot (S606). Specifically, the
ステップS605において更新が不要と判定すれば、新しいスナップショット401を作成し、スナップショット管理テーブル801に追加する(S607)。ところで、多数のスナップショット401をスナップショット管理テーブル801に追加すると、記憶装置13の容量を多く消費してしまう。そこで、スナップショット401には、削除条件を設定する。削除の方法として、記憶装置13の空き容量が不足している場合に、使用頻度が低いスナップショットを削除する方法が適切である。そこで、標準の削除条件を「ハードディスクの空き容量が5%以下、かつスナップショット管理テーブルのスナップショット群において使用頻度が3位以下である場合」とする。
If it is determined in step S605 that no update is necessary, a
削除条件の判定を行うために、スナップショット401を適用した履歴をスナップショット管理手段306が保持する。例えば削除処理を機器の起動時に実行する場合、S501において記憶装置13の空き容量を取得する。空き容量が5%以下であれば、S502においてスナップショット管理テーブル801の各スナップショット401を適用した履歴を参照し、使用頻度が3位以下のスナップショット401を削除する。スナップショット管理テーブル801に追加したスナップショット401の削除処理を実行するタイミングとしては、機器の起動時だけでなく、機器のシャットダウン時なども考えられるが、特に制限はない。
In order to determine the deletion condition, the
次に、適合度の確認処理について、図7を用いて説明する。図7はスナップショット401の適合度の確認処理のフローチャートである。適合度は、仮想マシン202上で実行された実際のプログラムにスナップショット401がどれだけ適合するかを示す度合いである。適合度の利用方法として、スナップショット401を適用中に適合度を適宜計測し、スナップショット401の適用をいつまで行うかを判断するために利用することが考えられる。また、スナップショット401の更新が必要かどうかを判断するために利用することが考えられる。
Next, the conformity confirmation process will be described with reference to FIG. FIG. 7 is a flowchart of the confirmation process of the adaptability of the
適合度の確認では、はじめにスナップショット管理手段306が、仮想マシン202が実行したプログラムの履歴を取得する(S701)。この履歴は、実行プログラム監視手段305によって作成されたものである。
In the confirmation of the fitness level, first, the
実行したプログラムの履歴を取得すると、適用中のスナップショット401との適合度が閾値以下の値であるかを確認する(S702)。具体的な適合度の算出方法として単純な方法は、スナップショットに含まれないメソッドが実行された回数を用いる方法である。例えば、「適合度=1/(スナップショットに含まれないメソッドが実行された回数)」として、閾値を1/100とする。すると、スナップショットに含まれないメソッドが機器の起動処理中に100回以上実行された場合に、ステップS702において適合度が閾値以下となる。
When the history of the executed program is acquired, it is confirmed whether the fitness with the applied
また、適合度の算出方法として、JITコードキャッシュ303のdiffを用いる方法もありえる。スナップショット401を適用すると、ネイティブコード群402がJITコードキャッシュ303に展開される。しかし、適用したスナップショット401と機器が実行するプログラムが適合しなければ、適用したスナップショット401に対応しないメソッドの実行が頻発する。すると、それらのメソッドがJITコンパイルされ、JITコードキャッシュ303にネイティブコードとして追加されていく。また、追加時にJITコードキャッシュ303の空きがなければ、実行頻度が低いネイティブコードがJITコードキャッシュ303から削除される。この結果、JITコードキャッシュ303の内容は、スナップショット401を適用した時点の状態と差異が生じていく。そこで、スナップショット401を適用直後のJITコードキャッシュ303と、適合度の確認を行う時点でのJITコードキャッシュ303のdiffを計測し、適合度として利用する。
Further, as a method for calculating the degree of conformity, there may be a method using diff of the
ステップS702において適合度が閾値以下の場合、スナップショット401を作成する(S703)。スナップショット作成の手順については、図6を用いて前述した。ステップS702において適合度が閾値より大きい場合、適用中のスナップショットは適切であると判断し、何も行わずに適合度の確認は終了する。
If the fitness level is equal to or smaller than the threshold value in step S702, a
以上、機器の起動時にスナップショット401を利用する方法について説明した。機器の起動時には多くのメソッドが実行されるため、スナップショット401を利用してJITコンパイル処理の負荷を低減することで、機器は高速に起動する。
The method of using the
(実施形態2)
実施形態1では、機器の起動時にスナップショット401を利用する方法について説明した。しかし、機器の起動完了後に実行されるプログラムによって、JITコンパイルが多く発生することがある。例えば、機器の起動が完了したあとで、ユーザがアプリケーション203の実行を開始して、多くのJITコンパイルが発生する場合である。
(Embodiment 2)
In the first embodiment, the method of using the
このような場合にJITコンパイル処理の負荷を低減するためには、多くのJITコンパイルが発生する処理を検出してスナップショット401を作成し、次回からはそのタイミングで作成したスナップショット401を利用すればよい。
In such a case, in order to reduce the load of JIT compilation processing, a
そこで、機器の起動完了後にスナップショット401を選択して利用する方法を、実施形態2として説明する。説明は図9を用いて行う。図9は機器がプログラムを実行する処理を示すフローチャートである。機器の起動時にスナップショット管理テーブル801のスナップショット_aを選択して適用中であるとして説明する。実行するプログラムは、機器の起動が完了したのちに、ユーザの指示で起動したアプリケーション203とする。以降、このアプリケーション203を、アプリXと記す。また、スナップショット管理テーブル801にはスナップショット_aのみがある状態であるとする。
Therefore, a method for selecting and using the
仮想マシン202はプログラムを開始する前に、実行プログラムの監視を開始する(S901)。この処理はステップS509と同様である。
The
そして、仮想マシン202は、シャットダウンが指示されたかどうかを確認する(S902)。ステップS902においてシャットダウンが指示されていれば、シャットダウンの処理を実行し(S913)、プログラムの実行は終了する。
Then, the
ステップS902においてシャットダウンの指示がなければ、仮想マシン202は、プログラムを実行する(S903)。実行するプログラムの単位で最小のものはメソッドである。しかし、このフローチャートにおいて1つのメソッドを実行するたびにステップS904以降の処理を行うと、負荷が高くなってしまう。そのため、ステップS903で実行するプログラムの単位は、ある程度まとまった処理とする。例えば、メソッド100個の実行処理や、3分間の実行処理、などが考えられる。
If there is no shutdown instruction in step S902, the
プログラムの実行が終わると、スナップショット管理手段306はスナップショットを適用中かどうか確認する(S904)。実施形態1で説明したように、スナップショット401はJITコードキャッシュ303のネイティブコード群である。そのため、複数のスナップショット401では、例えばJavaの基本クラスのメソッドに対応するネイティブコードなどが重複しえる。そのため、複数のスナップショットを同時に適用すると重複を解決する必要があるため、本実施形態ではスナップショットは一度に1つしか適用しない。ここで、現在はスナップショット_aを選択して適用中であるので、スナップショット管理手段306はスナップショット_aの適用停止条件を満たしているかを確認する(S905)。
When the execution of the program ends, the snapshot management means 306 checks whether a snapshot is being applied (S904). As described in the first embodiment, the
そして、スナップショット_aの適用停止条件である「機器の起動が完了した時」を満たしているため、スナップショット管理手段306はスナップショットの適用を停止する(S907)。スナップショットの適用を停止する方法では、単にスナップショット管理テーブル801の適用中の項目を「×」にする方法が単純である。
The
そして、スナップショット管理手段306は、状態に応じたスナップショット401があるかを確認する(S908)。ここで、現在はスナップショット_aしかないため、状態に応じたスナップショットがない。そこで、スナップショットの作成条件を満たしているかを確認する(S909)。
Then, the
ステップS909の処理は基本的にステップS512と同様であるが、本実施形態でさらに詳細に説明する。スナップショット401は、ハードディスクのように大容量だが低速なデバイスに保存される。スナップショット401を適用して機器の動作を高速にするためには、低速なデバイスにアクセスする遅延時間よりも、スナップショット401の適用によって省略されるJITコンパイル処理の時間が大きくなければならない。つまり、本実施形態の場合、アプリXが起動してから発生したJITコンパイル処理の合計時間が閾値以上でなければならない。
The processing in step S909 is basically the same as that in step S512, but will be described in more detail in this embodiment. The
ステップS909において、アプリXが起動してから発生したJITコンパイル処理の合計時間が閾値以上でなければ、ステップS902に戻ってアプリXのプログラムの実行を継続する。 In step S909, if the total time of JIT compilation processing that has occurred since the application X is started is not equal to or greater than the threshold, the process returns to step S902 to continue execution of the application X program.
ステップS909において、アプリXが起動してから発生したJITコンパイル処理の合計時間が閾値以上であれば、スナップショットを作成する(S910)。スナップショットを作成する処理は、実施形態1で説明したとおりである。本実施形態では、適用開始条件として、「アプリXの実行開始時」を設定し、スナップショット管理テーブル801にスナップショット_cを作成する。また、適用停止条件には、「アプリXの停止」を設定する。また、このスナップショット_cはアプリXのプログラムに依存するものであり、アプリXがアンインストールされれば不要となる。また、アプリXがアップデートされた場合、このスナップショット_cは不適切なものとなる。そこで、スナップショット_cを作成時のアプリXのバージョンを2.0の場合、スナップショット_cの削除条件は「アプリXのアンインストール。またはアプリXのバージョンが2.0と異なるとき」とする。 In step S909, if the total time of JIT compilation processing that has occurred since the application X is started is greater than or equal to the threshold, a snapshot is created (S910). The process for creating a snapshot is as described in the first embodiment. In the present embodiment, “when application X is started” is set as an application start condition, and a snapshot_c is created in the snapshot management table 801. Also, “stop application X” is set as the application stop condition. Further, this snapshot_c depends on the program of the application X, and becomes unnecessary if the application X is uninstalled. In addition, when the application X is updated, the snapshot_c is inappropriate. Therefore, when the version of the application X at the time of creating the snapshot_c is 2.0, the deletion condition of the snapshot_c is “uninstallation of the application X or when the version of the application X is different from 2.0”.
ステップS910においてスナップショット_cを作成後、機器を再起動して再度アプリXを実行したとする。すると、ステップS908において状態に応じたスナップショット_cがあるため、スナップショット管理手段306はスナップショット_cを選択する(S911)。そして、ステップS508と同様に選択したスナップショット_cを展開する(S912)。
Assume that after creating the snapshot_c in step S910, the device is restarted and the app X is executed again. Then, since there is a snapshot_c corresponding to the state in step S908, the
以上、実行するプログラムに応じてスナップショット401を利用する方法について説明した。
The method of using the
(実施形態3)
スナップショット401を適用中かどうかでJITコンパイルの処理の動作を変える方法について、実施形態3として図10、図11を用いて説明する。図10はJITコンパイルオプションの例を示す図である。図11は仮想マシンの構成を示す図である。
(Embodiment 3)
A method of changing the operation of JIT compilation processing depending on whether or not the
仮想マシン202では、JITコンパイルにおいてインライン展開する関数の大きさの上限を指定するオプション(MaxInlineSize)を使用できる。また、JITコンパイルするメソッドを選択する条件を指定するオプション(CompileThreshold)を使用できる。これらのオプションによって、実行環境や実行対象プログラムに適したJITコンパイルを行える。インライン展開を積極的に行う、あるいはJITコンパイルするメソッドを増やすと、JITコンパイル後のプログラムの動作はより高速になる。その一方で、JITコンパイルの処理に時間がかかるようにもなる。以降、このようなJITコンパイルを、高レベルのJITコンパイルと記す。
In the
一般的に、JITコンパイルに時間をかけないように高レベルのJITコンパイルは避けられる。しかし、本発明では一度JITコンパイルすればその結果をスナップショット401として利用できるため、高レベルなJITコンパイルを行いたい。
In general, high-level JIT compilation is avoided so as not to spend time on JIT compilation. However, in the present invention, once the JIT is compiled, the result can be used as the
これを実現するためには、JITコンパイルのオプションを、スナップショット適用時とスナップショット未適用時のそれぞれで設定できるようにすればよい。スナップショット管理テーブル801に適用できるスナップショット401がなければ、実行されるメソッドを高レベルにJITコンパイルしていく。ステップS909の条件を満たすと高レベルなJITコンパイルの結果がスナップショット401として作成され、次回からはJITコンパイルをせずに高速に機器が動作する。
In order to realize this, JIT compilation options may be set when the snapshot is applied and when the snapshot is not applied. If there is no
具体的には、図10に示すように、オプション名にスナップショット401を適用時用のprefixを追加する。prefixは、”UseSnap_”のような文字列でよい。例えばCompileThresholdオプションについて、オプションの値が大きいほど、プログラムのメソッドはJITコンパイルされにくくなる。また、値が0の場合はJITコンパイルされない。また、図11に示すように、仮想マシン202はJITコンパイル指示受信手段307を備える。JITコンパイル指示受信手段307は、オプションを受け取り、JITコンパイラの動作をスナップショット401の適用時と未適用時で変更する。
Specifically, as shown in FIG. 10, a prefix for applying the
例として、仮想マシン202の実行時に、”CompileThreshold=10,UseSnap_CompileThreshold=0”というオプションを与えるとする。このオプションの場合、スナップショット401を適用していなければ多数のメソッドがネイティブコードに変換され、作成されるスナップショット401に含まれるようになる。作成したスナップショット401を適用していれば、スナップショット401に含まれないメソッドが実行されてもJITコンパイルが行われない。スナップショット401を適用中に実行されるプログラムは、すべてネイティブコード群402に対応するメソッドのみを実行することが理想である。しかし、スレッドの実行タイミングや機器に保存されたデータによっては、ネイティブコード群402に対応しないメソッドを少数だけ実行することもありえる。このようなときには少数のメソッドはJITコンパイルを行わないことで、機器全体の動作を高速化できる。
As an example, when executing the
また、JITコンパイル処理の遅延がとくに問題となるのは、ユーザが遅延を実感しやすい処理である機器の起動処理だけであることが多い。そこで、機器の起動処理中と起動完了後でJITコンパイルのオプションを変えることも有効となる。具体的には、図12のように、JITコンパイル用オプションを機器の起動処理中と起動完了後で異なるようにprefixを設定する。 In many cases, the delay of the JIT compilation process is particularly problematic only in the device activation process, which is a process in which the user can easily feel the delay. Therefore, it is also effective to change the JIT compilation options during the device startup process and after the startup is completed. Specifically, as shown in FIG. 12, the prefix is set so that the JIT compilation options are different during the device startup process and after the startup is completed.
以上、スナップショット401を適用中かどうかでJITコンパイルの処理の動作を変える方法について説明した。
The method of changing the operation of JIT compilation processing depending on whether the
(実施形態4)
実施形態3ではスナップショット401を適用中かどうかで、JITコンパイルの内容を変える方法を説明した。スナップショット401を作成するには高レベルなJITコンパイルを行いたいが、高レベルなJITコンパイルは処理に時間がかかり、機器の動作が遅くなるという問題がある。高レベルなJITコンパイルの時間を問題にならないようにするには、JITコンパイルを非同期で行えばよい。非同期でJITコンパイルを行うには、スナップショット作成用のスレッドを仮想マシン202上で実行することが単純である。以降の説明では、JITコンパイルだけでなくスナップショットの作成処理の全てを、スナップショット作成用スレッドで行うとする。
(Embodiment 4)
In the third embodiment, the method of changing the contents of JIT compilation depending on whether the
そこで、スナップショット401を作成するためのJITコンパイルを非同期で行う方法を、実施形態4として説明する。スナップショット401を作成するためのJITコンパイルのオプションのprefixは、図13に示すように”CreateSnap_”とする。
Therefore, a method for asynchronously performing JIT compilation for creating the
はじめに、仮想マシン202の構成について図14を用いて説明する。図14は、仮想マシン202の構成を示す図である。図14は図11とほぼ同様であるが、新たにスナップショット作成用JITコードキャッシュ308を備えている。スナップショット401を作成するためのJITコンパイルによって生成されるネイティブコードは、スナップショット作成用JITコードキャッシュ308に格納される。JITコードキャッシュ303はプログラムの実行時に参照するため、メモリのような高速の記憶装置13である必要があった。しかし、スナップショット作成用JITコードキャッシュ308は非同期に参照するため、ハードディスクのような低速の記憶装置13でもよい。
First, the configuration of the
次に、スナップショット401を作成する手順について図15を用いて説明する。図15はスナップショットの作成処理のフローチャートである。スナップショット401の作成を開始すると、すでにJITコードキャッシュ303に存在するネイティブコードだけでスナップショット401を作れるかを確認する(S1501)。図13に示したJITコンパイルのオプションで、スナップショット未適用時、スナップショット適用時、スナップショット作成時の各オプションが同一であるとする。このときは、JITコードキャッシュ303にあるネイティブコード群をそのままスナップショット401にすればよい。この場合、ステップS601と同様にJITコードキャッシュ303からネイティブコード群を取得する(S1502)。
Next, a procedure for creating the
ステップS1501において、JITコードキャッシュ303のネイティブコードではスナップショット401が作れない場合、スナップショット管理手段306は実行プログラム監視手段305から実行したプログラムの履歴を取得する(S1503)。そして、JITコンパイルの対象となるメソッドを選択する(S1504)。選択の方法としては、JITコンパイラ302からJITコンパイルの履歴を取得し、最後にJITコンパイルが頻発しはじめたメソッドの実行から最も新しい実行履歴のメソッドまでを選択することが単純である。
In step S1501, when the
そして、スナップショット管理手段306は、スナップショット作成用JITコードキャッシュ308に、”CreateSnap_”で始まるオプション値でJITコンパイルしたネイティブコードを生成する(S1505)。生成が終わると、スナップショット管理手段306は、スナップショット作成用JITコードキャッシュ308からネイティブコード群を取得する(S1506)。
Then, the
ステップS1502、またはステップS1506でネイティブコード群を取得すると、ステップS602と同様に、403を作成する(S1507)。また、ステップS603と同様に適用開始条件を設定し(S1508)、ステップS604と同様に適用停止条件を設定する(S1509)。 When the native code group is acquired in step S1502 or step S1506, 403 is created as in step S602 (S1507). Further, an application start condition is set in the same manner as in step S603 (S1508), and an application stop condition is set in the same manner as in step S604 (S1509).
そして、ステップS605と同様に既存のスナップショットの更新が必要かを判定する(S1510)。更新が必要であればステップS606と同様に更新を行う(S1511)。更新が必要でなければ、ステップS607と同様に作成したスナップショット401をスナップショット管理テーブル801に追加する(S1512)。
Then, similarly to step S605, it is determined whether an existing snapshot needs to be updated (S1510). If updating is necessary, updating is performed in the same manner as in step S606 (S1511). If no update is necessary, the
以上、スナップショット401を作成するためのJITコンパイルを非同期で行う方法を説明した。
The method of performing JIT compilation for creating the
(他の実施形態)
また、本発明は、以下の処理を実行することによっても実現される。即ち、上述した実施形態の機能を実現するソフトウェア(プログラム)を、ネットワーク又は各種記憶媒体を介してシステム或いは装置に供給し、そのシステム或いは装置のコンピュータ(またはCPUやMPU等)がプログラムを読み出して実行する処理である。
(Other embodiments)
The present invention can also be realized by executing the following processing. That is, software (program) that realizes the functions of the above-described embodiments is supplied to a system or apparatus via a network or various storage media, and a computer (or CPU, MPU, or the like) of the system or apparatus reads the program. It is a process to be executed.
Claims (11)
前記アプリケーションをネイティブコードにコンパイルするコンパイル手段と、
前記コンパイルによって生成されたネイティブコード群を保持する保持手段と、
前記情報処理装置の状態を取得する取得手段と、
前記情報処理装置の状態に基づいて、前記ネイティブコード群からネイティブコードを選択して利用する利用手段と、を有することを特徴とする情報処理装置。 An information processing apparatus that executes an application,
Compiling means for compiling the application into native code;
Holding means for holding a group of native codes generated by the compilation;
Obtaining means for obtaining a state of the information processing apparatus;
An information processing apparatus comprising: a utilization unit that selects and uses a native code from the native code group based on a state of the information processing apparatus.
前記コンパイル手段は、前記監視手段による監視の結果に基づいて、前記ネイティブコード群を作成することを特徴とする請求項1に記載の情報処理装置。 Further comprising monitoring means for monitoring a program executed by the information processing apparatus;
The information processing apparatus according to claim 1, wherein the compiling unit creates the native code group based on a result of monitoring by the monitoring unit.
複数のネイティブコード群を保持することを特徴とする請求項8に記載の情報処理装置。 The holding unit is based on information on whether or not the native code group is used,
The information processing apparatus according to claim 8, wherein a plurality of native code groups are held.
コンパイル手段が、前記アプリケーションをネイティブコードにコンパイルするコンパイル工程と、
保持手段が、前記コンパイルによって生成されたネイティブコード群を保持する保持工程と、
取得手段が、前記情報処理装置の状態を取得する取得工程と、
利用手段が、前記情報処理装置の状態に基づいて、前記ネイティブコード群からネイティブコードを選択して利用する利用工程と、を有することを特徴とする情報処理方法。 An information processing method for an information processing apparatus that executes an application,
A compiling step for compiling the application into native code;
A holding step in which holding means holds a group of native codes generated by the compilation;
An obtaining step for obtaining a state of the information processing apparatus;
And a utilization step of selecting and using a native code from the native code group based on a state of the information processing apparatus.
アプリケーションを実行する情報処理装置であって、
前記アプリケーションをネイティブコードにコンパイルするコンパイル手段と、
前記コンパイルによって生成されたネイティブコード群を保持する保持手段と、
前記情報処理装置の状態を取得する取得手段と、
前記情報処理装置の状態に基づいて、前記ネイティブコード群からネイティブコードを選択して利用する利用手段と、を有することを特徴とする情報処理装置として機能させるためのコンピュータプログラム。 Computer
An information processing apparatus that executes an application,
Compiling means for compiling the application into native code;
Holding means for holding a group of native codes generated by the compilation;
Obtaining means for obtaining a state of the information processing apparatus;
A computer program for functioning as an information processing apparatus, comprising: a utilization unit that selects and uses a native code from the native code group based on a state of the information processing apparatus.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2018035569A JP2019152911A (en) | 2018-02-28 | 2018-02-28 | Information processing apparatus, information processing method and computer program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2018035569A JP2019152911A (en) | 2018-02-28 | 2018-02-28 | Information processing apparatus, information processing method and computer program |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2019152911A true JP2019152911A (en) | 2019-09-12 |
Family
ID=67946330
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2018035569A Pending JP2019152911A (en) | 2018-02-28 | 2018-02-28 | Information processing apparatus, information processing method and computer program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2019152911A (en) |
-
2018
- 2018-02-28 JP JP2018035569A patent/JP2019152911A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4828271B2 (en) | Software generation apparatus for multiple OS versions and software generation support program for multiple OS versions | |
JP5167589B2 (en) | Application server device and virtual machine program | |
JP2014170515A (en) | Device, information storage program, and information storage method | |
US20150242205A1 (en) | Non-Transitory Computer-Readable Recording Medium Storing Application Development Support Program and Application Development Support System That Automatically Support Platform Version | |
CN110825428A (en) | State machine configuration method, device, equipment and readable storage medium | |
JP6879625B2 (en) | Programmable controller, management device and control system | |
JP5489884B2 (en) | Instruction execution device, instruction execution method, and instruction execution program | |
JP2020030621A (en) | Information processing unit and program | |
CN106250068B (en) | Image forming apparatus and application deletion method | |
JP6555981B2 (en) | Information processing apparatus and control method thereof | |
JP2017126293A (en) | Information processing apparatus and resource management method | |
US9335990B2 (en) | Method, a system, and a non-transitory computer-readable medium for supporting application development | |
JP2019152911A (en) | Information processing apparatus, information processing method and computer program | |
JP2016051395A (en) | Image forming apparatus and resource management method | |
JP2021048489A (en) | Information processing apparatus, method of controlling the same, and program | |
JP2015210769A (en) | Information processing device, information processing method, and program | |
JP2016224559A (en) | Program creation support device, control method and program | |
JP2015197845A (en) | Information processing apparatus and control method of the same, and program | |
KR101670916B1 (en) | Method for storing function and system device using the same | |
JP2008305021A (en) | Information processor and application management method | |
CN112486511A (en) | Method for generating operating system installation mirror image through web | |
JP6398456B2 (en) | Software generator | |
JP2019046001A (en) | Application porting support device, application porting support program, and application porting method | |
JP6143476B2 (en) | Application processing apparatus, method, and program thereof | |
US11397572B2 (en) | Image forming apparatus capable of executing extension application, method of controlling same, and storage medium |