JP2023085797A - Information processing program, information processing device, and information processing method - Google Patents
Information processing program, information processing device, and information processing method Download PDFInfo
- Publication number
- JP2023085797A JP2023085797A JP2021200032A JP2021200032A JP2023085797A JP 2023085797 A JP2023085797 A JP 2023085797A JP 2021200032 A JP2021200032 A JP 2021200032A JP 2021200032 A JP2021200032 A JP 2021200032A JP 2023085797 A JP2023085797 A JP 2023085797A
- Authority
- JP
- Japan
- Prior art keywords
- processing
- event
- buffer
- flag
- events
- 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.)
- Granted
Links
- 230000010365 information processing Effects 0.000 title claims abstract description 70
- 238000003672 processing method Methods 0.000 title claims abstract description 9
- 238000012545 processing Methods 0.000 claims abstract description 421
- 230000003139 buffering effect Effects 0.000 claims abstract description 103
- 238000000034 method Methods 0.000 claims abstract description 96
- 230000008569 process Effects 0.000 claims abstract description 68
- 239000000872 buffer Substances 0.000 claims description 457
- 230000015654 memory Effects 0.000 claims description 149
- 238000009825 accumulation Methods 0.000 claims description 34
- 230000005540 biological transmission Effects 0.000 abstract description 207
- 230000000903 blocking effect Effects 0.000 abstract description 43
- 238000004891 communication Methods 0.000 abstract description 42
- 238000007726 management method Methods 0.000 description 71
- 230000006870 function Effects 0.000 description 49
- 238000010586 diagram Methods 0.000 description 14
- 230000001360 synchronised effect Effects 0.000 description 9
- 238000012790 confirmation Methods 0.000 description 8
- 230000008859 change Effects 0.000 description 6
- 230000004048 modification Effects 0.000 description 6
- 238000012986 modification Methods 0.000 description 6
- 230000001419 dependent effect Effects 0.000 description 5
- 230000000694 effects Effects 0.000 description 5
- 230000004044 response Effects 0.000 description 5
- 230000002159 abnormal effect Effects 0.000 description 3
- 238000006243 chemical reaction Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 238000013467 fragmentation Methods 0.000 description 3
- 238000006062 fragmentation reaction Methods 0.000 description 3
- 230000007246 mechanism Effects 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 230000003213 activating effect Effects 0.000 description 1
- 230000002776 aggregation Effects 0.000 description 1
- 238000004220 aggregation Methods 0.000 description 1
- 230000006835 compression Effects 0.000 description 1
- 238000007906 compression Methods 0.000 description 1
- 230000003111 delayed effect Effects 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000001152 differential interference contrast microscopy Methods 0.000 description 1
- 230000007717 exclusion Effects 0.000 description 1
- 238000004880 explosion Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000007689 inspection Methods 0.000 description 1
- 230000014759 maintenance of location Effects 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000002250 progressing effect Effects 0.000 description 1
- 238000012857 repacking Methods 0.000 description 1
- 230000000717 retained effect Effects 0.000 description 1
- 239000010979 ruby Substances 0.000 description 1
- 229910001750 ruby Inorganic materials 0.000 description 1
- 230000011664 signaling Effects 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
- Computer And Data Communications (AREA)
Abstract
Description
本発明は、情報処理プログラム、情報処理装置及び情報処理方法に関する。 The present invention relates to an information processing program, an information processing apparatus, and an information processing method.
従来の技術として、データの大きさに応じて使用するバッファを変更してデータを送信する情報処理装置が提案されている(例えば、特許文献1参照)。 As a conventional technology, an information processing apparatus has been proposed that transmits data by changing the buffer to be used according to the size of the data (see, for example, Japanese Unexamined Patent Application Publication No. 2002-100002).
特許文献1に開示された情報処理装置のCPU(Central Processing Unit)は、アプリケーションバッファエリアを占有するアプリケーションタスクとリングバッファエリアを占有するTCP(Transmission Control Protocol)/IP(Internet Protocol)タスクとを並列的に実行する。アプリケーションタスクは、データ生成処理によってアプリケーションバッファエリアに格納されたデータのサイズが閾値以下であるか否かを判別し、判別結果が肯定的であるときアプリケーションバッファエリア上のデータをリングバッファエリアに複製してデータ送信指示を発行する一方、判別結果が否定的であるときアプリケーションバッファエリアの占有権をTCP/IPタスクに一時的に付与してデータ送信指示を発行する。TCP/IPタスクは、自ら占有するメモリエリア上の送信データをデータ送信指示に応答して送信する。
A CPU (Central Processing Unit) of the information processing apparatus disclosed in
しかし、特許文献1の情報処理装置は、送信するデータ量が少ない場合はリングバッファを用いてデータを送信して、アプリケーションタスクを並列して行い、送信するデータ量が多い場合はTCP/IPタスクを専有的に処理することで通信速度の高速化を図るものの、送信するデータ量が多い場合はアプリケーションタスクがブロッキングされて処理されない、という問題がある。
However, when the amount of data to be transmitted is small, the information processing apparatus of
従って本発明の目的は、アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化する情報処理プログラム、情報処理装置及び情報処理方法を提供することにある。 SUMMARY OF THE INVENTION Accordingly, it is an object of the present invention to provide an information processing program, an information processing apparatus, and an information processing method that speed up communication by executing application processing and data transmission in a non-blocking manner.
本発明の一態様は、上記目的を達成するため、以下の情報処理プログラム、情報処理装置及び情報処理方法を提供する。 One aspect of the present invention provides the following information processing program, information processing apparatus, and information processing method in order to achieve the above object.
[1]コンピュータを、
処理対象とするイベントを蓄積するイベント蓄積手段と、
前記イベントを蓄積するバッファリング手段と、
前記蓄積したイベントを処理する処理手段と、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段として機能させ、
前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了し
た場合に完了通知を受けて実行するコールバック処理手段とを含み、
前記フラグ管理手段は、前記イベント処理要求手段がイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理手段の処理の終了後のタイミングでフラグを解除し、
前記処理要求手段は、前記イベント蓄積手段の前記バッファリング手段へのイベント蓄積終了後のタイミング及び前記コールバック処理手段のイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理プログラム。
[2]前記バッファリング手段は、イベントを蓄積する第1のバッファリング手段と、前記第1のバッファリング手段に蓄積された前記イベントを蓄積する第2のバッファリング手段とを有し、
前記処理要求手段は、フラグが立てられた場合に、前記第1のバッファリング手段から前記第2のバッファリング手段に前記イベントを移動して蓄積し、前記第2のバッファリング手段が蓄積している前記イベントの全て又は一部を処理する前記[1]に記載の情報処理プログラム。
[3]前記第1のバッファリング手段と前記第2のバッファリング手段の間、前記第1のバッファリング手段の前段又は前記第2のバッファリング手段の後段に、さらに1以上のバッファリング手段を有する前記[2]に記載の情報処理プログラム。
[4]前記バッファリング手段間の移動において、データブロックのサイズ、個数、タイプ、イベント保持形式の少なくとも1つを変更する前記[2]又は[3]に記載の情報処理プログラム。
[5]前記バッファリング手段間の移動において、移動イベントの数やサイズを予め定めた条件で制限する前記[2]~[4]のいずれかに記載の情報処理プログラム。
[6]前記バッファリング手段は、イベント蓄積手段のイベント蓄積動作と、前記処理手段の処理動作とが、非同期に実行される前記[1]から[5]のいずれかに記載の情報処理プログラム。
[7]前記バッファリング手段は、並列動作する複数のイベント生成元が実行するそれぞれのイベントの蓄積手段が非同期にイベントを蓄積する前記[1]から[6]のいずれかに記載の情報処理プログラム。
[8]前記バッファリング手段は、リングバッファである前記[1]から[7]のいずれかに記載の情報処理プログラム。
[9]前記バッファリング手段は、前記イベントそのものをメモリ領域に順次蓄積するリングバッファである前記[1]に記載の情報処理プログラム。
[10]前記バッファリング手段は、2段リングバッファ構成であり、第1段のリングバッファは並列動作するイベント蓄積手段のイベントを蓄積し、第2段のリングバッファは前記処理手段の処理に応じて定められたサイズに当該イベントを連結および分割するとともに前記処理手段に応じて定められた個数保持する前記[2]、[6]又は[7]に記載の情報処理プログラム。
[11]前記バッファリング手段は、ダイレクトバッファに前記イベントを格納することを特徴とする前記[1]、[2]又は[6]から[10]のいずれかに記載の情報処理プログラム。
[12]前記バッファリング手段は、バッファプールのバッファに前記イベントを蓄積する前記[1]、[2]又は[6]から[10]のいずれかに記載の情報処理プログラム。
[13]前記バッファリング手段は、前記第1段のリングバッファと前記第2段のリングバッファとで、異なるバッファサイズを保持するバッファプールのバッファにイベントを蓄積する前記[10]に記載の情報処理プログラム。
[14]前記処理手段は、蓄積されている前記イベントをすべて処理してからイベント処理を終了する前記[1]から[13]のいずれかに記載の情報処理プログラム。
[15]処理対象とするイベントを蓄積するイベント蓄積手段と、
前記イベントを蓄積するバッファリング手段と、
前記蓄積したイベントを処理する処理手段と、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段とを有し、
前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了し
た場合に完了通知を受けて実行するコールバック処理手段とを含み、
前記フラグ管理手段は、前記イベント処理要求手段がイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理手段の処理の終了後のタイミングでフラグを解除し、
前記処理要求手段は、前記イベント蓄積手段の前記バッファリング手段へのイベント蓄積終了後のタイミング及び前記コールバック処理手段のイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理装置。
[16]コンピュータを、
処理対象とするイベントを蓄積するイベント蓄積ステップと、
前記イベントを蓄積するバッファリングステップと、
前記蓄積したイベントを処理する処理ステップと、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理ステップとを有し、
前記処理ステップは、イベントの処理を要求する処理要求ステップと、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理ステップとを含み、
前記フラグ管理ステップは、前記イベント処理要求ステップにおけるイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理ステップにおける処理の終了後のタイミングでフラグを解除し、
前記処理要求ステップは、前記イベント蓄積ステップにおけるイベント蓄積終了後のタイミング及び前記コールバック処理ステップにおけるイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は蓄積した前記イベントを処理する情報処理方法。
[1] a computer,
event accumulation means for accumulating events to be processed;
buffering means for accumulating the events;
a processing means for processing the accumulated events;
act as a flag manager that accepts calls and sets flags exclusively,
The processing means includes processing request means for requesting event processing, and callback processing means for receiving a completion notification and executing when the event processing is completed,
The flag management means exclusively sets the flag at a timing before the event processing requesting means starts processing the event, and cancels the flag at the timing after the processing of the callback processing means ends,
The processing request means receives a call at a timing after the event accumulation means finishes accumulating the event in the buffering means and at a timing after the event processing ends for the callback processing means, and responds to the flag of the flag management means. an information processing program for terminating without processing if the flag is not set, and processing the event accumulated by the buffering means if the flag is set.
[2] The buffering means has a first buffering means for accumulating events and a second buffering means for accumulating the events accumulated in the first buffering means,
The processing request means moves and accumulates the event from the first buffering means to the second buffering means when the flag is set, and the second buffering means accumulates the event. The information processing program according to [1], which processes all or part of the event.
[3] One or more buffering means are further provided between the first buffering means and the second buffering means, before the first buffering means, or after the second buffering means. The information processing program according to [2] above.
[4] The information processing program according to [2] or [3], wherein at least one of data block size, number, type, and event holding format is changed in the movement between the buffering means.
[5] The information processing program according to any one of [2] to [4], wherein the number and size of movement events in movement between the buffering means are restricted according to predetermined conditions.
[6] The information processing program according to any one of [1] to [5], wherein the event accumulation operation of the event accumulation means and the processing operation of the processing means are executed asynchronously in the buffering means.
[7] The information processing program according to any one of [1] to [6], wherein the buffering means stores events asynchronously by respective event storage means executed by a plurality of event generators operating in parallel. .
[8] The information processing program according to any one of [1] to [7], wherein the buffering means is a ring buffer.
[9] The information processing program according to [1], wherein the buffering means is a ring buffer that sequentially accumulates the event itself in a memory area.
[10] The buffering means has a two-stage ring buffer structure, the first stage ring buffer stores events of the event storage means operating in parallel, and the second stage ring buffer responds to the processing of the processing means. The information processing program according to the above [2], [6], or [7], which connects and divides the event into a size determined by the above and holds the number of events determined according to the processing means.
[11] The information processing program according to any one of [1], [2], or [6] to [10], wherein the buffering means stores the event in a direct buffer.
[12] The information processing program according to any one of [1], [2], or [6] to [10], wherein the buffering means accumulates the event in a buffer of a buffer pool.
[13] The information according to [10], wherein the buffering means accumulates events in buffers of buffer pools holding different buffer sizes for the first stage ring buffer and the second stage ring buffer. processing program.
[14] The information processing program according to any one of [1] to [13], wherein the processing means finishes event processing after processing all the accumulated events.
[15] event accumulation means for accumulating events to be processed;
buffering means for accumulating the events;
a processing means for processing the accumulated events;
a flag management means for accepting calls and setting flags exclusively,
The processing means includes processing request means for requesting event processing, and callback processing means for receiving a completion notification and executing when the event processing is completed,
The flag management means exclusively sets the flag at a timing before the event processing requesting means starts processing the event, and cancels the flag at the timing after the processing of the callback processing means ends,
The processing request means receives a call at a timing after the event accumulation means finishes accumulating the event in the buffering means and at a timing after the event processing ends for the callback processing means, and responds to the flag of the flag management means. If the flag is not set, the information processing device ends without processing, and if the flag is set, the event accumulated by the buffering means is processed.
[16] a computer;
an event accumulation step for accumulating events to be processed;
a buffering step of accumulating the events;
a processing step of processing the accumulated events;
a flag management step for accepting and exclusively flagging calls;
The processing step includes a processing request step that requests processing of the event, and a callback processing step that is executed upon receiving a completion notification when processing of the event is completed,
The flag management step exclusively sets the flag at a timing before the start of event processing in the event processing request step, and releases the flag at a timing after the processing in the callback processing step ends,
The process request step accepts a call at the timing after the event accumulation in the event accumulation step ends and the event processing in the callback processing step ends, and if the flag is not set, the process is not performed. an information processing method for processing the accumulated event if set.
請求項1、15、16に係る発明によれば、アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化することができる。
According to the inventions according to
[第1の実施の形態]
(通信管理システムの構成)
図1は、実施の形態に係る通信管理システムの構成の一例を示す概略図である。
[First embodiment]
(Configuration of communication management system)
FIG. 1 is a schematic diagram showing an example of the configuration of a communication management system according to an embodiment.
この通信管理システムは、情報処理装置としてのサーバ装置1と、当該サーバ装置1のクライアントとしての端末装置2a、2b、2cとをネットワークによって互いに通信可能に接続することで構成される。通信管理システムに含まれる装置は、パソコン、ゲーム端末、クラウド、仮想マシンであってもよい。ネットワークは、LANやインターネットであってもよいし、仮想ネットワークなどであってもよい。
This communication management system is configured by connecting a
サーバ装置1は、サーバ型の情報処理装置であり、操作者の操作する端末装置2a、2b、2cの要求に応じて動作するものであって、本体内に情報を処理するための機能を有するCPU(Central Processing Unit)やHDD(Hard Disk Drive)又はフラッシュメモリ、揮発性メモリ、LANボード(無線/有線)等の電子部品を備える。サーバ装置1は、端末装置2a、2b、2cと通信し、データの送受信を行うことで端末装置2a、2b、2c上で扱うデータの同期を行うものであって、例えば、ゲームサーバ等である。サーバ装置1は、同期動作を行う場合は容量の小さいデータを頻繁にやりとりするものであるが、これに限られるものではない。なお、サーバ装置1は、複数のクラスタによって構成してもよく、分散処理を実行するよう構成してもよい。あるいは、クラウド環境において仮想マシンとして構成してもよい。
The
端末装置2a、2b、2cは、端末型の情報処理装置であり、プログラムに基づいて動作するものであって、本体内に情報を処理するための機能を有するCPUやHDD又はフラッシュメモリ等の電子部品を備える。端末装置2a、2b、2cは、例えば、MMOG(Massively Multiplayer Online Game)等のプログラムに基づいて動作し、動作の結果としてデータをサーバ装置1に対して逐次出力するとともに、サーバ装置1から他の端末の動作の結果としてのデータを受信して各端末装置2a、2b、2c間で高頻度にゲームオブジェクトを同期するものである。なお、端末装置2a、2b、2cは3つの装置で描かれているが単一あるいは2個の装置であってもよいし、4以上の装置で構成してもよく、好ましくは、1000台オーダーの端末装置が接続されるような場合であっても通信可能な構成を提供する。
The
ネットワーク4は、高速通信が可能な通信ネットワークであり、例えば、イントラネットやLAN(Local Area Network)等の有線又は無線の通信網である。
The
一例として、第1の実施の形態における通信管理システムにおいて、複数の参加者が共通の仮想空間における活動、例えばゲームを行う多人数参加型ゲームが実行される。サーバ装置1及び端末装置2a、2b、2cは、ゲームの進行に伴い各装置内でオブジェクトとして保持している情報(同期対象オブジェクト)を、各装置間で同期するために動作し、特にサーバ装置1は、データ通信を高速化すべくアプリケーションとNIC(Network Interface Card)との間にバッファを設けてアプリケーションとNIC間のデータ授受の動作を制御する。言い換えれば、マルチプロセス、マルチスレッドが、共有リソース(ソケットやNIC)に非同期に書き込む要求が大量に発生する場合、データが混ざらないようにシリアライズするには、排他制御が必要となるため、送信通信路を効率よく使用(特に、送信通路がデータで混雑してからのスループット向上)するために、バッファにバッファリングして、当該バッファへの書込で排他制御(ブロッキング)を行い、当該バッファからの共有リソースへの書込はCAS(Compare and Swap)等でロックフリー(ノンブロッキング)な制御をする。動作の詳細について、実施の形態において具体的に説明する。
As an example, in the communication management system according to the first embodiment, a multiplayer game is executed in which a plurality of participants play an activity, such as a game, in a common virtual space. The
また、第1の実施の形態において使用する「オブジェクト」等の語句は、例えば、Java(登録商標)、C++、C#、Python、JavaScript(登録商標)、Ruby等で用いられる同語句と同義で用いられるが、以降、クラス、及びインスタンス化されたクラス(インスタンス)のことを総称して「オブジェクト」と言う場合がある。 In addition, terms such as “object” used in the first embodiment are synonymous with synonyms used in, for example, Java (registered trademark), C++, C#, Python, JavaScript (registered trademark), Ruby, and the like. Although used, hereinafter, classes and instantiated classes (instances) may be collectively referred to as "objects."
(サーバ装置の構成)
図2は、第1の実施の形態に係るサーバ装置1の構成例を示すブロック図である。以下にサーバ装置1での実装について記述するが、端末装置2a、2b、2cも同様な構成としてもよい。
(Configuration of server device)
FIG. 2 is a block diagram showing a configuration example of the
サーバ装置1は、CPU(Central Processing Unit)等から構成され、各部を制御するとともに、各種のプログラムを実行する制御部10と、フラッシュメモリ等の記憶媒体から構成され情報を記憶する記憶部11と、揮発性記録媒体から構成され一時的に情報を記憶するメモリ12と、ネットワークを介して外部と通信する通信部13とを備える。
The
制御部10は、OS(Operating System)110を実行することで、OS実行手段100(Javaの場合はJVMも含む)として機能し、アプリケーション112を実行することで、アプリケーション実行手段103、アプリケーション読出手段104、アプリケーション書込手段105として機能し、情報処理プログラムとしての通信管理プログラム111を実行することで、ソケット読出手段101、ソケット書込手段102、バッファリング手段106(受信バッファ106aと送信バッファ106bを含む)、フラグ管理手段107等として機能する。
The
OS実行手段100(OSカーネル)は、OS110を実行し、OS110が有する各機能を提供する。OS実行手段100は、特に通信部13(NIC)を制御してネットワークにデータを送信し、ネットワークからデータを受信する。なお、JAVAを利用している場合は、Java VMもOSの一部とみなし、OS実行手段100によって実行されるものとする。
The OS executing means 100 (OS kernel) executes the
アプリケーション実行手段103は、処理手段としてアプリケーション112を実行し、アプリケーション112が有する各機能を提供するものであり、実行に伴い単一又は複数のスレッドを処理する。典型的には、それぞれのスレッドは、単一又は複数の端末装置とそれぞれ対応する単一又は複数のソケット(端末装置2a、2b、又は、2cの通信対象プログラムのIPアドレス及びポート番号)を介してネットワーク通信(送受信)を行う。
The application execution means 103 executes the
アプリケーション読出手段104は、アプリケーション112が有する機能として特に、スレッドの受信処理のために受信対象となるソケット(端末装置2a、2b、又は、2c)に対応する受信バッファ106aのデータを読み出す。
As a function of the
アプリケーション書込手段105は、スレッドの処理の結果生成されたデータを送信対象となるソケット(端末装置2a、2b、又は、2c)に対応する送信処理のために送信バッファに書き込む。書き込まれたデータは通常は書き込まれた順に送信バッファ121bに追加される。例えば、ゲームサーバがゲームオブジェクトの同期処理のため、同期情報のリレー処理を行う場合、アプリケーション書込手段105は、端末装置2aから同期情報のデータ受信し、スレッドで受信データを処理した結果、端末装置2b、及び、2cに同期情報データを送信する。アプリケーション書込手段105は、それぞれの端末装置に対応する2個のソケットに対応する2個の送信バッファ121bにデータを書き込む。アプリケーション書込手段105は、送信バッファ121bにデータを追加した後、ソケット書込要求手段102aを呼び出す。
The
ソケット読出手段101は、OS110が有する機能として特に、ネットワークとの通信においてソケットによって受信したデータを後述する受信バッファ106aに読み出す。
As a function of the
処理手段としてのソケット書込手段102は、処理要求手段としてのソケット書込要求手段102aとコールバック処理手段102bとして機能する。 Socket writing means 102 as processing means functions as socket writing request means 102a and callback processing means 102b as processing request means.
図6及び図8は、ソケット書込要求手段102aの動作例を説明するためのフローチャートである。また、図7は、コールバック処理手段102bの動作例を説明するためのフローチャートである。 6 and 8 are flow charts for explaining an operation example of the socket write request means 102a. Also, FIG. 7 is a flow chart for explaining an operation example of the callback processing means 102b.
図6に示すように、ソケット書込要求手段102aは、まず、フラグ管理手段107に依頼して、フラグ管理手段107の管理するフラグの状態を確認し(S10)、フラグが解除されている場合(S11;Yes)、フラグを立てる(S12)。ソケット書込要求手段102aは、アプリケーション書込手段105がイベントをリングバッファ121bに書き込み処理を終了する直前、及びソケット書込要求手段102aの完了後に実行される対応するコールバック処理手段102bの完了直前のいずれかから非同期に呼び出される。呼び出しは通常のメソッドあるいは関数の呼び出しでもよいし、あるいは、OS機能を使い待機しているスレッドへのシグナリングによる起動でもよい。フラグが立てられると、次に、ソケット書込要求手段102aは、ネットワークとの通信により送信するデータを送信バッファ106bからソケットに書き込んで、OS実行手段100にイベントの処理を要求する(S13)。もし、フラグ管理手段107の管理しているフラグがすでに立っている場合は(S11;No)、処理を直ちに終了する。なお、ここでは理解の容易性のため、フラグの検査S10/S11とフラグの変更S12を3個の別ブロックとして説明したが、マルチスレッド環境では、フラグの検査S10とフラグのセットS12の間に別スレッドがスイッチされて割り込むと、複数のスレッドそれぞれがフラグを立てた状態にして(S12)、自分のスレッドがフラグを立てたつもりになってイベント処理(S13)を実行するので、同時時期に、イベント処理(S13)を複数回実行してしまう可能性があり不都合である。この問題を解決するために、本発明では、ブロッキングによってソケット書込手段102a実行を排他制御するかわりに、後述するようなフラグ管理手段107が提供するCAS(Compare and swap)の機能を利用して、フラグの検査(S10/S11)と変更設定(S12)を単一のCPU命令で実行し、S10・S11・S12の処理の間に他のスレッドが実行されない工夫を行っている。
As shown in FIG. 6, the socket
また、図8に示すように、ソケット書込要求手段102aは、ステップS13において送信バッファ106bに送信対象のデータがあるか確認し(S30)、送信対象のデータがある場合(S30;Yes)、OS実行手段100にOS非同期送信要求を行ってイベントの処理を要求する(S31)。また、ソケット書込要求手段102aは、送信対象のデータがない場合(S30;No)、フラグ管理手段107に依頼して、フラグを解除する(S32)。
Further, as shown in FIG. 8, the socket
図7に示すように、コールバック処理手段102bは、OS実行手段100がソケット書込要求手段102aにより依頼された書込イベントの処理(図8のS31)を完了した場合に、OS実行手段100から完了通知を受け付けて(非同期に)実行する。OS実行手段100が実行したネットワーク送信結果を受け取る(S20)。送信結果が正常の場合は(S21;Yes)、コールバック処理手段102bは、送信完了分を送信バッファから除外する(S22)。引き続き、コールバック処理手段102bは、フラグ管理手段107に依頼して、フラグを解除する(S23)。引き続き、コールバック処理手段102bは、送信バッファに送信対象データが存在することを確認する(S24)。確認結果が肯定的であれば(送信バッファにデータがあれば)(S24;Yes)、コールバック処理手段102bは、ソケット書込要求手段102aに呼び出しを行う(S25)。確認結果が否定的であれば(S24;No)、コールバック処理手段102bは、処理を終了する。送信結果が異常の場合は(S21;No)、コールバック処理手段102bは、通信断、タイムアウトなどの例外処理(接続の切断など)を行う(S26)。 As shown in FIG. 7, the callback processing means 102b, when the OS execution means 100 completes the processing of the write event requested by the socket write request means 102a (S31 in FIG. 8), the OS execution means 100 Receive a completion notification from (asynchronously) and execute. The network transmission result executed by the OS executing means 100 is received (S20). If the transmission result is normal (S21; Yes), the callback processing means 102b removes the completed transmission from the transmission buffer (S22). Subsequently, the callback processing means 102b requests the flag management means 107 to clear the flag (S23). Subsequently, the callback processing means 102b confirms that there is data to be transmitted in the transmission buffer (S24). If the confirmation result is affirmative (if there is data in the transmission buffer) (S24; Yes), the callback processing means 102b calls the socket write request means 102a (S25). If the confirmation result is negative (S24; No), the callback processing means 102b terminates the process. If the transmission result is abnormal (S21; No), the callback processing means 102b performs exceptional processing (disconnection, etc.) such as disconnection of communication or timeout (S26).
ソケット書込要求手段102a及びコールバック処理手段102bの他の実装としては、以下のように構成してもよい。例えば、コールバック処理手段102bは、OS実行手段100がソケット書込要求手段102aの書込イベントの処理を完了した場合に完了通知を受け付けて(非同期に)実行された送信結果を受け取る。送信結果が異常の場合は、通信断、タイムアウトなどの例外処理(接続の切断など)を行い、終了する。送信結果が正常の場合は、送信完了分を送信バッファから削除する。引き続き、コールバック処理手段102bは、送信バッファに送信対象データが存在することを確認し、確認結果が肯定的であれば、ソケット書込要求手段102aに呼び出しを行う。確認結果が否定的であれば、フラグ管理手段107に依頼して、フラグを解除して処理を終了する。
Another implementation of the socket write request means 102a and the callback processing means 102b may be configured as follows. For example, the
バッファリング手段106は、メモリ12に2種類のバッファ領域、受信バッファ106aと送信バッファ106bを用意し、どちらも読み出し及び書き出しの対象を提供するとともに、読み出し及び書き出しをするデータを管理する。バッファを介することでバッファに対する読み出しと書き出しとを非同期に行うことができる。受信バッファ106aは、ソケット読出手段101が書き込み、アプリケーション読出手段104が読み出す。送信バッファ106bは、アプリケーション書込手段105が書き込み、ソケット書込手段102が読み出す。なお、バッファリング手段106(106a及び106b)は、データをノンブロッキングに読み書きする。バッファに必要なメモリを都度実行時に割り当てるのはCPUの効率が悪いので、事前に大きなメモリ領域(1個以上のブロック)を確保して、それを細分化したメモリチャンクをバッファプールに追加してバッファプールを用いた独自のメモリ管理をし、確保済のメモリブロックを再利用して使い回し、実行時の処理効率を向上させるのは一般的である。また、これらのメモリチャンクを組合せて、論理的にリングバッファを構成することも一般的である。ここでは、バッファ領域はバッファプールの一種であるリングバッファ121(受信バッファ106aとして受信リングバッファ121a、及び、送信バッファ106bとして送信リングバッファ121b)を用いた場合について説明するが、必ずしもリングバッファである必要はなく、論理的に無限長のバッファを提供できるバッファであればよく、好ましくはOSカーネルでの処理に好適なダイレクトバッファ等のヒープ領域外のメモリ領域に作成される高速に入出力が可能な一時記憶領域を用いる。
The buffering means 106 prepares two types of buffer areas in the
ダイレクトバッファは、実メモリ空間に存在するため、OSの処理実行においては、ダイレクトバッファ上のデータ処理は、仮想メモリ空間に存在する通常の非ダイレクトバッファ上のデータ処理に比べて、内部的なメモリ操作回数を削減し、処理時間を短くできることが知られている。なお、ダイレクトバッファは、非ダイレクトバッファに比べて、アプリケーションにとっては、メモリの割当・解放にOSの処理時間がかかることが知られている。特にダイレクトバッファの場合は、アプリケーションがメモリの割当・解放を高頻度に実行するのは適切ではなく、後述のバッファプールなどを活用して、事前に確保したメモリを使い回すことが望ましい。また、ダイレクトバッファはOSの処理対象としては好適であるが、一方で、アプリケーションの処理対象において、ダイレクトバッファのメモリアクセス(メモリ読取及びメモリ書込)は非ダイレクトバッファのメモリアクセスに比べて時間がかかるため、通常の処理のためにダイレクトバッファを利用することは不適切であることも知られている。ダイレクトバッファは濫用せずに、OSに処理要求をするデータの格納に特化した使用に限定するのが好適である。また、ダイレクトバッファは、当該アプリケーションだけでなく、当該情報装置で実行する他のアプリケーションも利用する共用のリソースであり、濫用すると当該情報装置の他のアプリケーションの稼働に影響を与える可能性もあり、適切に使用量を節約することが望ましい。以上に第1の実施形態を念頭に好適な利用方法を例として示したが、本発明の利用方法を限定するものではない。 Since the direct buffer exists in the real memory space, data processing on the direct buffer in the execution of the OS process requires less internal memory than data processing on the normal non-direct buffer that exists in the virtual memory space. It is known that the number of operations can be reduced and the processing time can be shortened. It is known that the direct buffer requires more OS processing time to allocate and release memory than the non-direct buffer. Particularly in the case of direct buffers, it is not appropriate for applications to frequently allocate and release memory, and it is desirable to reuse pre-allocated memory by utilizing buffer pools, which will be described later. Direct buffers are suitable for processing by the OS. Therefore, it is also known that the use of direct buffers for normal processing is inappropriate. It is preferable not to overuse the direct buffer, but to limit its use to specialized storage of data for which processing requests are made to the OS. In addition, the direct buffer is a shared resource that is used not only by the application concerned, but also by other applications running on the information device. Appropriate usage savings are desirable. Although the preferred method of use has been shown above as an example with the first embodiment in mind, the method of use of the present invention is not limited.
次に、バッファプールとは、アプリケーションの実行時に素早く動的に必要なメモリ領域を確保するために、アプリケーションの起動時などにメインメモリの空き領域からある程度大きな領域を一括して、複数のメモリブロックとして確保したものとする。バッファプールは、メモリ管理をOSに依頼せず、アプリケーションとして実装し、メモリが必要になったときに、確保されているメモリブロックから適切なサイズのメモリ(メモリチャンク)を借り出し(メモリ割当)、使い終わって不要になったメモリはバッファプールに返却して再利用する(メモリ解放)。バッファプールは様々実装が知られている。通常、メモリブロックはページサイズなど大きなサイズなので、ここでは、アプリケーションで使いやすい1種類あるいは2種類以上の規格化されたサイズのメモリチャンクにあらかじめ分割して、バッファプールに登録する。チャンクサイズは、通常、ページサイズの2の累乗数分の1となるように調整する。2の累乗数分の1とすることで、メモリブロックを無駄なく分割できる。また、規格化されたチャンクサイズのメモリブロックを再利用することで、メモリフラグメンテーションの発生を回避できる。また、メモリをアプリケーションでバッファプールとして管理することは、必要な都度OSにメモリの割当、解放を利用する場合に比べて、個々のメモリ割当・解放に、OS呼出のオーバヘッドなどが発生しないので、メモリ割当・解放の処理が効率化されることが知られている。バッファプールを採用する場合、プールに登録するメモリチャンクのサイズ、種類、数は用途に応じてさまざまな設計方針が考えられる。以上に第1の実施形態を念頭に好適な利用方法を例として示したが、本発明の利用方法を限定するものではない。 Next, a buffer pool is a system that collects a certain amount of free space from the main memory and stores it in multiple memory blocks when an application starts, etc., in order to quickly and dynamically allocate the necessary memory space during application execution. shall be secured as The buffer pool is implemented as an application without relying on the OS for memory management. The memory that is no longer needed after being used is returned to the buffer pool and reused (memory release). Various implementations of the buffer pool are known. Since a memory block is usually a large size such as a page size, here, it is divided in advance into one or more standardized size memory chunks that are easy to use for applications, and registered in the buffer pool. The chunk size is usually adjusted to be one power of two of the page size. A memory block can be divided without waste by setting it to 1/2 by a power of 2. In addition, memory fragmentation can be avoided by reusing memory blocks of standardized chunk size. In addition, managing memory as a buffer pool by an application does not generate overhead such as calling the OS for individual memory allocation and release, compared to the case of using memory allocation and release to the OS each time it is necessary. It is known that memory allocation/release processing is made more efficient. When adopting a buffer pool, various design policies can be considered for the size, type, and number of memory chunks registered in the pool, depending on the application. Although the preferred method of use has been shown above as an example with the first embodiment in mind, the method of use of the present invention is not limited.
さて、第1の実施の形態では、バッファプールを用いる場合、メモリチャンクのサイズとして、OSの処理に適したサイズに規格化されたチャンクサイズ(例えば、ページサイズとしてメモリブロックそのまま、あるいは、その半分など)を利用し、メモリの種類としては、OSの処理に適したダイレクトバッファのメモリを利用する。OSの処理に適した大きなサイズ(例えば、ページサイズ)のメモリチャンクに、イベントデータをぎっしりと詰め込むことにより、非常に小さいサイズのイベントデータをそれぞれ別のチャンクに保持する場合に比べて、OSが提供する非同期送信機能としてAsynchronousSocketChannel.write() の集約書込(gathering write)に指定するメモリチャンクの数を効果的に削減し、また、OSでの処理効率はよくなる。OSは同じバイト数のデータを処理する場合、格納するチャンクの数が少ないほうが、内部的処理が速くなることが知られている。例えば、チャンクサイズは、ページサイズあるいはその半分など、より具体的には1KBや2KBなどの単一のサイズを採用する。また、OSの処理のために確保するメモリブロックの種類としては、ヒープに確保される通常のメモリ(非ダイレクトバッファ)ではなく、OSの処理に適したダイレクトバッファを使うとさらにOSでの処理効率がよい。ダイレクトバッファの採用は、バッファプールと組み合わせても、バッファプールを使わずにその都度メモリ割当・解放を行う場合でも使える技術であるが、バッファプールと組み合わせて使うことで、OSでの処理により適した技術となる。以上に第1の実施形態を念頭に好適な利用方法を例として示したが、本発明の利用方法を限定するものではない。 In the first embodiment, when a buffer pool is used, a chunk size standardized to a size suitable for OS processing is used as the size of the memory chunk (for example, the page size is the memory block as it is or half of it). etc.), and as the type of memory, a direct buffer memory suitable for OS processing is used. By cramming the event data into a large size (e.g., page size) memory chunk that is suitable for OS processing, the OS is able to handle the event data rather than holding each very small size event data in a separate chunk. As an asynchronous transmission function to be provided, AsynchronousSocketChannel. It effectively reduces the number of memory chunks specified for gathering writes of write( ) and improves the processing efficiency in the OS. It is known that when the OS processes the same number of bytes of data, the smaller the number of chunks stored, the faster the internal processing. For example, the chunk size adopts a single size such as the page size or half thereof, more specifically 1 KB or 2 KB. As for the type of memory block to be secured for OS processing, using a direct buffer suitable for OS processing instead of a normal memory (non-direct buffer) secured in the heap will further improve the processing efficiency of the OS. is good. Adopting a direct buffer is a technology that can be used both in combination with a buffer pool and in cases where memory is allocated and released each time without using the buffer pool. technology. Although the preferred method of use has been shown above as an example with the first embodiment in mind, the method of use of the present invention is not limited.
フラグ管理手段107は、例えば、CAS(Compare and Swap)等の手段により、フラグをアトミックに管理する。ここでアトミックとは、不可分操作を指し、具体的には、あるメモリ位置の内容と指定された値を比較し、等しければそのメモリ位置に別の指定された値を格納することを1命令で行うCPUの特別な命令を指す。フラグ管理手段107は、ソケット書込要求手段102aの要求によりOS実行手段100がイベント処理を開始するタイミングで排他的にフラグを立て(図6、S12)、イベントの処理の完了のタイミング(コールバック処理手段102bの処理)でフラグを解除する(図7のS23)。ちなみに、図8のS32でもフラグを解除しているがイベント処理を開始するタイミングでフラグをたてたが、イベント処理するデータが全くなかった場合の(例外)処理である。前述のように、図6に示す動作をするので、フラグ管理手段107の機能により、ソケット書込要求手段102a及びコールバック処理手段102bは、ひとつのソケットについては、両手段あわせて高々1個しか同時には実行しないように制御され、ソケットへの書込操作の整合性が保証される。フラグを立てたソケット書込要求手段102a、又は、当該ソケット書込要求手段102aに対応するコールバック処理手段102bが処理中の場合は、2個目以降のソケット書込要求手段102aの呼び出しは、フラグが立っている間は、フラグを自らが立てることができないので、処理を中断し、OS実行手段100への書き込みを行わずに終了(図6のS11;No)する。このため、ソケット書込要求手段102aは必ずしも自らのイベントについてOSに非同期送信呼び出しを実行できるとは限らないが、ノンブロッキングに実行し、イベントが送信できるようになるまで待たずに処理を終了する。ソケット書込要求手段102a自身が非同期送信呼び出しを実行できなかった場合でも、近い将来、実行中のソケット書込手段102(ソケット書込要求手段102aあるいはコールバック処理手段102b)が非同期送信呼び出しを結果的に実行する。すなわち、非同期送信呼び出しが実行されずにソケット書込要求手段102aが処理終了してしまっていたイベントについては、当該イベントが第1のバッファ121b1に蓄積されたタイミングに依存して、すでにフラグを立てて排他的に実行中であるソケット書込要求手段102a自身、あるいは当該ソケット書込要求手段102aに対応するコールバック処理手段102bが、後に送信バッファが空でない場合に呼び出すソケット書込要求手段102aにより、非同期送信呼び出しがなされる。なお、前述のように、点線で囲まれたフラグの操作(状態確認や設定のステップS10,S11,S12)はマルチスレッド環境下で他スレッドによる割り込みによる影響がないようにアトミックに実行される必要があり、フラグ管理手段107が提供する(Compare and Swap)の機能を利用する。
The flag management means 107 manages flags atomically by means of, for example, CAS (Compare and Swap). Here, atomic refers to an indivisible operation. Specifically, one instruction compares the contents of a certain memory location with a specified value, and if they are equal, stores another specified value in that memory location. Refers to a special CPU instruction to perform. The
記憶部11は、制御部10を上述した各手段100-107として動作させるOS110、通信管理プログラム111、アプリケーション112等を記憶する。なお、各手段100~107として機能させるための対象は、OS110、通信管理プログラム111、アプリケーション112を適宜入れ替えて行うものであってもよい。また、記憶部は、リレーショナル・データベースやファイルシステムなどを用いる。なお、高速化のために、Redisなどインメモリデータベースを利用、あるいは、併用してもよい。
The
メモリ12は、バッファリング手段106及びその他図示しない手段により制御され、情報を一時的に記憶する。
The
なお、端末装置2a、2b、2cは、サーバ装置1と同様の構成に加え、操作部及び表示部を備える。サーバ装置1と構成が共通する部分については説明を省略する。
The
(情報処理装置の動作)
次に、第1の実施形態の作用を、(1)基本動作、(2)データ送信動作に分けて説明する。
(Operation of information processing device)
Next, the operation of the first embodiment will be described separately for (1) basic operation and (2) data transmission operation.
(1)基本動作
一例として、複数のユーザが、複数のゲームオブジェクトを同期させて同一の仮想空間(ルーム)での体験(ゲームプレイ)を共有するために、同じ仮想空間に参加する。ゲームの進行は各端末装置2a、2b、2cで行い、サーバ装置1は、ゲームの進行は行わず、オブジェクトの同期動作のみを行ってもよいし、サーバ装置1がゲームの進行も行ってもよい。
(1) Basic Operation As an example, multiple users participate in the same virtual space in order to synchronize multiple game objects and share the experience (game play) in the same virtual space (room). The game progresses in each of the
サーバ装置1の図示しない参加者管理手段は、ルームへの参加要求を受信すると、参加者に対してユーザID、ユーザ名、ソケットID、参加日時とともに記憶部11の当該ルームIDに関連付けられた参加者管理情報に記録する。
Upon receiving a room participation request, the participant management means (not shown) of the
端末装置2a、2b、2cは、ゲームのプレイ中は、アプリケーションの実行に伴い複数のオブジェクト(キャラクター、武器、アイテム等)を逐次生成、更新、削除して処理する。サーバ装置1は、ゲームの進行を行う場合、端末装置2a、2b、2cによるオブジェクトの操作要求を受け付けて、処理し、その処理結果を端末装置2a、2b、2cに通知することで、オブジェクトを同期させる。サーバ装置1は、ゲームの進行を行わない場合、端末装置2a、2b、2cにおけるオブジェクトの同期のためのリレー動作を行う。当該リレー動作において、サーバ装置1は、複数のオブジェクトの送受信を行う。いずれの場合でも、サーバ装置は、端末装置2a、2b、2cより、それぞれが操作する複数のオブジェクトの操作に関する情報を受信し、同期対象の端末装置に対応する複数のオブジェクト操作に関する情報を送信する。個々のオブジェクト操作情報のサイズは小さいが、各端末装置2a、2b、2cにおいて、なめらかなオブジェクトの描画を実現するには他頻度なデータ同期(少なくても秒20回から30回程度)が必要となり、洗練されたゲームで同期対象のオブジェクトの数が多い場合、MMOGなど同期対象の端末装置が多い場合、サーバが処理する同期のための送受信パケット数は組み合わせ爆発でストリーミング送受信のように莫大となりうる。近年CPUやメモリの高速化は著しいが、ネットワークの帯域幅、個々の端末とのスループットやレイテンシは、物理的・距離的制約や、モバイルからの利用形態などのトレンドもあり、高速化はよりゆるやかである。そのため、ネットワーク送受信はサーバでの処理において、ボトルネックとなりやすい。本発明では、ネットワーク送信の効率的な利用、NICレベルで常に処理中で空き時間のなるべくないような利用方法、特に、Javaを用いた実装で送信時のソケットの利用率の向上を実現する。以下、サーバ装置1の送受信の動作詳細について説明する。
During game play, the
図3は、データ送受信の動作の一例を説明するための概略図である。 FIG. 3 is a schematic diagram for explaining an example of data transmission/reception operations.
まず、ネットワーク4からサーバ装置1がデータを受信する場合、ネットワーク4のソース131からあるチャネル130を介し、ソケット読出手段101がチャネルに対応するソケット(受信元端末装置に対応するあるIPアドレスのあるポート)によって受信したデータを読み出して受信リングバッファ121aの書込ポインタの位置に書き込む。データは受信リングバッファ121aに追加される。なお、バッファはチャネルあるいはソケットごとに別々に用意する。また、チャネル/ソケットは送受信共用で、対応する端末装置(端末装置の通信相手となる特定のプログラム)ごとに1つ用意する。アプリバッファは、1つで図示しているが、実際は送受信別に管理する。また、リングバッファは、プールとしては、全チャネルで1つとして管理されており、1つで図示しているが、リングバッファ121は、チャネルごと、送受信別々に、それぞれ独立なポインタの管理があり、チャネルごとに、別々の受信リングバッファ121a、送信リングバッファ121bとして区別する。
First, when the
次に、アプリケーション読出手段104は、受信元端末装置に対応(チャネルあるいはソケット)した受信リングバッファ121aのデータを読出ポインタの位置から読み出してアプリバッファ120に書き込む。データは受信リングバッファ121aから取り出され、受信リングバッファ121aから除外される。ここでアプリバッファ120はアプリケーションが独自に管理するもので、バッファリング手段106が提供するものではない。アプリバッファは、別のバッファリング手段が提供する。たとえば、OS機能(通常のメモリ割当、メモリ解放)がアプリバッファを提供してもよい。メモリを再利用してメモリ管理を効率化するためには、バッファリング手段106同等の機能が提供するように別のバッファリング手段を構成して、アプリバッファを提供してもよい。
Next, the application reading means 104 reads the data of the reception ring buffer 121 a corresponding to the receiving terminal device (channel or socket) from the position of the read pointer and writes it to the
アプリケーション実行手段103は、アプリバッファ120のデータを読み出してスレッドにて処理する。
The
また、アプリケーション実行手段103のスレッドで処理されたデータをネットワーク4に送信する場合、アプリケーション実行手段103は、スレッドで処理されたデータをアプリバッファ120に書き込む。
Also, when transmitting data processed by the thread of the
次に、アプリケーション書込手段105は、アプリバッファ120のデータを意図する送信先端末装置に応じて、送信先端末装置、より厳密には、チャネルあるいはソケットに対応する送信リングバッファ121bの書込ポインタの位置に書き込む。この結果、データは送信リングバッファ121bに追加される。データを書き込み終わると、書込ポインタを進めて、書込終了位置の次に移動する。次回、アプリケーション書込手段105がデータを書き込む時は、移動後の書込ポインタを使用するので、次回書き込むデータは、今回書き込んだデータの後ろに追加される。一方で、アプリバッファ120のデータは、送信リングバッファ121にコピーされた後は不要なり、アプリケーション実行手段103はこのバッファ領域を再利用できる。なお、送信リングバッファ121bはチャネルあるいはソケットごとに用意する。
Next, the application writing means 105 writes the write pointer of the
次に、ソケット書込手段102は、送信リングバッファ121bの読出ポインタの位置から書き出しポインタの位置の手前までのデータを読み出し、ソケットによってチャネル130に書き込む。データは、チャネル130を介してソース131に送信される。読出ポインタは、送信に成功したバイト数だけ進めて、送信が完了したデータの次の位置に移動する。この時、データは送信リングバッファ121bから取り出され、送信対象としてOS実行手段100が送信処理をし、送信が完了したデータ(取り出したデータの全部あるいは一部)については、送信リングバッファ121bから除外される。送信が完了しなかったデータについては、引き続き送信リングバッファ121bにとどまる。ここでは、送信リングバッファ121bに蓄積されたデータを全部一度に送信するものとしたが、送信リングバッファ121bに蓄積されているデータが巨大になった場合は、OS送信機能呼出の制限を考慮するなど、全部一度に読み出さず、一部だけを読み出して送信する制御をしてもよい。
Next, the socket writing means 102 reads the data from the position of the read pointer of the
なお、上記したようにリングバッファ121は、メモリ領域(あるいは、仮想的に連続なメモリ領域)にデータ(イベント)を順次書込み(蓄積)し、読み出しするデータを直接格納するリングバッファであり、格納するデータを順番にメモリ領域に配置・格納(管理するデータを直接的に格納)するものである。このリングバッファ121は、格納したメモリへのポインタをメモリ領域(あるいは、仮想的に連続なメモリ領域)に書込又は読出ポインタとして順番に格納(管理するデータを間接的に格納)するものではない。また、このリングバッファ121は、書込みによりデータ(イベント)の書込単位の境界はなくなるため、データ(イベント)単位で処理する必要がある場合は、境界情報を別途管理しなければならない。第1の実施の形態では、データ処理(イベント処理)は、OSカーネルによるネットワーク送信であるので、データ(イベント)の境界にかかわらずバイトストリームとして送信するので、データ(イベント)の境界は管理しなくてよい。また、第1の実施の形態と同様の効果が得られるようなケースの場合は、他の仮想的なリングバッファの使用を妨げるものではない。
As described above, the
以下、アプリケーション実行手段103のスレッドで処理されたデータをOS実行手段100からネットワーク4に送信する場合について詳細に説明する。
A case in which data processed by the thread of the application execution means 103 is transmitted from the OS execution means 100 to the
(2)データ送信動作
図4は、データ送信動作の一例を説明するための概略図である。
(2) Data Transmission Operation FIG. 4 is a schematic diagram for explaining an example of data transmission operation.
アプリケーション実行手段103は、例えば、複数のスレッド1、スレッド2によりデータを処理し、処理結果のデータA、データBを同一の端末装置(より厳密には、同一のソケットあるいはチャネル)に送信するために、アプリケーション書込手段105により送信先端末へ通信するソケットに対応する送信リングバッファ121bに書き込まれる。複数のチャネルへ送信するためには、それぞれのチャネルごとに本発明の各手段が必要となる。スレッド1、スレッド2の処理はマルチスレッドの環境下で非同期に発生するものとする。アプリケーション書込手段105は、データA、データBをチャネル毎に最大1つのデータ書込だけ実行するようブロッキング制御し、アプリケーション書込手段105がスレッド1のデータAを送信リングバッファ121bに書き込んでいる間、スレッド2のデータBの書込処理を待機させる。同様にアプリケーション書込手段105がスレッド2のデータBを送信リングバッファ121bに書き込んでいる間、スレッド1はデータCの書込処理を待機させる。送信リングバッファ121bへの書込は、書込ポインタの位置から開始し、書込終了時には書込ポインタを書込終了位置の次に移動させる。ここでは説明の簡単のために、スレッド間の書込操作が送信リングバッファ121bで混ざらないようにブロッキング制御を行う、送信バッファ106bとして、ノンブロッキングなバッファを採用すれば、さらにアプリケーション書込手段105は効率的に機能する。つまり、送信リングバッファ121bの書込ポインタと読込ポインタは、それぞれがある一時期には高々1個だけがアクティブであるような書込用のスレッド(アプリケーション書込手段105)及び読込用のスレッド(ソケット書込手段102)が排他的に操作するため、ノンブロッキング、かつ非同期に、書込(アプリケーション書込手段105)と読出(ソケット書込手段102)を実行できる。
The application execution means 103, for example, processes data by a plurality of
次に、ソケット書込要求手段102aは、フラグ管理手段107のCASフラグを参照し、フラグが立っていない場合、フラグを立てて、OSシステムコール(例えばJAVAのAsynchronousSocketChannel.write())呼び出しを行い、送信リングバッファ121bに蓄積されているデータ(読出しポインタから呼出時点での書込ポインタの一つ前までのデータ)を送信する。この時点では送信リングバッファ121bにはデータAのみ蓄積されている。ソケット書込要求手段102aは、送信リングバッファ121のデータAをOS実行手段100(OSカーネル)に書き込み要求をして終了する(1)。
Next, the socket write request means 102a refers to the CAS flag of the flag management means 107. If the flag is not set, the socket write request means 102a sets the flag and calls the OS system call (for example, AsynchronousSocketChannel.write() of JAVA). , the data accumulated in the
次に、OSカーネル100は、データAを適切なサイズ(サイズは、例えば、ネットワーク依存の送信可能な最大パケットサイズMTU(Maximum Transmission Unit、イーサネットならMTUは1500バイト)と各種プロトコルヘッダに応じて決定する。典型的には、イーサネットでTCP/IPであれば、TCPヘッダ20バイトとIPヘッダ20バイトを差し引いたMSS(Maximum Segment Size)1460バイト)に分割してデータA1、A2としてネットワーク4に送信する。OSカーネル100のイベント処理中に、アプリケーション書込手段105から送信リングバッファ121bにデータBを書き込むと送信リングバッファ121bは、OSカーネル100が読取処理をしている最中ではあっても、データBをノンブロッキングに蓄積する。アプリケーション書込手段105は、引き続きソケット書込要求手段102aを呼び出すが、ソケット書込要求手段102aはデータAの処理中でフラグ管理手段107のCASフラグが立っているのでソケット書込要求手段102aはデータBの送信処理をせずに、ノンブロッキングに直ちに終了する(2)。スレッド2は、比較的長時間のネットワーク送信処理(OSカーネル100のイベント処理)の完了を待たずに次の処理を実行できる。この時点で、送信リングバッファ121bには、データBが追加され、データAとデータBが存在する。
Next, the
次に、OSカーネル100は、データAの送信を完了するとコールバック処理手段102bを起動して、送信完了を通知する。コールバック処理手段102bは、送信完了したバイト数を確認し、この場合はデータA全体が送信完了しているので、送信リングバッファ121bの読出ポインタをデータAの直後へ移動し、データAを送信リングバッファ121bから除外する。次に、コールバック処理手段102bは、フラグ管理手段107のCASフラグを解除する。この時点で、送信リングバッファ121bは、データAが除外され、データBのみが存在する。次に、コールバック処理手段102bは、送信リングバッファ121bにまだ送信すべきデータがあるか(読出ポインタと書込ポインタが一致していれば送信すべきデータはない)を判定する。送信すべきデータがある場合は、ソケット書込要求手段102aを呼び出す。送信すべきデータがない場合は終了する。この場合はすでに、データBが送信リングバッファ121bに存在しているので、ソケット書込要求手段102aを呼び出す(3)。
Next, when the transmission of data A is completed, the
次に、ソケット書込要求手段102aは、フラグ管理手段107に依頼して、CASフラグを参照し、フラグが立っていないので、フラグを立てて、OSシステムコール(AsynchronousSocketChannel.write())呼び出しを行い、送信リングバッファ121bに蓄積されているデータ(読出しポインタから呼出時点での書込ポインタの一つ前までのデータ)を送信する。この時点では送信リングバッファ121bにデータBのみ蓄積されている。ソケット書込要求手段102aは、送信リングバッファ121bのデータBをOSカーネル100に書き込み要求をして終了する。
Next, the socket write request means 102a requests the flag management means 107 to refer to the CAS flag. Since the flag is not set, the flag is set and an OS system call (AsynchronousSocketChannel.write()) is called. and transmits the data accumulated in the
次に、OSカーネル100は、データBを適切なサイズに分割してデータB1、B2、B3としてネットワーク4に送信する。OSカーネル100のイベント処理中に、アプリケーション書込手段105から送信リングバッファ121bにデータCを書き込むと送信リングバッファ121bはデータCをノンブロッキングに蓄積し、ソケット書込要求手段102aを呼び出すが、ソケット書込手段102は、直前のソケット書込要求手段102aがOSに依頼したデータBの処理中で、フラグ管理手段107のCASフラグが立っているのでソケット書込要求手段102aはデータCの送信処理をOSカーネル100に依頼せずに直ちに終了する(4)。また、同様にして、アプリケーション書込手段105からリングバッファ121にデータDを書き込むとリングバッファ121はデータDをノンブロッキングに蓄積し、ソケット書込要求手段102aを呼び出すが、ソケット書込手段102はデータBの処理中でフラグ管理手段107のCASフラグが立っているのでソケット書込要求手段102aはデータDの送信処理をせずに直ちに終了する(5)。この時点では送信リングバッファ121bにデータB、データC、データDが順番に蓄積されている。
Next, the
次に、OSカーネル100は、データBの送信を完了するとコールバック処理手段102bを起動して、送信完了を通知する。コールバック処理手段102bは、まず、送信完了バイト数がデータB全体であることを確認した上で、送信リングバッファ121bの読出ポインタをデータBの次の位置(この場合はデータCの先頭)に移動する。この時点では送信リングバッファ121bは、データBが除外されて、データCとデータDを蓄積している。コールバック処理手段102bは、次に、フラグ管理手段107のCASフラグを解除して、その次に、送信リングバッファ121bは空でない(この場合はデータC及びデータDが蓄積されている)ことを確認して、ソケット書込要求手段102aを呼び出す。
Next, when the transmission of data B is completed, the
次に、ソケット書込要求手段102aは、フラグ管理手段107のCASフラグを参照し、フラグが立っていないので、フラグを立てて、OSシステムコール(AsynchronousSocketChannel.write())呼び出しを行い、送信リングバッファ121bのデータCとデータDをOSカーネル100に書き込む(6)。
Next, the socket write request means 102a refers to the CAS flag of the flag management means 107. Since the flag is not set, the socket write request means 102a sets the flag, calls the OS system call (AsynchronousSocketChannel.write()), and The data C and data D in the
次に、OSカーネル100は、データC及びデータDを適切なサイズに分割してデータC1、C2、C3、…としてネットワーク4に送信する。OSカーネル100のイベント処理中に、アプリケーション書込手段105から送信リングバッファ121bにデータEを書き込むと、送信リングバッファ121bはデータEをノンブロッキングに蓄積するが、ソケット書込要求手段102aの呼出はフラグ管理手段107のCASフラグが立っているのでソケット書込要求手段102aはデータEの送信処理をせずに終了する(7)。また、同様にしてアプリケーション書込手段105から送信リングバッファ121bにデータFを書き込むと、送信リングバッファ121bはデータFをノンブロッキングに蓄積する(8)。この時点で送信リングバッファ121bはデータC、データD、データE、データFを蓄積している。
Next, the
次に、OSカーネル100は、データCの送信を完了すると、今回はたまたまDの処理を実行せずに、コールバック処理手段102bを起動して、送信完了を通知する。一般にOSシステムコール(AsynchronousSocketChannel.write())は必ずしも要求したデータすべての送信を完了することを保証しない。OSやネットワークの負荷などの理由で要求したデータの一部のみ送信されることがある。したがって、送信完了したバイト数の確認は必須である。また、このシステムコールは、複数のバッファ(メモリチャンク)を指定することで、それらをまとめて1回のシステムコールで送る集約送信(集約書込、gathering write)の機能を提供する。したがって、CとDとは連続した単一のメモリチャンクではなく、2個以上のメモリチャンクであっても1回のシステムコールで送信要求が可能である。この例では、偶然データCの全体の送信終了を通知したが、OSカーネル100にとってはデータCとデータDは集約された連続した送信対象のデータで、別のデータであるかどうかの区別はしていないので、データCを送りきったのは全くの偶然で、データCの送信中、データCの一部を残して送信を終了する場合もある。集約送信では複数のメモリチャンクを指定できるので、CやDはそれぞれが複数のメモリチャンクに分割されて指定されてもよいし、CとDをまとめた一つのメモリチャンクで指定してもよいし、あるいは、部分的にCとDが交じるような複数個のメモリチャンク(例えば、Cの前半、Cの後半とDの前半、Dの後半などの3個)に分割されて指定されてもよい。一方でOSの集約送信は、指定されたチャンクを順に送信しようとするが、OSの都合により、指定されたチャンクすべて送信することもあれば、指定されたチャンクの一部のチャンクのみを送信することもある。ここで一部のチャンクとは、複数チャンクの一部のチャンクの全体であることもあれば、最後のチャンクはチャンクの最初の部分だけで送り残しのある場合があることもある。送信指定したチャンクの含むすべてのバイト数すべてが送信に成功するわけではなく、コールバックルーチンで送信成功したバイト数を確認し、送り残したチャンクあるいはチャンクの一部は、次回の集約送信の対象とする必要がある。(例えば、C1とC2を送信完了して、C3を残す場合とか、C1とC2に加えてC3の前半まで送信完了して、C3の後半を残す場合とかも考えられる。コールバック処理手段102bは、まず、送信完了したバイト数を確認し、この場合は、データCのみが全部送信完了であるので、送信リングバッファ121bの読出ポインタをデータCの次の位置(この場合はデータDの先頭位置)に移動する。この時点で、送信リングバッファ121bは、データCが除外されるが、データC送信処理中にデータEとデータFが追加されているので、送信リングバッファ121bは、データD、データE、データFを蓄積している。コールバック処理手段102bは、次に、フラグ管理手段107のCASフラグを解除する。コールバック処理手段102bは、この場合は、送信リングバッファ121bに送信対象のデータ(この場合は、データD、データE、データF)が存在するので、ソケット書込要求手段102aを呼び出す。
Next, when the transmission of data C is completed, the
次に、ソケット書込要求手段102aは、フラグ管理手段107のCASフラグを参照し、フラグが立っていないので、フラグを立てて、OSシステムコール(AsynchronousSocketChannel.write())呼び出しを行い、送信リングバッファ121bのすべてのデータDEFをOSカーネル100に書き込み要求する(9)。
Next, the socket write request means 102a refers to the CAS flag of the flag management means 107. Since the flag is not set, the socket write request means 102a sets the flag, calls the OS system call (AsynchronousSocketChannel.write()), and A write request is issued to the
次に、OSカーネル100は、データDEFを適切なサイズに分割してデータD1、D2、…としてネットワーク4に送信する。
Next, the
次に、OSカーネル100は、たまたまデータDだけの送信を完了するとコールバック処理手段102bを起動して、送信完了を通知する。コールバック処理手段102bは、送信済バイト数を確認すると、偶然データDだけが送信完了となっていたので、送信リングバッファ121bの読出ポインタをデータEの先頭に移動し、フラグ管理手段107のCASフラグを解除して、送信リングバッファが空ではないので、ソケット書込要求手段102aを呼び出す。
Next, when the
次に、ソケット書込要求手段102aは、フラグ管理手段107のCASフラグを参照し、フラグが立っていないので、フラグを立てて、OSシステムコール(AsynchronousSocketChannel.write())呼び出しを行い、リングバッファ121のデータEFをOSカーネル100に書き込み要求する(10)。
Next, the socket write request means 102a refers to the CAS flag of the flag management means 107. Since the flag is not set, the socket write request means 102a sets the flag, calls the OS system call (AsynchronousSocketChannel.write()), and writes to the ring buffer. The
次に、OSカーネル100は、データEFを適切なサイズに分割してデータE、F1、F2としてネットワーク4に送信する。
Next, the
次に、OSカーネル100は、データE、Fの送信をするとコールバック処理手段102bを起動して、送信完了を通知する。コールバック処理手段102bは、送信完了バイト数を確認し、送信リングバッファ121bの読出ポインタをデータFの次に移動させ、フラグ管理手段107のCASフラグを解除する。コールバック処理手段102bは、送信リングバッファ121bが空(読出ポインタと書込ポインタが一致)になり、処理を終了する
Next, when the
以上の例では、説明しやすいように、データA-Fはそれぞれが1個以上のネットワークパケットとして送信されるような大きなデータとして図示した。ゲームサーバでオブジェクトの同期情報をストリーミングのように送受信する際には、個々のデータのサイズはネットワークの送信パケットサイズにくらべて非常に小さく、データが蓄積されれば、多数のデータがひとつのネットワーク送信パケットとして送信される。したがって、CASによるノンブロッキングなソケット書込手段は、OSのロック機能を使用する場合に比べて、著しくオーバヘッドが小さくなり、また、複数のデータをまとめて連続なブロックに配置したり、複数のデータをまとめて1回のOS送信要求で送ったりすることにより、送信チャネルを切れ目なく効率よく稼働させることができ、特にストリーミングのような利用形態では有用である。 In the above examples, for ease of explanation, the data A to F are illustrated as large pieces of data each transmitted as one or more network packets. When the game server transmits and receives object synchronization information like streaming, the size of each piece of data is very small compared to the network transmission packet size. Sent as a send packet. Therefore, the non-blocking socket writing means by CAS has a significantly smaller overhead than the case of using the OS lock function, and also puts a plurality of data together in a continuous block, or a plurality of data. By collectively sending the data with one OS transmission request, the transmission channel can be efficiently operated without interruption, which is particularly useful in a mode of use such as streaming.
(第1の実施の形態の効果)
上記した実施の形態によれば、アプリケーション書込手段105とソケット書込手段102の間に送信リングバッファ121bを設け、送信リングバッファ121bはアプリケーション書込手段105の書込データをノンブロッキングに蓄積して、ソケット書込要求手段102aの書込動作をCASフラグに応じて実行し、CASフラグをフラグ管理手段107によって管理し、ソケット書込要求手段102aの書込開始でフラグを立て、OS実行手段100のイベント処理完了の通知を受けたコールバック処理手段102bがフラグを解除するようにしたため、アプリケーション書込手段105の書き込み動作がOS実行手段100の送信イベント処理の動作に直接影響を及ぼさないようになり(アプリケーション書込手段105、OS実行手段100がそれぞれに対応するための待ち時間がなくなり、また、それぞれの呼出回数が削減され)、アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化することができる。特に、所要時間の比較的長いネットワークへの送信処理を、ウェイト時間(レイテンシ)短く、なるべく連続処理、かつ、ノンブロッキングに実行することで、ネットワーク送信処理を優先し、送信スループットを上げ、非同期送信(NIO)の処理待ちの間の時間にアプリ処理を実行することができる。
(Effect of the first embodiment)
According to the above embodiment, the
また、アプリケーションが消費するOSリソース(総メモリ量、スレッド数、OS機能呼び出し回数)を削減し、処理の高速化を実現できる。また、レンタルサーバやクラウドサービスなどで運用する場合は、よりコンパクトなサーバ仕様で動作させることができ、運用コストが削減される。 In addition, the OS resources (total amount of memory, number of threads, number of OS function calls) consumed by the application can be reduced, and high-speed processing can be realized. Also, when operating with a rental server or cloud service, it can be operated with more compact server specifications, which reduces operating costs.
(第2の実施の形態)
第2の実施の形態は、送信バッファとしての中間バッファが2種類存在する点、アプリケーション書込手段105がマルチスレッド時にノンブロッキングである点で第1の実施の形態と異なる。アプリケーション書込手段105がノンブロッキングで並行処理が可能となり、第1の実施の形態に比べて、アプリケーションの処理効率が改善される。なお、第1の実施の形態と共通の構成、動作については記載を省略する場合がある。まず、第2の実施の形態における通信管理システムの構成、及びサーバ装置の構成については、それぞれ、第1の実施の形態で示した図1及び図2と同じなので記載を省略する。図1及び図2の説明の記載で、第1の実施の形態に特化した動作や機能については、第1の実施の形態とのちがいも含めて、以下に説明する。
(Second embodiment)
The second embodiment differs from the first embodiment in that there are two types of intermediate buffers as transmission buffers and that the application writing means 105 is non-blocking during multithreading. The application writing means 105 can perform non-blocking parallel processing, and application processing efficiency is improved compared to the first embodiment. The description of the configuration and operation common to those of the first embodiment may be omitted. First, the configuration of the communication management system and the configuration of the server device in the second embodiment are the same as those shown in FIGS. 1 and 2 shown in the first embodiment, respectively, so descriptions thereof will be omitted. Operations and functions specific to the first embodiment in the descriptions of FIGS. 1 and 2 will be described below, including differences from the first embodiment.
図9及び図10に示すように、構成において、第1の実施の形態(図3及び図4)と比較して、第2の実施の形態では、リングバッファ121(図3参照。)が中間バッファ121B(図9参照。)に置き換えられる点、バッファリング手段106がメモリ12に送信バッファとして、リングバッファ121b(図4参照。)だけでなく、第1のバッファ121b1と第2のバッファ121b2を用意する点(図10参照。)で第1の実施の形態と構成が異なる。
As shown in FIGS. 9 and 10, compared with the first embodiment (FIGS. 3 and 4), the ring buffer 121 (see FIG. 3) is intermediate in the second embodiment. In that the buffering means 106 is replaced with the
図10に示すように、第1のバッファ121b1は、アプリケーション書込手段105により、スレッド103の処理の結果生成されたイベントの書き込みを受け付け、第2のバッファ121b2は、ソケット書込手段102aにより、第1のバッファ121b1にスレッド毎に書き込まれたデータの集合の書込を受け付ける。イベントを規格化されたメモリチャンクに保持する場合、第1のバッファ121b1では、一例として、標準的なイベントサイズを考慮し、イベントをチャンクに格納した場合にチャンクの使い残しがあまり発生しないように、既存の各種最適化アルゴリズムなどを用いてチャンクサイズを計算・設計するものとし、ここでは256バイトの規格化されたチャンクにイベントを保持(イベントサイズが256バイトより大きければ複数チャンクに保持)したものを複数保持するものとする。チャンクはバッファプールで管理し、バッファプールを複数のチャネルで共有すると想定して、初期値として4096個用意すると合計1MBである。バッファプールは不足した場合は、追加でメモリチャンクを割り当てて、拡張できる構成が望ましい。また、ここでバッファプールを複数チャネルで共有するとは、異なる送信先ごとに異なるチャネル、異なるソケットを使うため、本発明は単一のチャネルの動作を中心に記述するが、他チャネルでもそれぞれが同様に独立したバッファリング手段106を保持するが、それぞれのバッファリング手段にメモリチャンクを提供するバッファプールは一元的に管理すれば、各チャネルで個別にバッファプールを保持する場合に比べて、バッファプールのメモリ確保の重複を排除して、チャネル間でメモリを融通できるため、バッファプールとして確保する総メモリを節約できる。一方で、第2のバッファ121b2はOSでのイベント処理に使用される。第2のバッファ121b2は、一例として、OSの好適なデータ処理サイズであるページサイズを考慮し、ここでは2048バイトの規格化されたチャンクをに処理すべき送信データを保持するものとする。チャンクをバッファプールで管理し、バッファプールを複数のチャネルで共有すると想定して、初期値として4096個用意すると合計8MBである。第1のバッファ121b1のバッファプールと同様に、バッファプールは不足した場合は、追加でメモリチャンクを割り当てて、拡張できる構成が望ましい。なお、第1のバッファ121b1と第2のバッファ121b2のそれぞれのチャンク容量及びチャンク数は通信環境やシステムの仕様に合わせて適宜設定するため、例として示した値に限定されるものではない。ただし、バッファプールのメモリチャンクは、あらかじめまとめて取得した大きなメモリを分割して使用するので、メモリチャンクのサイズは、メモリ境界を考慮して、サーバ装置1のページサイズ、又は、ページサイズの2の累乗数分の1から選ぶことがメモリシステムの効率上望ましく、50バイトや100バイトのような任意のバイト数を選択すべきではない。また、第2のバッファは、OSでの処理に適したダイレクトバッファを使用するとOSでの送信処理効率がよくなる。
As shown in FIG. 10, the first buffer 121b_1 accepts writing of an event generated as a result of the processing of the
また、図11,図12,図13に示すように、第2の実施の形態は、第1の実施の形態(図6、図7、図9)と比べると、フラグ管理手段107の使い方において、処理手段としてのソケット書込手段102、処理要求手段としてのソケット書込要求手段102aとコールバック処理手段102bが第1の実施の形態の同手段と異なる動作をする点で、第1の実施の形態と構成が異なる。ソケット書込要求手段102a及びコールバック処理手段102bの動作について以下説明する。このフラグ管理手段107の変更は、第2の実施形態では、アプリケーション書込手段105がノンブロッキングで並行処理が可能となったため、アプリケーション書込手段105が連続的多頻度に実行されている間に限り、アプリケーション書込手段105がソケット書込要求手段を呼び出さずに、中間バッファ121Bにイベントを書き込むだけの少ない処理で終了するためである。その代わり、アプリケーション書込手段105が連続的多頻度に実行されている間は、すでに実行中のソケット書込手段102のコールバック処理手段は、中間バッファ121Bが保持するイベントがなくなるまで連続してソケット書込手段を呼び出す。このことにより、アプリケーション書込手段105の平均処理速度が短くなり、アプリケーションのスレッド103の並行処理の効率がよくなる。なお、第1の実施例でも第2の実施例で示すアプリケーションの送信スレッドの並列動作効率を重視したフラグ管理手段107の使い方(ソケット書込要求手段102a及びコールバック処理手段102bの動作)を適用することは可能であるし、逆に、第2の実施例でも第1の実施例で示したOSの送信処理効率を重視したフラグ管理手段107の使い方(ソケット書込要求手段102a及びコールバック処理手段102bの動作)を適用することも可能である。また、一方で、フラグ管理方法をこの2種類の手法に限定するものではなく、イベント追加とイベント処理をノンブロッキングかつ非同期に行うための他の手法を用いてもよい。
Also, as shown in FIGS. 11, 12, and 13, the second embodiment differs from the first embodiment (FIGS. 6, 7, and 9) in the usage of the flag management means 107. , socket writing means 102 as processing means, socket writing request means 102a and callback processing means 102b as processing request means operate differently from the same means in the first embodiment. differ in form and composition. The operations of the socket write request means 102a and the callback processing means 102b will be described below. In the second embodiment, since the application writing means 105 is capable of non-blocking parallel processing, this change of the flag management means 107 is limited to the period when the application writing means 105 is continuously and frequently executed. , the application writing means 105 does not call the socket write request means, but writes the event to the
図11及び図13は、ソケット書込要求手段102aの動作例を説明するためのフローチャートである。また、図12は、コールバック処理手段102bの動作例を説明するためのフローチャートである。 11 and 13 are flow charts for explaining an operation example of the socket write request means 102a. Also, FIG. 12 is a flow chart for explaining an operation example of the callback processing means 102b.
まず、図11に示すように、ソケット書込要求手段102aは、呼出元を確認し(S40)、呼出元がアプリケーション書込手段105(第1のバッファにイベント追加後の呼出)の場合(S40;Yes)、フラグ管理手段107に依頼して、フラグ管理手段107の管理するフラグの状態を確認し(S41)、フラグが解除されている場合(S42;Yes)、フラグを立てる(S43)。ソケット書込要求手段102aは、アプリケーション書込手段105がイベントをリングバッファ121bに書き込み処理を終了する直前、及びソケット書込要求手段102aの終了後に実行される対応するコールバック処理手段102bの終了直前のいずれかから非同期に呼出される。呼び出しは通常のメソッドあるいは関数の呼び出しでもよいし、あるいは、OS機能を使い待機しているスレッドへのシグナリングによる起動でもよい。前者の場合のみフラグ管理手段を利用して、OS実行手段にイベント処理を要求できる状態であるかどうかを判断する。後者の場合はすでにフラグを立てて後、1回以上OS実行手段にイベント処理を実行している最中であるので、フラグを再び立てることなく、OS実行手段にイベントの処理を要求しようとする。呼び出し元を通知する一番簡単な方法は、呼び出しパラメータに呼び出し元識別子を含めることであるが、他のどんな方法でもよい。前者の場合でフラグが立てられると、次に、ソケット書込要求手段102aは、OS実行手段100にイベントの処理を要求する(S44)。一方、前者の場合で、もし、フラグ管理手段107の管理しているフラグがすでに立っている場合は(S42;No)、処理を直ちに終了する。また、ソケット書込要求手段102aは、後者の場合、すなわち、呼出元がアプリケーション書込手段105ではなくコールバック処理手段102bの場合(S40;No)、このコールバック処理手段102bの実行に対応する直前のソケット書込要求手段102aの実行時にすでにフラグを立てているので、フラグの状態に関わらずOS実行手段100にイベントの処理を要求する(S44)。なお、前述のように、図6同様に、点線で囲まれたフラグの操作(状態確認や設定S41,S42,S43はマルチスレッド環境下で他スレッドによる割り込みによる影響がないようにアトミックに実行される必要があり、フラグ管理手段107が提供する(Compare and Swap)の機能を利用する。
First, as shown in FIG. 11, the socket
また、図13にOS実行手段100の動作を示す。ソケット書込要求手段102aは、ステップS44(図11)において第1のバッファ121b1に送信対象のデータがあるか確認し(S60)、送信対象のデータがある場合(S60;Yes)、第1のバッファ121b1上のイベントを第2のバッファ121b2に必要に応じて移動する(S61)。単に移動するだけならば、このステップは省略して、第1のバッファのデータを対象として、いきなりOS非同期送信呼出S63を実行すればよく、移動を省く分だけ処理の効率はよくなる。移動するからには、移動操作においてなんらかの性能の向上が期待される操作、例えば、バッファのメモリタイプの変更、バッファのメモリサイズの変更、バッファ内のデータの配置の変更、移動個数(移動イベント数、あるいは、移動バイト数)の制御などを行い、第1のバッファのメモリチャンクに保持されているイベントを、第2のバッファの新たに割り当てたメモリチャンクにコピーし、第1のバッファのコピー終了後の不要なメモリチャンクを解放する。
13 shows the operation of the
なお、バッファが保持するメモリチャンクの割当や解放はバッファプールを用いると効率がよい。以下の各種バリエーションではバッファプールを仮定し、規格化されたサイズのメモリチャンクを用いたバッファを念頭に記述するが、本発明は、それらのすべての操作、あるいは、一部の操作だけと限定せず、通常に都度割当解放するメモリチャンクであっても、また、チャンクのサイズがばらばらであっても、以下の各種バリエーション、及び、その他の有用な操作を除外するものではない。 It is more efficient to allocate and release memory chunks held by buffers using a buffer pool. The various variations below assume a buffer pool and are described with buffers using standardized size memory chunks in mind, but the present invention is not limited to all or only some of these operations. However, even if the memory chunks are normally deallocated each time, and even if the size of the chunks varies, it does not exclude the following variations and other useful operations.
まず、メモリチャンクのタイプは、第2のバッファを後述するようにOSが処理で使用(S63)するので、OSの処理に適したダイレクトバッファを使用するとよい。 First, as for the type of memory chunk, the OS uses the second buffer for processing (S63) as will be described later, so it is preferable to use a direct buffer suitable for the processing of the OS.
次にバッファのサイズやデータの配置を検討する。OSは同じサイズのデータでも、大きなメモリチャンク1個で処理をする方が、小さなチャンクを数多く処理するより効率がよい。そこで、大きなメモリチャンクを用意し、複数のイベントをひとつのメモリチャンクに順番に配置することで、OSが処理するメモリチャンクの個数を削減するとよい。 Next, consider the buffer size and data placement. The OS is more efficient to process the same size data in one large chunk of memory than to process many small chunks. Therefore, it is preferable to reduce the number of memory chunks processed by the OS by preparing a large memory chunk and sequentially arranging a plurality of events in one memory chunk.
次に移動について検討する。移動のタイミングで、ごく単純に、第1のバッファ121b1が保持すすべてのイベントを第2のバッファ121b2に移動してしまってもよい。しかし、第2のバッファはOS処理に使うダイレクトバッファを使用すること、OS処理要求が一度に処理できるメモリチャンクの数や総バイト数には上限があることを考慮すると、ダイレクトバッファの使用量を抑制するためには、移動するイベントの数は、受け入れる第2のバッファが保持するメモリチャンクが、OS処理要求に適切な分量以下になるように制御するとよい。たとえば、第2のバッファの保持するダイレクトバッファのメモリチャンクの数に対して、例えば32個程度などの上限を設定し、OSの処理が滞るなどの原因で、第2のバッファがすでに相当量のメモリチャンク(この例では32個に近い数のメモリチャンク)を保持している場合、移動を上限の範囲(この例では例えば32個、あるいは33個などの予め定める上限値)で停止する、あるいは、すでに上限を超えていれば移動を行わない(0個の移動を行う)。このように、第2バッファ121b2が保持するメモリチャンク数に上限などの制限を設けることで、通信不調などで滞ったイベントは、第1のバッファ121b1に蓄積され、サーバ装置1全体で共有するダイレクトバッファリソースを使う第2のバッファ121b2を肥大化させることはない。逆に第2のバッファが保持するチャンクがほとんどない健全な状態では、第1のバッファ121b1のイベントすべてを移動できる。
Next, consider movement. All the events held in the
第1のバッファ121b1から第2のバッファ121b2へのイベントの移動は、このようなメモリチャンクのタイプの変更やメモリチャンクのサイズの変更やメモリチャンク内のデータ配置の変更や移動個数の制御あるいはその他の性能向上の工夫の全部あるいは一部だけを実施して、後段のOSでのイベント処理効率をよくするために行う。 Movement of events from the first buffer 121b1 to the second buffer 121b2 is performed by changing the type of memory chunk, changing the size of the memory chunk, changing the data arrangement in the memory chunk, and controlling the number of events to be moved. Alternatively, all or part of other measures for improving performance are implemented in order to improve the efficiency of event processing in the subsequent OS.
以上、2個のバッファ(第1のバッファ121b1と第2のバッファ121b2)の例を記載したが、バッファの個数を2個に限定するものではない。メモリチャンクのタイプの変更やメモリチャンクのサイズの変更やメモリチャンク内のデータ配置の変更や移動個数の制御あるいはその他の性能向上の工夫は、2個のバッファ間の1回の移動ですべて実施する必要はなく、3個以上のバッファを用いて、多段に順次実行してもよい。 Although an example of two buffers (first buffer 121b1 and second buffer 121b2) has been described above, the number of buffers is not limited to two. Changing the type of memory chunk, changing the size of the memory chunk, changing the data arrangement in the memory chunk, controlling the number of moves, and other measures to improve performance are all performed in a single move between two buffers. It is not necessary, and may be executed sequentially in multiple stages using three or more buffers.
また、イベント単位の移動の例を記載したが、移動をイベント単位に限定するものではない。ネットワーク送信などOS処理システムが、個々のイベントの境界にとらわれず、蓄積されたバイト単位に処理をする場合、バッファ間のイベントの移動はイベント単位(0個以上の複数個のイベント)に限定されない。あるイベントの一部分だけでもよいし、連続するイベントの部分を結合したもの(例えば、イベントA,イベントB、イベントCが順番に蓄積されていた時に、イベントAの前半が移動した後は、イベントAの後半の一部(イベントAの残りの後半)、イベントB全部、イベントCの前半の一部を連続するイベントの部分を結合したもの)でもよい。 Also, although an example of movement in event units has been described, movement is not limited to event units. When the OS processing system such as network transmission processes in units of accumulated bytes without being constrained by the boundaries of individual events, movement of events between buffers is not limited to units of events (0 or more events). . It may be only a part of a certain event, or a combination of consecutive event parts (for example, when event A, event B, and event C are accumulated in order, after the first half of event A is moved, event A (remaining second half of event A), all of event B, and a part of the first half of event C combined).
また、第1のバッファ121b1に送信対象のデータがない場合(S60;No)、ステップS62へと進む。 If there is no data to be transmitted in the first buffer 121b1 (S60; No), the process proceeds to step S62.
なお、第1のバッファ121b1へイベントを追加するのは、アプリケーション書込手段105である。アプリケーション書込手段105は、第1のバッファ121b1へイベントを追加後(図10)に、ソケット書込要求手段102aを呼び出す。アプリケーション書込手段105は、並行動作する複数スレッド103から非同期に呼出され、ノンブロッキングで第1のバッファ121b1にイベントを蓄積する。バッファとしては、たとえば、Javaが提供するキュー(java.util.concurrent.ConcurrentLinkedQueue)を、メモリチャンクへのポインタを管理するFIFOバッファを利用する。バッファプールが管理する、メモリチャンクを再利用することで、効率のよいリングバッファを実現できる。バッファプールのメモリチャンクは典型的なイベントサイズより少し大きめのメモリサイズで規格化するとよい。メモリチャンクにはいりきらない大きなイベントは複数のチャンクに保管する。チャンクサイズは、ページサイズの2の累乗数分の1となるように調整する。第2のバッファ121b2も、第1のバッファ121b1同様に、イベント情報格納したメモリチャンクへのポインタを保持するFIFOキュー(例えば、java.util.concurrent.ConcurrentLinkedQueue)が使用できる。
It is the application writing means 105 that adds the event to the first buffer 121b1 . After adding the event to the first buffer 121b1 (FIG. 10), the application writing means 105 calls the socket
次に、ソケット書込要求手段102aは、第2のバッファ121b2に送信対象のデータがある場合(S62;Yes)、OS実行手段100にOS非同期送信要求を行ってイベントの処理を要求する(S63)。例えば、JavaのAsynchronousSocketChannel.write()の集約書込(gathering write)を呼び出して、複数メモリチャンクを送信対象として、1回の呼び出しで複数のイベントの処理を要求する。また、ソケット書込要求手段102aは、第2のバッファ121b2に送信対象のデータがない場合(S62;No)、フラグ管理手段107に依頼して、フラグを解除する(S64)。第1のバッファ121b1にデータがないことを確認(S60)後、第2のバッファ121b2にもデータがないことを確認(S62)したので、中間バッファ121B(第1のバッファ121b1及び第2のバッファ121b2)が保持するデータをすべて送信し終わったとみなして、フラグを解除して、場合によってはフラグをたてたまま複数回連続的に行ってきたOS非同期送信呼び出しを終了する。送信し終わったとみなした後、フラグを解除するまでの間に、第1のバッファ121b1にイベントが追加された場合は、次のイベントとともにOS処理が実行される。
Next, when the second buffer 121b2 contains data to be transmitted (S62; Yes), the socket
図12に示すコールバック処理手段102bは、OS実行手段100がソケット書込要求手段102aの書込イベントの処理を完了した場合に、OS実行手段100から完了通知を受け付けて、対応するソケット書込要求手段102aとは非同期に実行する。コールバック処理手段102bは、OS実行手段100が実行したネットワーク送信結果を受け取る(S50)。送信結果が正常の場合は(S51;Yes)、コールバック処理手段102bは、送信完了分を第2のバッファ121b2から削除し(S52)、ソケット書込要求手段102aに呼び出しを行う(S53)。また、送信結果が異常の場合は(S51;No)、コールバック処理手段102bは、通信断、タイムアウトなどの例外処理(接続の切断など)を行う(S54)。 The callback processing means 102b shown in FIG. 12 receives a completion notification from the OS execution means 100 when the OS execution means 100 completes the processing of the write event of the socket write request means 102a, and writes to the corresponding socket. It executes asynchronously with the request means 102a. The callback processing means 102b receives the network transmission result executed by the OS executing means 100 (S50). If the transmission result is normal (S51; Yes), the callback processing means 102b deletes the transmission completion data from the second buffer 121b2 (S52), and calls the socket write request means 102a (S53). . If the transmission result is abnormal (S51; No), the callback processing means 102b performs exceptional processing (disconnection, etc.) such as disconnection of communication or timeout (S54).
(情報処理装置の動作)
第2の実施の形態の作用を、(1)基本動作、(2)データ送信動作に分けて説明する。
(Operation of information processing device)
The operation of the second embodiment will be described separately for (1) basic operation and (2) data transmission operation.
図9は、第2の実施の形態のデータ送受信の動作の一例を説明するための概略図である。 FIG. 9 is a schematic diagram for explaining an example of data transmission/reception operations according to the second embodiment.
(1)基本動作
まず、ネットワーク4からサーバ装置1がデータを受信する場合、ネットワーク4のソース131からあるチャネル130を介し、ソケット読出手段101がチャネルに対応するソケット(受信元端末装置に対応するあるIPアドレスのあるポート)によって受信したデータを読み出して中間バッファ121Bに書き込む。データは中間バッファ121Bに追加される。なお、バッファはチャネルあるいはソケットごとに別々に用意する。また、チャネル/ソケットは送受信共用で、対応する端末装置(端末装置の通信相手となる特定のプログラム)ごとに1つ用意する。アプリバッファは、1つで図示しているが、実際は送受信別に管理する。また、中間バッファ121Bは、バッファプールとしては、全チャネルで1つとして管理されており、1つで図示しているが、チャネルごと、送受信別々に管理され、チャネルごとに、別々の受信中間バッファ、送信中間バッファとして区別する。
(1) Basic operation First, when the
以降のアプリバッファ120への書込動作は第1の実施の形態と共通するため省略する。
The subsequent write operation to the
次に、アプリケーション実行手段103は、アプリバッファ120のデータを読み出してスレッドにて処理する。
Next, the application execution means 103 reads the data of the
また、アプリケーション実行手段103のスレッドで処理されたデータをネットワーク4に送信する場合、アプリケーション実行手段103は、スレッドで処理されたデータをアプリバッファ120に書き込む。第2の実施の形態ではアプリケーション書込手段105がマルチスレッドで並行処理される場合をメインに説明する。
Also, when transmitting data processed by the thread of the
アプリケーション書込手段105は、アプリバッファ120のデータを意図する送信先端末装置に応じて、送信先端末装置、より厳密には、チャネルあるいはソケットに対応する中間バッファ121B、特に第1のバッファ121b1にスレッド毎に書き込む。第1のバッファ121b1には、スレッド毎に用意された領域に順次データが書き込まれる。アプリケーション書込手段105の並行処理の効率をよくするために、アプリケーション書込手段105はノンブロキングに中間バッファ121Bにデータ(処理結果のイベント)を書き込む。
Depending on the destination terminal device for which the data in the
次に、ソケット書込手段102は、任意のタイミングで第1のバッファ121b1から第2のバッファ121b2へ順次データを移動する。移動とは、データを保持するメモリチャンクを第1のバッファ121b1から第2のバッファ121b2へと文字通りバッファ間で移動する場合だけでなく、対象データを第2のバッファへコピーした後に、第1のバッファからは削除する場合を含む。また、移動とは、単なる1対1の移動にとどまらず、移動によりバッファのタイプ、メモリチャンクのサイズ、メモリチャンク内での配置方法を変更したり、移動するイベント個数の調整をしたり、OS実行手段が処理しやすいデータ保持形態に変換したりすることも含む。これらの変換を段階的に実施するためには、第3のバッファ、第4のバッファなどさらにバッファ個数(バッファの段数)を増やしてもよい。また、バッファの利用都度に発生するメモリの割当・解放の負荷を軽減するために、データを保持するメモリチャンクはあらかじめまとめて割り当てたメモリを再利用するバッファプールで管理することができる。第1のバッファ、第2のバッファでバッファプールを共有することもできる。また、複数チャネルでそれぞれのバッファ管理を行う場合でも、単一のバッファプールを共有することもできる。バッファプールでは、多くの場合、規格化されたサイズのメモリチャンクを1種類あるいは複数種類保持する。バッファプールは通信管理プログラム起動時にシステムから確保したメモリを使い回すため、バッファプールのメモリを使ったメモリの割当・解放はシステムコールを伴わず処理が軽い、頻繁で複雑なメモリ利用をしても、システムメモリのフラグメンテーションを引き起こさないなどの効果がある。バッファプールは起動時に適切量を確保するが、実行時に不足が起きてしまった場合は、その時点、あるいは、不足が予測された時点で、OSに負荷を与えてしまうので、可能であればある適当なタイミングを見計らって、OSにリクエストして追加のメモリを確保し、バッファプールを拡張することが望ましい。バッファプールが確保するメモリチャンクのメモリの種類やチャンクのサイズは利用形態で適切にチューニングする。第1のバッファで扱うメモリチャンクとしては、通常のヒープが管理する非ダイレクトバッファから平均的なイベントサイズより少し大きな単一サイズ(例えば256バイト)を選択する。第2のバッファで扱うメモリチャンクとしては、OSが扱いやすいサイズとタイプ、例えばページサイズ、あるいはページサイズの半分(例えば2KB)のダイレクトバッファを選択する。メモリプールのサイズは、OSからまとめて取得したバッファを小分けにして使うので、ページサイズやメモリ境界を意識して、ページサイズ、あるいは、ページサイズの2の累乗数分の1の値を採用し、25バイトや50バイトのような任意の値を採用しない。
Next, the socket writing means 102 sequentially moves data from the
次に第1のバッファから第2のバッファへ移動するタイミングは、予め定めた時間間隔毎であってもよいし、第1のバッファ121b1又は第1のバッファ121b1内のチャンクに蓄積されたデータ量が予め定めた量になった場合であってもよいし、第1のバッファ121b1又は第1のバッファ121b1内のチャンク蓄積されたイベントの数が予め定めた数になった場合であってもよい。
The next timing of moving from the first buffer to the second buffer may be every predetermined time interval, or the
ソケット書込手段102の起動のトリガ、あるいは、第1のバッファ121b1から第2のバッファ121b2へのデータの移動のトリガは、ポーリングやタイマなどであってもよいし、すべてあるいは一部のアプリケーション書込手段105の実行直後であってもよい。 A trigger for activating the socket writing means 102 or a trigger for moving data from the first buffer 121b1 to the second buffer 121b2 may be polling or a timer, or all or part of it. It may be immediately after execution of the application writing means 105 .
なお、3段以上のバッファを使用する場合において、格段のバッファ間のデータの移動のタイミング、トリガ、移動方法などは、それぞれの段間で、上記記載の第1バッファと第2バッファについて記述した方法をそれぞれの段で独立に採用することができる。上記の例では移動の際に複数の操作(チャンクのメモリタイプの変更、チャンクサイズの変更、移動量の制限など)を同時に行ったが、操作を分割して、途中結果を追加のバッファとして保持することが考えられる。その場合には、移動のタイミング、トリガはすべての段で同じであってもよい。 When three or more stages of buffers are used, the timing, trigger, movement method, etc. for moving data between stages are described for the above-described first and second buffers. The method can be employed independently at each stage. In the above example, when moving, multiple operations (chunk memory type change, chunk size change, movement amount limit, etc.) were performed at the same time, but the operations were divided and the intermediate results were stored as additional buffers. can be considered. In that case, the movement timing and trigger may be the same for all stages.
次に、ソケット書込手段102は、第2のバッファ121b2のデータを読み出し、ソケットによってチャネル130に書き込む。データは、チャネル130を介してソース131に送信される。この時、データは第2のバッファ121b2から取り出され、送信対象としてOS実行手段100が送信処理をし、送信が完了したデータ(取り出したデータの全部あるいは一部)については、第2のバッファ121b2から削除される。送信が完了しなかったデータについては、引き続き第2のバッファ121b2にとどまる。ここでは、第2のバッファ121b2に蓄積されたデータを全部一度に送信するものとしたが、第2のバッファ121b2に蓄積されているデータが巨大になった場合は、OS送信機能呼出の制限を考慮するなど、全部一度に読み出さず、一部だけを読み出して送信する制御をしてもよい。あるいは、第2のバッファ121b2が蓄積するデータが巨大にならないように、第1のバッファ121b1から第2のバッファ121b2へ移動するイベントの数やバイト数を移動の際にあらかじめ制限してもよい。
Next, the socket writing means 102 reads the data in the second buffer 121b2 and writes it to the
以下、アプリケーション実行手段103のスレッドで処理されたデータをOS実行手段100からネットワーク4に送信する場合について詳細に説明する。
A case in which data processed by the thread of the application execution means 103 is transmitted from the OS execution means 100 to the
(2)データ送信動作
図10は、データ送信動作の一例を説明するための概略図である。スレッド1とスレッド2が、非同期にそれぞれイベントA,C,F,及びイベントB,D,Eを順次生成し、アプリケーション書込手段105、ソケット書込要求手段102aを呼び出し、それぞれのイベントA-Fをネットワーク4に送信する。アプリケーション書込手段105は、スレッド1及びスレッド2が生成したイベント1個を第1のバッファ121b1に追加し、ソケット書込手段102aを呼び出す。ソケット書込手段102aは、OSカーネル100がすでにイベント処理を実行中の場合は処理を行わないで終了するが、OSカーネル100がイベント処理を実行中でない場合は、第1のバッファ121b1が保持する0個以上のイベントを第2のバッファ121b2へ移動し、第2のバッファ121b2が保持するイベントについて、OSカーネル100にイベントの処理を依頼する。OSカーネル100がイベントの処理中であるかどうかの状態は、フラグ管理手段107が提供するCASフラグにより管理される。OSカーネル100は要求されたイベントの処理を完了すると、コールバックスレッド(スレッド1のコールバックスレッド)で、コールバック処理手段102bを、スレッド1及びスレッド2とも非同期に実行する。コールバックスレッドは、イベント処理の進捗状況を確認して、第2のバッファ121b2を調整後(処理済のイベントを第2のバッファから削除したり、第1のバッファから第2のバッファへイベントを移動したりして)、ソケット書込手段aを再帰的かつ排他的に呼び出し、OSカーネル100が処理中に第1のバッファ121b1に蓄積されたイベントについても、イベント処理を行う。コールバックスレッドは、ソケット書込要求手段102a及びコールバック処理手段102bの処理を繰り返して、中間バッファ121B(すなわち、第1のバッファ121b1及び第2のバッファ121b2)が保持するイベントがなくなるまで稼働する。
(2) Data Transmission Operation FIG. 10 is a schematic diagram for explaining an example of data transmission operation.
アプリケーション実行手段103は、例えば、複数のスレッド1、スレッド2によりデータを処理し、処理結果のイベントA、イベントBを同一の端末装置(より厳密には、同一のソケットあるいはチャネル)に送信するために、当該イベントA、イベントBはアプリケーション書込手段105により送信先端末へ通信するソケットに対応する第1のバッファ121b1に書き込まれる。スレッド1、スレッド2の処理は非同期に発生するものとする。第1のバッファ121b1は、例えばスレッドセーフでノンブロッキングなリングバッファ(例えば、ノンブロッキングでスレッドセーフなFIFOキュー java.util.ConcurrentLinkedQueue にイベントを格納するメモリチャンクのポインタを登録することで実現可能)である。アプリケーション書込手段105は、イベントA、イベントBをスレッド毎に異なる領域(チャンク)にノンブロッキングにイベントを書き込む(1)(2)。特に、イベントのサイズのメモリチャンクの代わりに、規格化されたサイズのメモリチャンクを用いる場合は、メモリチャンクは、例えば、java.nio.ByteBufferを用いて、保管しているイベントの開始位置と終了位置も管理する。また、規格化されたサイズのメモリチャンクにイベントを保管する場合、チャンクサイズより大きなイベントについては、イベントを複数チャンクにわたるチャンクグループに保管し、チャンクグループへのポインタをリングバッファに追加してもよい。
The application execution means 103, for example, processes data by a plurality of
さて、まず、スレッド1のイベントAについては、アプリケーション書込手段105は第1のバッファ121b1のイベントAの処理を要求すべくソケット書込要求手段102aを呼び出す(3)。ソケット書込要求手段102aは、呼出元がアプリケーション書込手段105なので、フラグ管理手段107のCASフラグを参照し、フラグが立っていないので、フラグを立てて(4)、第1のバッファ121b1にイベントが蓄積されているか確認し、イベントがあるので第1のバッファ121b1のイベントAを第2のバッファ121b2へ移動する(5)。ここで、第2のバッファ121b2も、第1のバッファ121b1同様に、例えばノンブロッキングなリングバッファ(例えば、ノンブロッキングでスレッドセーフなFIFOキュー java.util.ConcurrentLinkedQueue にイベントを格納するメモリチャンクのポインタを登録することで実現可能)であってもよい。ただし、第2のバッファの操作を行うスレッドは、フラグ管理手段107により、高々1個に制御されているので、スレッドセーフでなくてもよい。また、ソケット書込要求手段102aは、イベントAを第2のバッファ121b2へ移動した後、スレッド1に次の処理を進めるよう呼び出しを行い、処理はOSカーネル100にまかせて(6)、OSカーネル100の処理の完了をまたずに終了し、スレッド1の処理に戻る(7)。
First, for event A of
一方で、スレッド2のイベントBについては、アプリケーション書込手段105は第1のバッファ121b1のイベントBの処理を要求すべくソケット書込要求手段102aを呼び出す(8)。ソケット書込要求手段102aは、呼出元がアプリケーション書込手段105なので、フラグ管理手段107のCASフラグを参照し(9)、この場合は先のイベントAの処理のためにすでにフラグが立っている(4)ため、もはやフラグをたてられない。ソケット書込要求手段102aは、処理ができるようになるまで待たず、ノンブロッキングで処理を終了してスレッド2の処理に戻る(10)。
On the other hand, for event B of
スレッド1については、アプリケーション実行手段103は、引き続きデータを処理し、アプリケーション書込手段105は処理結果のイベントCを第1のバッファ121b1に書き込む(11)。第1のバッファ121b1は、未処理のイベントBとイベントCを保持している(11)。スレッド1のイベントCについては、アプリケーション書込手段105は第1のバッファ121b1のデータ(追加したデータCだけでなく、すでに追加されているデータBも)の処理を要求すべくソケット書込要求手段102aを呼び出す(50)。ソケット書込要求手段102aは、呼出元がアプリケーション書込手段105なので、フラグ管理手段107のCASフラグを参照し、この場合は先のデータAの処理のためにすでにフラグが立っている(4)ため、もはやフラグをたてられない。ソケット書込要求手段102aは、処理ができるようになるまで待たず、ノンブロッキングでソケット書込要求手段102aの処理を終了してスレッド1の処理に戻る。
For
スレッド1のイベントAのネットワーク送信については、具体的には、ソケット書込要求手段102aが、OSカーネル100に処理をまかせる(6)際には、OSシステムコール(例えばJAVAのAsynchronousSocketChannel.write())呼び出しを行い、第2のバッファ121b2に存在するイベントA(12)を指定して送信要求する。ソケット書込要求手段102aは、第2のバッファ121b2のイベントAをOS実行手段100(OSカーネル)に書き込み要求をして終了し、スレッド1の処理に戻る(7)。
Regarding the network transmission of the event A of the
スレッド1のイベントAのネットワーク送信については、送信依頼されたOSカーネル100は、第1の実施の形態と同様に、イベントAを適切なサイズに分割してイベントA1、A2を送信する(13)。分割のサイズ、分割の個数、送信間隔はOSやネットワークの負荷などに依存する。
As for network transmission of event A of
また、一方で、スレッド2のイベントBについて、OSカーネル100がイベントAの処理中に、アプリケーション書込手段105は、第1のバッファ121b1のイベントBを処理すべく、引き続きソケット書込要求手段102aを呼び出す(8)が、ソケット書込要求手段102aは、まだイベントAが処理中(4)でフラグ管理手段107のCASフラグが立っている(9)のでソケット書込要求手段102aは第1のバッファ121b1のイベントBを第2のバッファ121b2へ移動せず、アプリケーション書込手段105は処理を終了し、スレッド2は次の処理を進める(10)。この時点では、第1のバッファ121b1には、イベントB、Cが蓄積されており、まだイベントDは生成されていない(11)。アプリケーション実行手段103は、スレッド2によりデータを処理して、後のタイミングでイベントDを生成する。
On the other hand, regarding event B of
次に、スレッド1よりイベントAの送信依頼されたOSカーネル100は、イベントAの送信を完了すると、コールバック処理手段102bをスレッド1のコールバックスレッドとして起動して(14)、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントA全体が送信完了しているので、第1のバッファ121b1からイベントAを削除する(15)。この時点で第1のバッファ121b1にはイベントB、Cが存在する(11)。その後、コールバック処理手段102bは、ソケット書込要求手段102aを呼び出す(16)。
Next, when the
引き続き、コールバックスレッドにおいて、ソケット書込要求手段102aは、第1のバッファ121b1にイベントが蓄積されているか確認し、イベントがあるので第1のバッファ121b1のイベントB、Cを第2のバッファ121b2へ移動する(17)。ここでは、第2のバッファ121b2の容量に十分余裕があるので、第1のバッファ121b1のイベントすべてを移動したが、第2のバッファ121b2の容量などを考慮して、第1のバッファ121b1が蓄積するイベントの一部だけ(例えばイベントBだけ)を移動してもよい。たまたま、この後のタイミングで、スレッド2のイベントDについて、アプリケーション書込手段105は処理結果のイベントDを第1のバッファ121b1に書き込む(18)。この時点では、第1のバッファ121b1はイベントDだけを保持している。
Subsequently, in the callback thread, the socket
さて、スレッド1のイベントCについては、引き続きソケット書込要求手段102aを呼び出すが、フラグ管理手段107のCASフラグが立っているので、ソケット書込要求手段102aは第1のバッファ121b1のイベントB、イベントCを第2のバッファ121b2へ移動せず、アプリケーション書込手段105は処理を終了し、スレッド1に戻り処理を進める(19)。アプリケーション実行手段103は、スレッド1によりデータを処理し、後のタイミングでイベントFを生成する(20)。また、この第1バッファ121b1のイベントBとイベントCについては、前述したように、後のタイミングで、コールバックスレッドによりイベント処理が行われることになる。
As for event C of
次に、コールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bの場合なので、引き続きOSシステムコール呼び出しを行い、第2のバッファ121b2のイベントBとイベントCを送信要求する(21)。ソケット書込要求手段102aは、第2のバッファ121b2のイベントBをOS実行手段100(OSカーネル)に書き込み要求をしてコールバックスレッドを終了する。 Next, in the callback thread, since the call source is the callback processing means 102b, the socket write request means 102a continues to call the OS system call, and transmits event B and event C of the second buffer 121b2 . Request (21). The socket write request means 102a requests the OS execution means 100 (OS kernel) to write event B in the second buffer 121b2 , and terminates the callback thread.
次に、コールバックスレッドよりイベントB、Cの送信依頼をされたOSカーネル100は、イベントB及びイベントCを適切なサイズに分割してネットワークに送信する。まずイベントBを3分割してイベントB1、B2、B3と送信して、終了(OSカーネルは処理を完了)する。イベントBのみ送信してイベントCを送信しない理由、あるいはイベントBの一部でなくイベントB全体を送信した理由は、OSの都合であり、サーバ装置1又はネットワーク4の負荷などの状況による(22)。
Next, the
また、スレッド2のイベントDについて、スレッド1のコールバックスレッドに依頼されたOSカーネル100のイベント処理中に、アプリケーション書込手段105は、第1のバッファ121b1のイベントDを処理すべく、引き続きソケット書込要求手段102aを呼び出す(23)が、ソケット書込要求手段102aはイベントB、Cの処理中(16)でフラグ管理手段107のCASフラグが立っている(24)のでソケット書込要求手段102aは第1のバッファ121b1のイベントDを第2のバッファ121b2へ移動せず、アプリケーション書込手段105は終了し、スレッド2に戻り次の処理を進める(25)。アプリケーション実行手段103は、引き続きスレッド2によりデータを処理して、後のタイミングでイベントEを生成する(26)。この時点で、第1のバッファ121b1には、イベントDが蓄積(18)されており、まだイベントEは生成されていない。
Also, regarding event D of
次に、コールバックスレッドよりイベントB、Cの送信依頼をされたOSカーネル100は、イベントBの送信を完了すると、コールバック処理手段102bを起動して(27)、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントB全体が送信完了しているので、第1のバッファ121b1からイベントBを削除する。
Next, the
この時点で、スレッド2は、イベントEを生成し、アプリケーション書込手段105によりイベントEを第1のバッファ121b1に書き込む。第1のバッファ121b1にはイベントD、Eが存在する(28)。スレッド2において、イベントEを生成(26)したアプリケーション書込手段105は、ソケット書込要求手段102aを呼び出す(30)。ソケット書込要求手段102aは、まだイベントC及びイベントDの処理中(27)でフラグ管理手段107のCASフラグが立っている(31)のでソケット書込要求手段102aは第1のバッファ121b1のイベントD及びEを第2のバッファ121b2へ移動せず、アプリケーション書込手段105は処理を終了しスレッド2に戻り、スレッド2は次の処理を進める(32)。
At this point,
スレッド1のコールバックスレッドよりイベントB、Cの送信依頼をされたOSカーネル100が、イベントBの送信を完了後に、再び、スレッド1のコールバックスレッドを起動し、起動したコールバック処理手段102bは、再び、ソケット読み込み要求手段102aを呼び出す(29)。ソケット書込要求手段102aは、第1のバッファ121b1にイベントが蓄積されているか確認し、イベントがあるので第1のバッファ121b1のイベントD、E(28)を第2のバッファ121b2へイベントを移動する(33)。この時点で、第2のバッファ121b2はイベントC、D、Eを保持する。
When the
次に、スレッド1のコールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bなので、OSシステムコール呼び出しを行い、第2のバッファ121b2のイベントC、D、EをOSに送信要求してコールバックスレッドを終了(34)する。
Next, in the callback thread of
次に、OSカーネル100は、イベントC,D,Eを送信しようとする。まずイベントCを適切なサイズに分割(C1,C2,C3)してイベントC1、C2を送信して終了(OSカーネルは処理を完了)する(35)。イベントCの一部(C1,C2)のみを送信(35)して、残りのイベントC(C3)、イベントD、イベントEを送信しない理由は、前述したようにOSの都合である。この時点で、第1のバッファ121b1には、イベントFが蓄積されている。
The
次に、OSカーネル100は、イベントCの一部の送信を完了すると、再び、スレッド1のコールバックスレッドとして、コールバック処理手段102bを起動(36)して、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントCのうちC1、C2が送信完了しているので、第2のバッファ121b2からイベントCのうちC1、C2に相当する部分を削除する。Cが単一のチャンクに格納されている場合、C3の送信が完了するまではチャンク全体のメモリ解放はできない。例えば、java.nio.ByteBufferを用いて送信開始位置と送信終了位置を管理する場合、C全体の解放はC3の処理終了後とし、C1,C2の完了は、送信開始位置をC1からC3に移動すればよい。そして再び、ソケット書込要求手段102aを呼び出す(37)。
Next, when the
次に、コールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bなので、第1のバッファ121b1にイベントが蓄積されているか確認するが、イベントFが蓄積されていたので、イベントFを第2のバッファ121b2へ移動する。イベントFは第1のバッファ121b1から第2のバッファ121b2へ移動し、第1のバッファはイベントがなくなり(38)、第2のバッファはイベントC3、D、E、F(39)を保持する。ソケット書込要求手段102aは、引き続き、OSシステムコール呼び出しを行い、第2のバッファ121b2のイベントC3、D、E、F(39)をOS実行手段100(OSカーネル)に書き込み要求をしてコールバックスレッドを終了する(40)。
Next, in the callback thread, the socket
次に、イベントC3、D、E、Fの送信依頼されたOSカーネル100は、イベントC、Dを適切なサイズに分割してイベントC3、D1、D2を送信する(41)。イベントC3とDのみ送信してイベントE、Fを送信しない理由は、前述したようにOSの都合である。
Next, the
次に、イベントC3、D、E、Fの送信依頼されたOSカーネル100は、イベントC、Dの送信を完了すると、コールバックスレッドとして、コールバック処理手段102bを起動して(42)、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントCのうちC3が、イベントDのすべてが送信完了しているので、第2のバッファ121b2からイベントC3(あるいはイベントC全体)およびイベントDを削除する。そして再び、ソケット書込要求手段102aを呼び出す(43)。
Next, the
次に、コールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bなので、まず第1のバッファ121b1にイベントが蓄積されているか確認し、イベントがない(38)ので第2のバッファ121b2にイベントを移動せず、OSシステムコール呼び出しを行い、第2のバッファ121b2のイベントE、F(44)をOS実行手段100(OSカーネル)に書き込み要求をしてコールバックスレッドを終了する(45)。 Next, in the callback thread, the socket write request means 102a first confirms whether an event is accumulated in the first buffer 121b1 because the caller is the callback processing means 102b. An OS system call is made without moving the event to the second buffer 121b2 , and a write request is made to the OS execution means 100 (OS kernel) to write events E and F (44) of the second buffer 121b2. Terminate the back thread (45).
次に、イベントE、Fの送信依頼されたOSカーネル100は、イベントE、Fを適切なサイズに分割してイベントE1、E2、Fを送信する(46)。
Next, the
次に、イベントE、Fの送信依頼されたOSカーネル100は、イベントE、Fの送信を完了すると、コールバックスレッドとして、コールバック処理手段102bを起動して(47)、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントE、Fのすべてが送信完了しているので、第2のバッファ121b2からイベントE、Fを削除する。そして再び、ソケット書込要求手段102aを呼び出す(48)。
Next, the
その後、コールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bなので、第1のバッファ121b1及び第2のバッファ121b2を順に確認するが、第1のバッファ121b1及び第2のバッファ121b2のいずれにもイベントがなくなっているので、フラグ管理手段107のCASフラグを解除(49)し、コールバックスレッドを終了する。
After that, in the callback thread, the socket write request means 102a checks the
(第2の実施の形態の効果)
上記した第2の実施の形態によれば、アプリケーション書込手段105とソケット書込手段102の間に中間バッファ121Bを設け、中間バッファ121Bの第1のバッファ121b1はアプリケーション書込手段105の書込データをスレッド毎にノンブロッキングに蓄積して、ソケット書込要求手段102aの書込動作をCASフラグに応じて実行し、CASフラグをフラグ管理手段107によって管理し、ソケット書込要求手段102aの書込開始でフラグを立て、OS実行手段100のイベント処理完了の通知を受けたコールバック処理手段102bがフラグを解除するとともに、第1のバッファ121b1にイベントが存在する場合は第2のバッファ121b2にイベントをまとめるなどOS実行手段の処理に適した形式に変換した上で移動してからOS実行手段100により第2のバッファ121b2のイベントを処理するようにしたため、アプリケーション書込手段105の書き込み動作がOS実行手段100の送信イベント処理の動作に直接影響を及ぼさないようになり(アプリケーション書込手段105、OS実行手段100がそれぞれに対応するための待ち時間がなくなり、また、イベントごとにOS実行手段100を呼び出す場合に比べてOS実行手段100の呼出回数が削減され)、アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化することができる。特に、所要時間の比較的長いネットワークへの送信処理を、ウェイト時間(レイテンシ)短く、なるべく連続処理、かつ、ノンブロッキングに実行することで、ネットワーク送信処理を優先し、送信スループットを上げつつ、非同期送信(NIO)の処理待ちの間の時間にアプリ処理をノンブロッキングに並列実行することができる。
(Effect of Second Embodiment)
According to the above-described second embodiment, the
(変形例)
上記した第2の実施の形態において、ソケット書込要求手段102aを、アプリケーション書込手段105からの呼び出しにのみ応じてOS実行手段100にイベント処理を要求するソケット書込要求手段102a1と、コールバック処理手段102bの呼び出しにのみ応じてOS実行手段100にイベント処理を要求するソケットフラッシュ書込手段102a2とに分けてもよい。この場合、図11のステップS40が不要となり、図12のステップS53が「OS実行手段100にイベント処理を要求する」に変わり、図13の動作をソケットフラッシュ書込手段102a2が担うこととなる。このように実装した場合についても第2の実施の形態と同様の上記効果を奏する。
(Modification)
In the above-described second embodiment, the socket write request means
[他の実施の形態]
なお、本発明は、上記実施の形態に限定されず、本発明の趣旨を逸脱しない範囲で種々な変形や組み合わせが可能である。
(A)CASによるノンブロッキングな排他制御
本発明の基本は、CASによるノンブロッキングなOS実行手段100の呼び出しである。ネットワーク送信処理において、OS実行手段100の呼び出しは、送信要求したデータの一部のみを送信することがあるなど、送信バッファのセットアップ、送信処理、送信完了後の済送信バッファの調整など、同一チャネルへの送信は並行処理することができない。そのためなんらかの排他制御が必要である。そこで、OSの機能を利用して、Synchronizedメソッドなどで実装し、同時に単一のスレッドしか実行できず、他のスレッドは実行中のスレッドの終了を待ち、暫時、ひとつずつ実行が再開されるような、排他制御を行うことが一般的である。ただ、ネットワークゲームでゲームオブジェクトの変化を大量多頻度に中継するようなゲームサーバのような用途では、小さなデータを大量多頻度に送受信することになり、OSの機能を用いた排他制御も多頻度となるため、OS機能呼び出しのオーバヘッドが無視できなくなり、サーバ機能の処理性能を低下させる。そこで本発明は、アトミックなインストラクションで実行されるノンブロッキングなCASを用いて排他制御を行う。イベントをOS機能処理中に、別のイベントのためにOS機能呼び出しを行おうとしてもCASの排他制御によって、実行されることなく、待つこともなく終了してしまう。イベントごとに逐次に処理することはできないので、イベントは一旦、バッファへ蓄積し、OS機能処理実行中のスレッドは、起動時に想定していたイベントだけでなく、起動前に蓄積されていたイベント、あるいは、OS機能処理実行中に蓄積されたイベントも、処理するように工夫している。一般に、OSの機能呼び出しは通常のメモリ処理に比べて、処理時間が長いので、ゲームサーバのような用途では、OS機能呼び出し中に新たなイベントが蓄積される可能性が高い。第1の実施例と第2の実施例で典型的な2種類のCASによるノンブロッキング排他制御方法を示したが、この2個の実施例に限定するものではない。
(B)イベント蓄積の仮想的なリングバッファの形式
OSの機能呼び出しに時間がかかる場合、機能呼び出し実行中に別の処理を非同期に実行できるように、OSは機能呼び出しとコールバックとに分けて処理する仕組みを提供する。そのため、イベント処理後のコールバックは、イベント処理のための機能呼び出しとは非同期に発生する。また、アプリケーションのイベントの生成も非同期である。これらを調停するために、イベントはリングバッファに蓄積し、FIFOでイベント処理できるように、蓄積と処理を完全に非同期に実行できるようにする必要がある。リングバッファにはさまざまなバリエーションがあり、第1の実施例ではイベントデータをバイトシーケンスで蓄積するリングバッファを示し、第2の実施例ではイベントデータを蓄積するメモリチャンクのポインタを蓄積するリングバッファを示したが、開示した2個の方法及びその変形だけに限定するものではない。
(C)イベントの蓄積とOSの機能呼び出しの非同期処理
イベントの蓄積はイベントの発生に同期できる。一方で蓄積しているイベントの処理はイベント処理完了のコールバックから起動すればよい。ただ、イベント処理が全く動作していない、例えば最初の1個目のイベント処理を起動するには別の機構が必要である。第1の実施例及び第2の実施例では、イベント処理が停止している場合に限り、イベント蓄積をトリガとする方式を開示した。しかし、前述しているように、このトリガは、タイマなどで完全に非同期であってもよいし、毎回あるいは数回に一度のイベント蓄積と同期であってもよい。また、トリガとしては、機能呼び出し(メッソッドや関数の呼び出し)であってもよいし、OS機能を用いたシグナリングでもよいし、それ以外の方法でもよい。第2の実施例では、アプリケーションのイベント処理の効率を考慮して、トリガとしてコールバックからのメソッド呼び出しを優先する方式を示した。適用するアプリケーションにより適切な方法を選択するものであり、実施例及びその変形として開示した手法のみに限定するものではない。
(D)メモリの再利用
頻繁にメモリの割当解放を繰り返す場合は、その都度OS機能呼び出しを行うのはオーバヘッドとなるので、事前にまとまったメモリを確保し、メモリの割当解放はOSに依頼するのではなく、確保済のメモリを再利用するバッファプールは一般的である。メモリのフラグメンテーションやそれに伴うガベージコレクションを回避し、メモリの再利用を促進するには、バッファプールは、規格化したメモリチャンクの集合として管理し、アプリケーションが使用するメモリサイズに応じて、必要個数のチャンクを結合して使うのも一般的である。仮想的にリングバッファを実現するには、メモリのバファプールを用いるのがよい。チャンクのサイズや個数、また、使用するメモリの種類(ダイレクトバファであるか非ダイレクトバッファであるか)は適用するアプリケーションにより適切に選択するものであり、実施例及びその変形として開示した手法による選択に限定されるものではない。
[Other embodiments]
The present invention is not limited to the above embodiments, and various modifications and combinations are possible without departing from the scope of the present invention.
(A) Non-blocking exclusive control by CAS The basis of the present invention is non-blocking OS execution means 100 calling by CAS. In network transmission processing, calling the OS execution means 100 may involve transmitting only a part of the data requested to be transmitted, setting up the transmission buffer, transmission processing, adjustment of the transmission buffer after completion of transmission, etc. cannot be sent concurrently. Therefore, some kind of exclusive control is required. Therefore, using the functions of the OS, implement it with a Synchronized method etc., so that only a single thread can be executed at the same time, and the other threads wait for the end of the running thread and resume execution one by one for a while. It is common to perform exclusive control. However, in applications such as a game server that relays changes in game objects in a network game in large quantities and frequently, small data will be sent and received in large quantities frequently, and exclusive control using OS functions will also occur frequently. Therefore, the overhead of calling the OS function cannot be ignored, and the processing performance of the server function is lowered. Therefore, the present invention performs exclusive control using non-blocking CAS executed by atomic instructions. During OS function processing of an event, even if an OS function call is attempted for another event, it will not be executed and will end without waiting due to exclusive control of CAS. Since it is not possible to process each event sequentially, the events are temporarily accumulated in a buffer, and the thread executing the OS function processing not only the events assumed at startup, but also the events accumulated before startup, Alternatively, it is devised to process events accumulated during execution of OS function processing. In general, OS function calls take longer than normal memory processing, so in applications such as game servers, there is a high possibility that new events will be accumulated during OS function calls. Although two typical non-blocking exclusion control methods by CAS have been shown in the first and second embodiments, the present invention is not limited to these two embodiments.
(B) Format of Virtual Ring Buffer for Accumulating Events If an OS function call takes a long time, the OS is divided into function calls and callbacks so that another process can be executed asynchronously while the function call is being executed. Provide a mechanism for processing. Therefore, the callback after event processing occurs asynchronously with the function call for event processing. Application event generation is also asynchronous. In order to arbitrate these, events must be accumulated in a ring buffer so that accumulation and processing can be performed completely asynchronously so that events can be processed in FIFO. There are various variations of ring buffers, the first embodiment shows a ring buffer that stores event data in byte sequences, and the second embodiment shows a ring buffer that stores pointers to memory chunks that store event data. Although shown, it is not intended to be limited to only the two disclosed methods and variations thereof.
(C) Asynchronous Processing of Event Accumulation and OS Function Calling Accumulation of events can be synchronized with the occurrence of events. On the other hand, the accumulated event processing can be started from the event processing completion callback. However, if event processing is not working at all, for example, another mechanism is required to activate the first event processing. In the first embodiment and the second embodiment, a method is disclosed in which event accumulation is used as a trigger only when event processing is stopped. However, as mentioned above, this trigger may be completely asynchronous, such as with a timer, or it may be synchronous with event accumulation once every or several times. The trigger may be a function call (method or function call), signaling using an OS function, or other methods. In the second embodiment, in consideration of the efficiency of event processing of the application, a method of giving priority to method calls from callbacks as triggers has been shown. An appropriate method is selected according to the application to be applied, and the method is not limited only to the methods disclosed as the examples and their modifications.
(D) Reuse of memory When memory allocation and deallocation are repeated frequently, calling the OS function each time becomes an overhead. Buffer pools that reuse allocated memory instead of reusing it are common. To avoid memory fragmentation and associated garbage collection, and to promote memory reuse, the buffer pool should be managed as a set of standardized memory chunks, and depending on the memory size used by the application, the required number of It is also common to combine chunks. To implement a virtual ring buffer, it is better to use a memory buffer pool. The size and number of chunks, and the type of memory to be used (direct buffer or non-direct buffer) are appropriately selected according to the application to be applied, and selection by the method disclosed as the embodiment and its modification is not limited to
図5は、レイヤ構成の変形例を示す概略図である。 FIG. 5 is a schematic diagram showing a modification of the layer configuration.
例えば、本願は、OSI(Open Systems Interconnection)参照モデルの7層のうち、アプリケーション層(アプリケーション112)とプレゼンテーション層及びセッション層(通信管理プログラム111)との間にバッファ(a)を設けた例を説明したが、イ~オの異なる層構成で、異なる位置にバッファ(b)~(e)を設けてもよい。 For example, the present application provides an example in which a buffer (a) is provided between the application layer (application 112) and the presentation layer and session layer (communication management program 111) among the seven layers of the OSI (Open Systems Interconnection) reference model. As described above, the buffers (b) to (e) may be provided at different positions in different layer configurations (a) to (e).
ここで、送信スループットを上げるためには、下位の送信に関するレイヤで待ち、下位のレイヤでレイテンシが発生しないためには、上位のアプリは下位への依頼・呼出はロックフリー(ノンブロッキング)であることが望ましい。上位から下位へはなんらかの集約が発生するので、マルチタスク環境では各スレッドのデータが混ざらないように通常はなんらかの排他制御が必要となる。排他制御にOSの「ロック(Mutex)」を使用すると処理負荷が重くなるため、ロックフリーなアルゴリズムが望ましい。特にゲームサーバのように、同期のためのパケットをストリーミングのように大量に他頻度に送信するような場合は、パケット送信単位でロックがかかるのは望ましくない。ウ~オではOSの排他制御は使えないため、アプリケーションによる排他制御を独自に行う必要がある。 Here, in order to increase the transmission throughput, it is necessary to wait in the layer related to transmission in the lower layer, and in order to prevent latency in the lower layer, requests and calls to the lower layer must be lock-free (non-blocking) for the upper application. is desirable. Since some kind of aggregation occurs from the top to the bottom, in a multitasking environment, some kind of exclusive control is usually required so that the data of each thread is not mixed. A lock-free algorithm is desirable because the use of the OS "lock (mutex)" for exclusive control increases the processing load. In particular, in the case of a game server that transmits a large amount of packets for synchronization at different frequencies, such as streaming, it is not desirable to lock each packet transmission. Since the exclusive control of the OS cannot be used in Woo, it is necessary to independently perform exclusive control by the application.
ア(第1の実施の形態および第2の実施の形態)の場合、Java VM(仮想OS)によって作成されたTCP又はUDP(User Datagram Protocol)チャネルにデータを順次送信する。同一チャネルを複数スレッドで利用する場合には排他制御が必要となる。RUDP(Reliable User Datagram Protocol)の場合は、UDPソケットを使うアプリがACK(肯定応答)や再送などの信頼性保証のレイヤを独自に作成する必要がある。 In the case of a (first embodiment and second embodiment), data is sequentially transmitted to a TCP or UDP (User Datagram Protocol) channel created by a Java VM (virtual OS). Exclusive control is required when multiple threads use the same channel. In the case of RUDP (Reliable User Datagram Protocol), an application that uses UDP sockets must independently create a reliability assurance layer such as ACK (acknowledgement) and retransmission.
イの場合、アとの相違点は仮想OSかNative OSかの違いであるため、アとほぼ同じ構成、動作で実現可能である。 In the case of B, the difference from A is whether it is a virtual OS or a Native OS.
ウの場合、ステートレス(コネクションレス)なUDPで実現可能性がある。OSの内部のレイヤを直接呼び出すことは、通常できないため実現可能性は低いが、直接呼び出す構成があれば可能となる。複数のアプリケーション及びスレッドが、NICを共用する複数の送信先(端末装置)に対する通信全てについて集約が必要となる。 In the case of c, stateless (connectionless) UDP is feasible. It is usually not possible to directly call the layers inside the OS, so the feasibility is low, but it is possible if there is a configuration for direct calling. Multiple applications and threads need to aggregate all communications to multiple destinations (terminal devices) sharing the NIC.
エの場合、OSのプロトコルスタックをバイパスして高速化することができる。プロトコルスタックを独自に制作する必要がある。(例えばDPDK(Data Plane Development Kit)等を用いることができる。https://www.dpdk.org/)。NICドライバは、NDISではなく特殊となり、通常は特定のNICプロダクト依存となる。UDPの場合、データグラムとして、ソケットを介さずに直接送信が可能な場合もある。OSの内部のレイヤを直接呼び出すことは、通常できないため実現可能性は低いが、DPDKのように専用のNICドライバがあれば可能となる。ウ同様に、複数のアプリケーション及びスレッドが、NICを共用する複数の送信先(端末装置)に対する通信全てについて集約が必要となる。 In the case of D, the speed can be increased by bypassing the protocol stack of the OS. You need to create your own protocol stack. (For example, DPDK (Data Plane Development Kit) or the like can be used. https://www.dpdk.org/). NIC drivers are not NDIS, they are specialized and are usually dependent on a particular NIC product. In the case of UDP, it may be possible to send directly as a datagram without going through a socket. It is usually not possible to directly call the internal layer of the OS, so the feasibility is low, but it is possible if there is a dedicated NIC driver like DPDK. C. Similarly, multiple applications and threads need to aggregate all communications to multiple destinations (terminal devices) that share the NIC.
オの場合、アプリケーションが完全にハードウェア依存となるため、組込みシステムなど特殊用途以外で用いられる。ウ同様に、複数のアプリケーション及びスレッドが、NICを共用する複数の送信先(端末装置)に対する通信全てについて集約が必要となる。 In the case of E, since the application is completely hardware-dependent, it is used for non-special purposes such as embedded systems. C. Similarly, multiple applications and threads need to aggregate all communications to multiple destinations (terminal devices) that share the NIC.
次に、各バッファ(a)~(e)について説明する。 Next, each buffer (a) to (e) will be explained.
(a)の場合、一般的用法としてはJAVA限定、OS非依存のものとなり、ソケット単位でのマルチスレッドのアプリパケット(アプリ送信単位)が混ざらないように集約するものとなる。 In the case of (a), as a general usage, it is limited to JAVA and independent of the OS, and is aggregated so as not to mix multithreaded application packets (application transmission units) in units of sockets.
(b)の場合、一般的用法としては言語依存、OSに依存することもあり、(a)と同様となる。(a)経由の場合はそのままパラメータのパススルーで引き渡してもよいし、分散書込の場合は、送信バイトバッファが連続領域にあれば一つの送信バッファにまとめるなどの最適化をしてもよい。ここで、分散書込とは、例えばJavaのAsynchronousSocketChannel.write()の機能で、1つ以上の可変長のデータブロックをグループ化した複数のバッファを指定して送信要求するものを指す。 In the case of (b), the general usage is language-dependent and OS-dependent, and is the same as (a). (a) In the case of via, the parameters may be passed through as they are, and in the case of distributed writing, if the transmission byte buffers are in a continuous area, they may be optimized by combining them into one transmission buffer. Here, distributed writing means, for example, Java's AsynchronousSocketChannel. A function of write( ) that specifies multiple buffers in which one or more variable-length data blocks are grouped and requests transmission.
(c)の場合、通常はOS内部、OSカーネルの作業となり、アプリは横断的に対応してプロトコルごとに集約する。なお、プロトコルヘッダの追加が必要となる。TCPソケットに書かれた時点でコネクションごとのデータストリーム状態、アプリパケットの送信単位の境界は問題としない。適当な大きさに分割して、プロトコルドライバに渡す。その際に、データのコピーや詰替えが発生する可能性がある。UDPソケットの場合は、コネクションレスのため、ソケットに書きまれればバッファリングされずに送信され、まとめて送ることはない。RUDPで複数のデータをまとめて送る場合には、UDPソケットに書き込む前にまとめてから書き込む。 In the case of (c), the work is usually done inside the OS and in the OS kernel, and the application handles it cross-sectionally and aggregates it for each protocol. Note that it is necessary to add a protocol header. When data is written to a TCP socket, the data stream state for each connection and the boundary of the transmission unit of application packets are irrelevant. It is divided into appropriate sizes and passed to the protocol driver. At that time, there is a possibility that data copying or repacking may occur. Since UDP sockets are connectionless, data written to a socket is transmitted without buffering and is not sent all at once. When sending a plurality of data collectively by RUDP, they are collectively written before being written to the UDP socket.
(d)の場合、通常はOS内部、プロトコルドライバの作業となり、アプリは横断的に対応して、各種プロトコルをNICごとに集約する。なお、プロトコルヘッダの追加が必要となる。各パケットの結合、分割、プロトコルヘッダを追加した、全データをNICごとに集約する。 In the case of (d), the task is usually done by the protocol driver inside the OS, and the application handles it cross-sectionally and aggregates various protocols for each NIC. Note that it is necessary to add a protocol header. Aggregate all data for each NIC, combining and splitting each packet and adding protocol headers.
(e)の場合、NIC内部の作業となる。ネットワークタイプに応じた分割、結合、圧縮などの加工、ヘッダなどの追加をして、ビット列に対応する電気信号に変換して、通信回線に送信する。 In the case of (e), it becomes work inside the NIC. Processing such as division, combination, and compression according to the network type, addition of a header, etc., conversion to an electrical signal corresponding to the bit string, and transmission to the communication line.
上記実施の形態では制御部10の各手段100~107の機能をプログラムで実現したが、各手段の全て又は一部をASIC等のハードウェアによって実現してもよい。また、上記実施の形態で用いたプログラムをCD-ROM等の記録媒体に記憶して提供することもできる。また、上記実施の形態で説明した上記ステップの入れ替え、削除、追加等は本発明の要旨を変更しない範囲内で可能である。また、各手段の機能は適宜他の手段に結合してもよいし、複数の手段に分離してもよい。
Although the functions of the
上記実施の形態では、主にネットワークの送信イベントの処理について記述したが、本発明は、処理する対象のイベントをネットワーク送信イベントのみに限定するものではない。本発明の各手段のすべて又は一部は、ネットワークの送信以外のイベント処理、特にOS機能に処理操作を依頼する比較的長時間を要する処理(OS機能が非同期処理を可能とするために処理要求手段とコールバック手段とを提供する処理、典型的には各種I/O操作)、より具体的には、ネットワークやディスクなど各種メディアなどに対する出力操作に、対応する要求手段とコールバック手段を差し替えることで、適用できる。また、OS機能を順次複数回呼び出してイベント処理するには、本発明のイベント処理の仕組みを複数段組み合わせることができる。 In the above embodiments, processing of network transmission events has been mainly described, but the present invention does not limit the events to be processed to network transmission events only. All or a part of each means of the present invention can be applied to event processing other than network transmission, especially processing that requires a relatively long time to request processing operations from the OS function (processing request for OS function to enable asynchronous processing). Processing that provides means and callback means, typically various I/O operations), more specifically, output operations to various media such as networks and disks, replaces the corresponding request means and callback means Therefore, it can be applied. Further, in order to process an event by sequentially calling OS functions a plurality of times, it is possible to combine a plurality of event processing schemes of the present invention.
1 :サーバ装置
2a、2b、2c:端末装置
4 :ネットワーク
10 :制御部
11 :記憶部
12 :メモリ
13 :通信部
100 :OS実行手段(OSカーネル)
101 :ソケット読出手段
102 :ソケット書込手段
102a :ソケット書込要求手段
102b :コールバック処理手段
103 :アプリケーション実行手段
104 :アプリケーション読出手段
105 :アプリケーション書込手段
106 :バッファリング手段
107 :フラグ管理手段
111 :通信管理プログラム
112 :アプリケーション
120 :アプリバッファ
121 :リングバッファ
121B :中間バッファ
121b1 :第1のバッファ
121b2 :第2のバッファ
130 :チャネル
131 :ソース
Reference Signs List 1:
101: socket reading means 102: socket writing means 102a: socket writing request means 102b: callback processing means 103: application executing means 104: application reading means 105: application writing means 106: buffering means 107: flag management means 111: communication management program 112: application 120: application buffer 121:
[1]コンピュータを、
処理対象とするイベントを蓄積するイベント蓄積手段と、
前記イベントを蓄積するバッファリング手段と、
前記蓄積したイベントを処理する処理手段と、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段として機能させ、
前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理手段とを含み、
前記フラグ管理手段は、前記処理要求手段がイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理手段の処理の終了後のタイミングでフラグを解除し、
前記処理要求手段は、前記イベント蓄積手段の前記バッファリング手段へのイベント蓄積終了後のタイミング及び前記コールバック処理手段のイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理プログラム。
[2]前記バッファリング手段は、イベントを蓄積する第1のバッファリング手段と、前記第1のバッファリング手段に蓄積された前記イベントを蓄積する第2のバッファリング手段とを有し、
前記処理要求手段は、フラグが立てられた場合に、前記第1のバッファリング手段から前記第2のバッファリング手段に前記イベントを移動して蓄積し、前記第2のバッファリング手段が蓄積している前記イベントの全て又は一部を処理する前記[1]に記載の情報処理プログラム。
[3]前記第1のバッファリング手段と前記第2のバッファリング手段の間、前記第1のバッファリング手段の前段又は前記第2のバッファリング手段の後段に、さらに1以上のバッファリング手段を有する前記[2]に記載の情報処理プログラム。
[4]前記バッファリング手段間の移動において、データブロックのサイズ、個数、タイプ、イベント保持形式の少なくとも1つを変更する前記[2]又は[3]に記載の情報処理プログラム。
[5]前記バッファリング手段間の移動において、移動イベントの数やサイズを予め定めた条件で制限する前記[2]から[4]のいずれか1項に記載の情報処理プログラム。
[6]前記バッファリング手段は、イベント蓄積手段のイベント蓄積動作と、前記処理手段の処理動作とが、非同期に実行される前記[1]から[5]のいずれか1項に記載の情報処理プログラム。
[7]前記バッファリング手段は、並列動作する複数のイベント生成元が実行するそれぞれのイベントの蓄積手段が非同期にイベントを蓄積する前記[1]から[6]のいずれか1項に記載の情報処理プログラム。
[8]前記バッファリング手段は、リングバッファである前記[1]から[7]のいずれか1項に記載の情報処理プログラム。
[9]前記バッファリング手段は、前記イベントそのものをメモリ領域に順次蓄積するリングバッファである前記[1]に記載の情報処理プログラム。
[10]前記バッファリング手段は、2段リングバッファ構成であり、第1段のリングバッファは並列動作するイベント蓄積手段のイベントを蓄積し、第2段のリングバッファは前記処理手段の処理に応じて定められたサイズに当該イベントを連結および分割するとともに前記処理手段に応じて定められた個数保持する前記[2]、[6]又は[7]に記載の情報処理プログラム。
[11]前記バッファリング手段は、ダイレクトバッファに前記イベントを格納することを特徴とする前記[1]、[2]又は[6]から[10]のいずれか1項に記載の情報処理プログラム。
[12]前記バッファリング手段は、バッファプールのバッファに前記イベントを蓄積する前記[1]、[2]又は[6]から[10]のいずれか1項に記載の情報処理プログラム。
[13]前記バッファリング手段は、前記第1段のリングバッファと前記第2段のリングバッファとで、異なるバッファサイズを保持するバッファプールのバッファにイベントを蓄積する前記[10]に記載の情報処理プログラム。
[14]前記処理手段は、蓄積されている前記イベントをすべて処理してからイベント処理を終了する前記[1]から[13]のいずれか1項に記載の情報処理プログラム。
[15]処理対象とするイベントを蓄積するイベント蓄積手段と、
前記イベントを蓄積するバッファリング手段と、
前記蓄積したイベントを処理する処理手段と、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段とを有し、
前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理手段とを含み、
前記フラグ管理手段は、前記処理要求手段がイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理手段の処理の終了後のタイミングでフラグを解除し、
前記処理要求手段は、前記イベント蓄積手段の前記バッファリング手段へのイベント蓄積終了後のタイミング及び前記コールバック処理手段のイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理装置。
[16]コンピュータにおいて実行される情報処理方法であって、
処理対象とするイベントを蓄積するイベント蓄積ステップと、
前記イベントを蓄積するバッファリングステップと、
前記蓄積したイベントを処理する処理ステップと、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理ステップとを有し、
前記処理ステップは、イベントの処理を要求する処理要求ステップと、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理ステップとを含み、
前記フラグ管理ステップは、前記処理要求ステップにおけるイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理ステップにおける処理の終了後のタイミングでフラグを解除し、
前記処理要求ステップは、前記イベント蓄積ステップにおけるイベント蓄積終了後のタイミング及び前記コールバック処理ステップにおけるイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は蓄積した前記イベントを処理する情報処理方法。
[1] a computer,
event accumulation means for accumulating events to be processed;
buffering means for accumulating the events;
a processing means for processing the accumulated events;
act as a flag manager that accepts calls and sets flags exclusively,
The processing means includes processing request means for requesting event processing, and callback processing means for receiving a completion notification and executing when the event processing is completed,
The flag management means sets the flag exclusively before the process request means starts processing the event, and cancels the flag after the process of the callback processing means ends;
The processing request means receives a call at a timing after the event accumulation means finishes accumulating the event in the buffering means and at a timing after the event processing ends for the callback processing means, and responds to the flag of the flag management means. an information processing program for terminating without processing if the flag is not set, and processing the event accumulated by the buffering means if the flag is set.
[2] The buffering means has a first buffering means for accumulating events and a second buffering means for accumulating the events accumulated in the first buffering means,
The processing request means moves and accumulates the event from the first buffering means to the second buffering means when the flag is set, and the second buffering means accumulates the event. The information processing program according to [1], which processes all or part of the event.
[3] One or more buffering means are further provided between the first buffering means and the second buffering means, before the first buffering means, or after the second buffering means. The information processing program according to [2] above.
[4] The information processing program according to [2] or [3], wherein at least one of data block size, number, type, and event holding format is changed in the movement between the buffering means.
[5] The information processing program according to any one of [2] to [4], wherein the number and size of movement events are restricted according to predetermined conditions in movement between the buffering means.
[6] The information processing according to any one of [1] to [5], wherein the event accumulation operation of the event accumulation means and the processing operation of the processing means are executed asynchronously in the buffering means. program.
[7] The information according to any one of [1] to [6], wherein the buffering means asynchronously accumulates events by respective event accumulation means executed by a plurality of event generators operating in parallel. processing program.
[8] The information processing program according to any one of [1] to [7], wherein the buffering means is a ring buffer.
[9] The information processing program according to [1], wherein the buffering means is a ring buffer that sequentially accumulates the event itself in a memory area.
[10] The buffering means has a two-stage ring buffer structure, the first stage ring buffer stores events of the event storage means operating in parallel, and the second stage ring buffer responds to the processing of the processing means. The information processing program according to the above [2], [6], or [7], which connects and divides the event into a size determined by the above and holds the number of events determined according to the processing means.
[11] The information processing program according to any one of [1], [2], or [6] to [10], wherein the buffering means stores the event in a direct buffer.
[12] The information processing program according to any one of [1], [2], or [6] to [10], wherein the buffering means accumulates the event in a buffer of a buffer pool.
[13] The information according to [10], wherein the buffering means accumulates events in buffers of buffer pools holding different buffer sizes for the first stage ring buffer and the second stage ring buffer. processing program.
[14] The information processing program according to any one of [1] to [13], wherein the processing means finishes event processing after processing all the accumulated events.
[15] event accumulation means for accumulating events to be processed;
buffering means for accumulating the events;
a processing means for processing the accumulated events;
a flag management means for accepting calls and setting flags exclusively,
The processing means includes processing request means for requesting event processing, and callback processing means for receiving a completion notification and executing when the event processing is completed,
The flag management means sets the flag exclusively before the process request means starts processing the event, and cancels the flag after the process of the callback processing means ends;
The processing request means receives a call at a timing after the event accumulation means finishes accumulating the event in the buffering means and at a timing after the event processing ends for the callback processing means, and responds to the flag of the flag management means. If the flag is not set, the information processing device ends without processing, and if the flag is set, the event accumulated by the buffering means is processed.
[16] An information processing method executed on a computer, comprising :
an event accumulation step for accumulating events to be processed;
a buffering step of accumulating the events;
a processing step of processing the accumulated events;
a flag management step for accepting and exclusively flagging calls;
The processing step includes a processing request step that requests processing of the event, and a callback processing step that is executed upon receiving a completion notification when processing of the event is completed,
The flag management step exclusively sets the flag at a timing before the start of event processing in the processing request step, and cancels the flag at a timing after the processing in the callback processing step ends,
The process request step accepts a call at the timing after the event accumulation in the event accumulation step ends and the event processing in the callback processing step ends, and if the flag is not set, the process is not performed. an information processing method for processing the accumulated event if set.
Claims (16)
処理対象とするイベントを蓄積するイベント蓄積手段と、
前記イベントを蓄積するバッファリング手段と、
前記蓄積したイベントを処理する処理手段と、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段として機能させ、
前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了し
た場合に完了通知を受けて実行するコールバック処理手段とを含み、
前記フラグ管理手段は、前記イベント処理要求手段がイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理手段の処理の終了後のタイミングでフラグを解除し、
前記処理要求手段は、前記イベント蓄積手段の前記バッファリング手段へのイベント蓄積終了後のタイミング及び前記コールバック処理手段のイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理プログラム。 the computer,
event accumulation means for accumulating events to be processed;
buffering means for accumulating the events;
a processing means for processing the accumulated events;
act as a flag manager that accepts calls and sets flags exclusively,
The processing means includes processing request means for requesting event processing, and callback processing means for receiving a completion notification and executing when the event processing is completed,
The flag management means exclusively sets the flag at a timing before the event processing requesting means starts processing the event, and cancels the flag at the timing after the processing of the callback processing means ends,
The processing request means receives a call at a timing after the event accumulation means finishes accumulating the event in the buffering means and at a timing after the event processing ends for the callback processing means, and responds to the flag of the flag management means. an information processing program for terminating without processing if the flag is not set, and processing the event accumulated by the buffering means if the flag is set.
前記処理要求手段は、フラグが立てられた場合に、前記第1のバッファリング手段から前記第2のバッファリング手段に前記イベントを移動して蓄積し、前記第2のバッファリング手段が蓄積している前記イベントの全て又は一部を処理する請求項1に記載の情報処理プログラム。 The buffering means has a first buffering means for accumulating events and a second buffering means for accumulating the events accumulated in the first buffering means,
The processing request means moves and accumulates the event from the first buffering means to the second buffering means when the flag is set, and the second buffering means accumulates the event. 2. The information processing program according to claim 1, which processes all or part of said events that are present.
前記イベントを蓄積するバッファリング手段と、
前記蓄積したイベントを処理する処理手段と、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段とを有し、
前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了し
た場合に完了通知を受けて実行するコールバック処理手段とを含み、
前記フラグ管理手段は、前記イベント処理要求手段がイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理手段の処理の終了後のタイミングでフラグを解除し、
前記処理要求手段は、前記イベント蓄積手段の前記バッファリング手段へのイベント蓄積終了後のタイミング及び前記コールバック処理手段のイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理装置。 event accumulation means for accumulating events to be processed;
buffering means for accumulating the events;
a processing means for processing the accumulated events;
a flag management means for accepting calls and setting flags exclusively,
The processing means includes processing request means for requesting event processing, and callback processing means for receiving a completion notification and executing when the event processing is completed,
The flag management means exclusively sets the flag at a timing before the event processing requesting means starts processing the event, and cancels the flag at the timing after the processing of the callback processing means ends,
The processing request means receives a call at a timing after the event accumulation means finishes accumulating the event in the buffering means and at a timing after the event processing ends for the callback processing means, and responds to the flag of the flag management means. If the flag is not set, the information processing device ends without processing, and if the flag is set, the event accumulated by the buffering means is processed.
処理対象とするイベントを蓄積するイベント蓄積ステップと、
前記イベントを蓄積するバッファリングステップと、
前記蓄積したイベントを処理する処理ステップと、
呼び出しを受け付けて排他的にフラグを立てるフラグ管理ステップとを有し、
前記処理ステップは、イベントの処理を要求する処理要求ステップと、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理ステップとを含み、
前記フラグ管理ステップは、前記イベント処理要求ステップにおけるイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理ステップにおける処理の終了後のタイミングでフラグを解除し、
前記処理要求ステップは、前記イベント蓄積ステップにおけるイベント蓄積終了後のタイミング及び前記コールバック処理ステップにおけるイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は蓄積した前記イベントを処理する情報処理方法。
the computer,
an event accumulation step for accumulating events to be processed;
a buffering step of accumulating the events;
a processing step of processing the accumulated events;
a flag management step for accepting and exclusively flagging calls;
The processing step includes a processing request step that requests processing of the event, and a callback processing step that is executed upon receiving a completion notification when processing of the event is completed,
The flag management step exclusively sets the flag at a timing before the start of event processing in the event processing request step, and releases the flag at a timing after the processing in the callback processing step ends,
The process request step accepts a call at the timing after the event accumulation in the event accumulation step ends and the event processing in the callback processing step ends, and if the flag is not set, the process is not performed. an information processing method for processing the accumulated event if set.
Priority Applications (6)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2021200032A JP7061301B1 (en) | 2021-12-09 | 2021-12-09 | Information processing program, information processing device and information processing method |
PCT/JP2022/025042 WO2023008008A1 (en) | 2021-07-30 | 2022-06-23 | Information processing program, information processing device, and information processing method |
CN202280004572.XA CN115917519B (en) | 2021-07-30 | 2022-06-23 | Recording medium storing information processing program, information processing apparatus, and information processing method |
KR1020227044708A KR102521873B1 (en) | 2021-07-30 | 2022-06-23 | Information processing program, information processing device, and information processing method |
EP22808933.0A EP4152168A4 (en) | 2021-07-30 | 2022-06-23 | Information processing program, information processing device, and information processing method |
US18/071,627 US11762663B2 (en) | 2021-07-30 | 2022-11-30 | Information processing program, information processing device, and information processing method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2021200032A JP7061301B1 (en) | 2021-12-09 | 2021-12-09 | Information processing program, information processing device and information processing method |
Publications (2)
Publication Number | Publication Date |
---|---|
JP7061301B1 JP7061301B1 (en) | 2022-04-28 |
JP2023085797A true JP2023085797A (en) | 2023-06-21 |
Family
ID=81448191
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2021200032A Active JP7061301B1 (en) | 2021-07-30 | 2021-12-09 | Information processing program, information processing device and information processing method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP7061301B1 (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0962772A (en) * | 1995-08-25 | 1997-03-07 | Oki Electric Ind Co Ltd | Character recognition device |
JP2017062540A (en) * | 2015-09-24 | 2017-03-30 | 富士ゼロックス株式会社 | Uni-directional inter-operating-system communication system, and program |
CN112579097A (en) * | 2020-12-21 | 2021-03-30 | 广州博冠信息科技有限公司 | Software project construction method and device, storage medium and electronic equipment |
CN112667217A (en) * | 2019-10-16 | 2021-04-16 | 上汽通用汽车有限公司 | Vehicle end development module based on intelligent vehicle networking architecture |
-
2021
- 2021-12-09 JP JP2021200032A patent/JP7061301B1/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0962772A (en) * | 1995-08-25 | 1997-03-07 | Oki Electric Ind Co Ltd | Character recognition device |
JP2017062540A (en) * | 2015-09-24 | 2017-03-30 | 富士ゼロックス株式会社 | Uni-directional inter-operating-system communication system, and program |
CN112667217A (en) * | 2019-10-16 | 2021-04-16 | 上汽通用汽车有限公司 | Vehicle end development module based on intelligent vehicle networking architecture |
CN112579097A (en) * | 2020-12-21 | 2021-03-30 | 广州博冠信息科技有限公司 | Software project construction method and device, storage medium and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
JP7061301B1 (en) | 2022-04-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112204513B (en) | Group-based data replication in a multi-tenant storage system | |
US11762581B2 (en) | Method, device, and system for controlling data read/write command in NVMe over fabric architecture | |
US10387202B2 (en) | Quality of service implementation in a networked storage system with hierarchical schedulers | |
US6418478B1 (en) | Pipelined high speed data transfer mechanism | |
EP0891585B1 (en) | A method and apparatus for client managed flow control on a limited memory computer system | |
US11411885B2 (en) | Network-accessible data volume modification | |
CN106874143B (en) | Server backup method and backup system thereof | |
US10037298B2 (en) | Network-accessible data volume modification | |
CN113709131B (en) | Network data transmission method, device, computer equipment and readable medium | |
WO2023008008A1 (en) | Information processing program, information processing device, and information processing method | |
CN110445580B (en) | Data transmission method and device, storage medium, and electronic device | |
US20230281141A1 (en) | Method for order-preserving execution of write request and network device | |
JP2023085797A (en) | Information processing program, information processing device, and information processing method | |
CN108347341A (en) | A kind of acceleration capacity method of adjustment and device for adjusting virtual machine acceleration capacity | |
CN111314249A (en) | Method and server for avoiding data packet loss of 5G data forwarding plane | |
WO2022151766A1 (en) | Io request pipeline processing device, method and system, and storage medium | |
JP6998000B1 (en) | Communication management program, information processing device and communication management method | |
CN111221642A (en) | Data processing method and device, storage medium and terminal | |
CN109478151B (en) | Network accessible data volume modification |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20211215 |
|
A871 | Explanation of circumstances concerning accelerated examination |
Free format text: JAPANESE INTERMEDIATE CODE: A871 Effective date: 20211215 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20220308 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20220317 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20220329 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20220401 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 7061301 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |