WO2023008008A1 - 情報処理プログラム、情報処理装置及び情報処理方法 - Google Patents

情報処理プログラム、情報処理装置及び情報処理方法 Download PDF

Info

Publication number
WO2023008008A1
WO2023008008A1 PCT/JP2022/025042 JP2022025042W WO2023008008A1 WO 2023008008 A1 WO2023008008 A1 WO 2023008008A1 JP 2022025042 W JP2022025042 W JP 2022025042W WO 2023008008 A1 WO2023008008 A1 WO 2023008008A1
Authority
WO
WIPO (PCT)
Prior art keywords
processing
event
buffer
flag
data
Prior art date
Application number
PCT/JP2022/025042
Other languages
English (en)
French (fr)
Inventor
直樹 宮永
Original Assignee
株式会社ソフトギア
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Priority claimed from JP2021125358A external-priority patent/JP6998000B1/ja
Priority claimed from JP2021200032A external-priority patent/JP7061301B1/ja
Application filed by 株式会社ソフトギア filed Critical 株式会社ソフトギア
Priority to CN202280004572.XA priority Critical patent/CN115917519B/zh
Priority to KR1020227044708A priority patent/KR102521873B1/ko
Priority to EP22808933.0A priority patent/EP4152168A4/en
Priority to US18/071,627 priority patent/US11762663B2/en
Publication of WO2023008008A1 publication Critical patent/WO2023008008A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information transfer, e.g. on bus using universal interface adapter
    • G06F13/385Information transfer, e.g. on bus using universal interface adapter for adaptation of a particular data processing system to different peripheral devices
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3802Instruction prefetching
    • G06F9/3808Instruction prefetching for instruction reuse, e.g. trace cache, branch target cache
    • G06F9/381Loop buffering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information transfer, e.g. on bus using universal interface adapter
    • G06F13/387Information transfer, e.g. on bus using universal interface adapter for adaptation of different data processing systems to different peripheral devices, e.g. protocol converters for incompatible systems, open system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4004Coupling between buses
    • G06F13/4027Coupling between buses using bus bridges
    • G06F13/405Coupling between buses using bus bridges where the bridge performs a synchronising function
    • G06F13/4059Coupling between buses using bus bridges where the bridge performs a synchronising function where the synchronisation uses buffers, e.g. for speed matching between buses
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/543Local
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0656Data buffering arrangements

Definitions

  • the present invention relates to an information processing program, an information processing apparatus, and an information processing method.
  • Patent Document 1 As a conventional technology, an information processing device that transmits data by changing the buffer to be used according to the size of the data has been proposed (see Patent Document 1, for example).
  • the CPU (Central Processing Unit) of the information processing device disclosed in Patent Document 1 parallelizes an application task occupying an application buffer area and a TCP (Transmission Control Protocol)/IP (Internet Protocol) task occupying a ring buffer area. execute The application task determines whether the size of the data stored in the application buffer area by the data generation process is equal to or less than a threshold value, and copies the data in the application buffer area to the ring buffer area when the determination result is positive. On the other hand, when the determination result is negative, the right to occupy the application buffer area is temporarily given to the TCP/IP task and the data transmission instruction is issued. The TCP/IP task transmits transmission data on the memory area it occupies in response to the data transmission instruction.
  • TCP Transmission Control Protocol
  • IP Internet Protocol
  • Patent Document 1 transmits data using a ring buffer and performs application tasks in parallel. However, if the amount of data to be sent is large, the application task will be blocked and will not be processed.
  • an object of the present invention is 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • application processing and data transmission can be executed in a non-blocking manner to speed up communication.
  • FIG. 1 is a schematic diagram showing an example of the configuration of a communication management system according to an embodiment.
  • FIG. 2 is a block diagram illustrating a configuration example of a server device according to the embodiment;
  • FIG. 3 is a schematic diagram for explaining an example of data transmission/reception operations.
  • FIG. 4 is a schematic diagram for explaining an example of data transmission operation.
  • FIG. 5 is a schematic diagram showing a modification of the layer configuration.
  • FIG. 6 is a flow chart for explaining an operation example of the socket write request means.
  • FIG. 7 is a flow chart for explaining an operation example of the callback processing means.
  • FIG. 8 is a flow chart for explaining an operation example of the socket write request means.
  • FIG. 9 is a schematic diagram for explaining another example of the data transmission/reception operation.
  • FIG. 9 is a schematic diagram for explaining another example of the data transmission/reception operation.
  • FIG. 10 is a schematic diagram for explaining another example of the data transmission operation.
  • FIG. 11 is a flow chart for explaining another operation example of the socket write request means.
  • FIG. 12 is a flow chart for explaining another operation example of the callback processing means.
  • FIG. 13 is a flow chart for explaining another operation example of the socket write request means.
  • FIG. 1 is a schematic diagram showing an example of the configuration of a communication management system according to an embodiment.
  • This communication management system is configured by connecting a server device 1 as an information processing device and terminal devices 2a, 2b, and 2c as clients of the server device 1 so as to be able to communicate with each other via a network.
  • Devices included in the communication management system may be personal computers, game terminals, clouds, and virtual machines.
  • the network may be a LAN, the Internet, or a virtual network.
  • the server device 1 is a server-type information processing device that operates in response to requests from terminal devices 2a, 2b, and 2c operated by an operator, and has a function for processing information within its main body. Equipped with electronic components such as CPU (Central Processing Unit), HDD (Hard Disk Drive) or flash memory, volatile memory, LAN board (wireless/wired).
  • the server device 1 communicates with the terminal devices 2a, 2b, and 2c to transmit and receive data, thereby synchronizing data handled on the terminal devices 2a, 2b, and 2c, and is, for example, a game server. .
  • the server device 1 frequently exchanges small-capacity data when performing a synchronous operation, but is not limited to this.
  • the server apparatus 1 may be configured by a plurality of clusters, and may be configured to execute distributed processing. Alternatively, it may be configured as a virtual machine in a cloud environment.
  • the terminal devices 2a, 2b, and 2c are terminal-type information processing devices that operate based on programs, and have electronic devices such as CPUs, HDDs, or flash memories that have functions for processing information in their main bodies. Have parts.
  • the terminal devices 2a, 2b, and 2c operate, for example, based on a program such as MMOG (Massively Multiplayer Online Game), and sequentially output data to the server device 1 as a result of the operation. It receives data as a result of terminal operations and synchronizes game objects frequently among the terminal devices 2a, 2b, and 2c.
  • MMOG Massively Multiplayer Online Game
  • terminal devices 2a, 2b, and 2c are depicted as three devices, they may be composed of a single device or two devices, or may be composed of four or more devices, preferably on the order of 1000 units. To provide a configuration capable of communication even when a terminal device is connected.
  • the network 4 is a communication network capable of high-speed communication, for example, a wired or wireless communication network such as an intranet or a LAN (Local Area Network).
  • a wired or wireless communication network such as an intranet or a LAN (Local Area Network).
  • a multiplayer game is executed in which a plurality of participants play an activity, such as a game, in a common virtual space.
  • the server device 1 and the terminal devices 2a, 2b, and 2c operate to synchronize information (synchronized objects) held as objects in each device as the game progresses.
  • 1 provides a buffer between an application and a NIC (Network Interface Card) to speed up data communication and controls the operation of data transfer between the application and the NIC.
  • NIC Network Interface Card
  • buffering is performed in a buffer, exclusive control (blocking) is performed on writing to the buffer, and data is written from the buffer.
  • Blocking is performed on writing to the buffer
  • data is written from the buffer.
  • Write to the shared resource is controlled lock-free (non-blocking) by CAS (Compare and Swap) or the like. Details of the operation will be specifically described in an embodiment.
  • 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.
  • classes and instantiated classes (instances) may be collectively referred to as "objects.”
  • FIG. 2 is a block diagram showing a configuration example of the server device 1 according to the first embodiment. Although the implementation in the server device 1 will be described below, the terminal devices 2a, 2b, and 2c may also have the same configuration.
  • the server device 1 is composed of a CPU (Central Processing Unit) and the like, controls each part, and also includes a control unit 10 that executes various programs, and a storage unit 11 that is composed of a storage medium such as a flash memory and stores information. , a memory 12 configured from a volatile recording medium for temporarily storing information, and a communication section 13 for communicating with the outside via a network.
  • a CPU Central Processing Unit
  • the server device 1 is composed of a CPU (Central Processing Unit) and the like, controls each part, and also includes a control unit 10 that executes various programs, and a storage unit 11 that is composed of a storage medium such as a flash memory and stores information. , a memory 12 configured from a volatile recording medium for temporarily storing information, and a communication section 13 for communicating with the outside via a network.
  • a CPU Central Processing Unit
  • the control unit 10 By executing an OS (Operating System) 110, the control unit 10 functions as an OS executing means 100 (including JVM in the case of Java), and by executing an application 112, an application executing means 103, an application reading means 104, functions as application writing means 105, and executes a communication management program 111 as an information processing program to perform socket reading means 101, socket writing means 102, buffering means 106 (receiving buffer 106a and transmitting buffer 106b). ), and functions as flag management means 107 and the like.
  • OS Operating System
  • the OS execution means 100 executes the OS 110 and provides each function that the OS 110 has.
  • the OS executing means 100 particularly controls the communication unit 13 (NIC) to transmit data to the network and receive data from the network. If JAVA is used, the Java VM is also considered part of the OS and is executed by the OS execution means 100.
  • the application execution means 103 executes the application 112 as a processing means, provides each function of the application 112, and processes a single thread or multiple threads during execution. Typically, each thread communicates through a single or multiple sockets (IP address and port number of the communication target program of the terminal device 2a, 2b, or 2c) respectively corresponding to single or multiple terminal devices. network communication (send/receive).
  • the application reading means 104 reads the data of the receiving buffer 106a corresponding to the receiving socket (terminal device 2a, 2b, or 2c) for receiving processing of the thread.
  • the application writing means 105 writes the data generated as a result of thread processing into the transmission buffer for transmission processing corresponding to the socket (terminal device 2a, 2b, or 2c) to be transmitted.
  • the written data are normally added to the transmission buffer 121b in the order in which they were written.
  • the application writing means 105 receives synchronization information data from the terminal device 2a, processes the received data in a thread, and outputs the data to the terminal device. Synchronization information data is transmitted to the devices 2b and 2c.
  • Application writing means 105 writes data to two transmission buffers 121b corresponding to two sockets corresponding to respective terminal devices. After adding the data to the transmission buffer 121b, the application writing means 105 calls the socket write request means 102a.
  • the socket reading means 101 reads data received by a socket in communication with the network into a reception buffer 106a, which will be described later.
  • the socket writing means 102 as the processing means functions as the socket writing request means 102a as the processing request means and the callback processing means 102b.
  • FIG. 6 and 8 are flowcharts for explaining an example of the operation 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.
  • the socket write requesting means 102a first requests the flag managing means 107 to check the state of the flag managed by the flag managing means 107 (S10). (S11; Yes), set a flag (S12).
  • the socket write requesting means 102a writes the event to the ring buffer 121b immediately before the application writing means 105 finishes writing the event to the ring buffer 121b, and immediately before the completion of the corresponding callback processing means 102b executed after the completion of the socket write requesting means 102a. Called asynchronously from either The call may be a normal method or function call, or may be triggered by signaling to a waiting thread using an OS facility.
  • the socket write request means 102a When the flag is set, the socket write request means 102a next writes the data to be transmitted by communication with the network from the transmission buffer 106b to the socket, and requests the OS execution means 100 to process the event (S13). If the flag managed by the flag management means 107 is already set (S11; No), the process is terminated immediately.
  • the flag checking S10/S11 and the flag changing S12 have been described as three separate blocks.
  • each of the plurality of threads sets a flag (S12), and the own thread executes event processing (S13) as if the flag was set. , the event processing (S13) may be executed multiple times, which is inconvenient.
  • a CAS compute and swap function provided by the flag management means 107 as described later is used.
  • flag inspection (S10/S11) and change setting (S12) are executed by a single CPU command, and other threads are devised so that other threads are not executed between the processing of S10, S11, and S12.
  • the socket write request means 102a checks whether or not there is data to be transmitted in the transmission buffer 106b in step S13 (S30), and if there is data to be transmitted (S30; Yes), An OS asynchronous transmission request is issued to the OS executing means 100 to request event processing (S31). If there is no data to be transmitted (S30; No), socket write request means 102a requests flag management means 107 to clear the flag (S32).
  • 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).
  • 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).
  • the callback processing unit 102b receives a completion notification when the OS execution unit 100 completes the processing of the write event of the socket write request unit 102a (asynchronously) and receives the executed transmission result. If the transmission result is abnormal, perform exception processing such as disconnection or timeout (disconnection, etc.), and terminate. If the transmission result is normal, delete the completed transmission from the transmission buffer. Subsequently, the callback processing means 102b confirms that the transmission target data exists in the transmission buffer, and if the confirmation result is affirmative, calls the socket write request means 102a. If the confirmation result is negative, the flag management means 107 is requested to cancel the flag, and the process ends.
  • exception processing such as disconnection or timeout (disconnection, etc.
  • the buffering means 106 prepares two types of buffer areas in the memory 12, a receive buffer 106a and a transmit buffer 106b, both of which provide targets for reading and writing and manage data to be read and written. By using the buffer, reading and writing to the buffer can be performed asynchronously.
  • the receiving buffer 106 a is written by the socket reading means 101 and read by the application reading means 104 .
  • the transmission buffer 106b is written by the application writing means 105 and read by the socket writing means 102.
  • the buffering means 106 (106a and 106b) reads and writes data in a non-blocking manner. It is inefficient for the CPU to allocate the memory required for the buffer each time it is executed.
  • a ring buffer 121 (a receiving ring buffer 121a as the receiving buffer 106a and a transmitting ring buffer 121b as the transmitting buffer 106b), which is a kind of buffer pool, is used as the buffer area will be described, but the ring buffer is not necessarily used. There is no need, any buffer that can logically provide an infinite length buffer can be used.
  • a direct buffer suitable for processing in the OS kernel is created in a memory area outside the heap area, enabling high-speed input/output. temporary storage area.
  • 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.
  • 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.
  • 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. Also, memory fragmentation can be avoided by reusing memory blocks of a standardized chunk size.
  • 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.
  • various design policies can be considered for the size, type, and number of memory chunks registered in the pool, depending on the application.
  • 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.
  • a large size e.g., page size
  • the OS is able to handle the event data rather than holding each very small size event data in a separate chunk.
  • AsynchronousSocketChannel 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 processing efficiency in the OS.
  • the chunk size adopts a single size such as the page size or half thereof, more specifically 1 KB or 2 KB.
  • 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.
  • the flag management means 107 manages flags atomically by means of, for example, CAS (Compare and Swap).
  • 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 flag management unit 107 sets a flag exclusively at the timing when the OS execution unit 100 starts event processing in response to a request from the socket write request unit 102a (FIG. 6, S12), and sets the flag at the timing of completion of event processing (callback The flag is cleared in the process of the processing means 102b (S23 in FIG. 7). Incidentally, even though the flag is cleared in S32 of FIG.
  • the flag is raised at the timing of starting the event processing, but this is (exception) processing when there is no data for the event processing.
  • the socket write request means 102a and the callback processing means 102b are limited to one socket write request means 102a and one callback processing means 102b by the function of the flag management means 107. Concurrency is controlled to ensure consistency of write operations to sockets. If the flagged socket write request means 102a or the callback processing means 102b corresponding to the socket write request means 102a is in process, calling the second and subsequent socket write request means 102a Since the flag itself cannot be set while the flag is set, the process is interrupted and ends without writing to the OS execution means 100 (S11 in FIG.
  • the socket write request means 102a cannot necessarily execute an asynchronous transmission call to the OS for its own event, but executes it in a non-blocking manner and ends processing without waiting until the event can be transmitted. Even if the socket write request means 102a itself cannot execute the asynchronous send call, the socket write means 102 (socket write request means 102a or callback processing means 102b) in execution will execute the asynchronous send call in the near future. execute That is, for an event for which processing by the socket write request means 102a has ended without the asynchronous transmission call being executed, the flag has already been set depending on the timing at which the event was accumulated in the first buffer 121b1.
  • Socket write request means 102a called by the socket write request means 102a itself or the callback processing means 102b corresponding to the socket write request means 102a, which is currently being executed exclusively, later when the transmission buffer is not empty. makes an asynchronous send call.
  • the operation of flags enclosed by dotted lines steps S10, S11, and S12 for status confirmation and setting
  • the (Compare and Swap) function provided by the flag management means 107 is used.
  • the storage unit 11 stores an OS 110, a communication management program 111, an application 112, etc., which causes the control unit 10 to operate as each means 100 to 107 described above. It should be noted that the objects for functioning as the means 100 to 107 may be performed by appropriately replacing the OS 110, the communication management program 111, and the application 112. FIG. Also, the storage unit uses a relational database, a file system, or the like. For speeding up, an in-memory database such as Redis may be used or used together.
  • the memory 12 is controlled by the buffering means 106 and other means (not shown) to temporarily store information.
  • terminal devices 2a, 2b, and 2c have the same configuration as the server device 1, and also include an operation unit and a display unit. A description of the parts that have the same configuration as the server device 1 will be omitted.
  • the participant management means (not shown) of the server device 1 Upon receiving a room participation request, the participant management means (not shown) of the server device 1 sends a participation request associated with the room ID in the storage unit 11 to the participant along with the user ID, user name, socket ID, participation date and time. recorded in the user management information.
  • the terminal devices 2a, 2b, and 2c sequentially generate, update, and delete multiple objects (characters, weapons, items, etc.) as applications are executed.
  • the server device 1 accepts and processes object operation requests from the terminal devices 2a, 2b, and 2c, and notifies the terminal devices 2a, 2b, and 2c of the processing results so that the objects can be processed. Synchronize.
  • the server device 1 performs a relay operation for synchronizing the objects in the terminal devices 2a, 2b, and 2c. In the relay operation, the server device 1 transmits and receives a plurality of objects.
  • the server device receives from the terminal devices 2a, 2b, and 2c information regarding the operations of the plurality of objects operated by each of them, and transmits information regarding the manipulation of the plurality of objects corresponding to the terminal devices to be synchronized. .
  • the size of individual object operation information is small, frequent data synchronization (at least about 20 to 30 times per second) is required to achieve smooth object drawing in each of the terminal devices 2a, 2b, and 2c. If there are many objects to be synchronized in a sophisticated game, or if there are many terminal devices to be synchronized such as MMOG, the number of sending and receiving packets for synchronization processed by the server will be huge like streaming sending and receiving due to combinatorial explosion. sell.
  • the present invention realizes efficient use of network transmission, a method of using a NIC level that is always processing and has as little idle time as possible, and an implementation using Java, in particular, that improves socket utilization during transmission. The details of the transmission/reception operation of the server device 1 will be described below.
  • FIG. 3 is a schematic diagram for explaining an example of data transmission/reception operations.
  • the socket reading means 101 receives data from the source 131 of the network 4 via the channel 130, and the socket reading means 101 reads the socket corresponding to the channel (with an IP address corresponding to the receiving terminal device). port) and writes it to the position of the write pointer in the reception ring buffer 121a.
  • the data is added to receive ring buffer 121a.
  • Separate buffers are prepared for each channel or socket. A channel/socket is used for both transmission and reception, and one channel/socket is prepared for each corresponding terminal device (a specific program with which the terminal device communicates).
  • One application buffer is shown in the drawing, but in practice, it is managed separately for transmission and reception.
  • the ring buffer 121 is managed as one pool for all channels, and although one is shown in the figure, the ring buffer 121 manages independent pointers for each channel and for transmission and reception separately. , and separate reception ring buffer 121a and transmission ring buffer 121b for each channel.
  • 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 application buffer 120 .
  • Data is retrieved from the receive ring buffer 121a and removed from the receive ring buffer 121a.
  • the application buffer 120 is independently managed by the application and not provided by the buffering means 106 .
  • the app buffer is provided by another buffering means.
  • OS functions normal memory allocation, memory release
  • another buffering means may be configured so as to provide a function equivalent to the buffering means 106 to provide an application buffer.
  • the application execution means 103 reads data from the application buffer 120 and processes it in a thread.
  • the application execution means 103 when transmitting data processed by the thread of the application execution means 103 to the network 4 , the application execution means 103 writes the data processed by the thread to the application buffer 120 .
  • the application writing means 105 writes the write pointer of the transmission ring buffer 121b corresponding to the destination terminal device, more precisely, the channel or socket, according to the destination terminal device for which the data in the application buffer 120 is intended. write to the position of As a result, the data is added to the transmission ring buffer 121b. After the data is written, the write pointer is advanced to move to the position next to the write end position. When the application writing means 105 writes data next time, the write pointer after movement is used, so the data to be written next time is added after the data written this time. On the other hand, the data in the application buffer 120 becomes unnecessary after being copied to the transmission ring buffer 121, and the application executing means 103 can reuse this buffer area.
  • the transmission ring buffer 121b is prepared for each channel or socket.
  • the socket writing means 102 reads the data from the position of the read pointer in the transmission ring buffer 121b to the position just before the position of the write pointer, and writes it to the channel 130 by means of the socket. Data is transmitted to source 131 via channel 130 .
  • the read pointer advances by the number of bytes successfully transmitted and moves to the location next to the data that has been successfully transmitted.
  • the data is taken out from the transmission ring buffer 121b, and the OS executing means 100 performs transmission processing as a transmission object, and the data that has been transmitted (all or part of the data taken out) is excluded from the transmission ring buffer 121b. be done. Data for which transmission has not been completed continues to remain in the transmission ring buffer 121b.
  • the ring buffer 121 is a ring buffer that sequentially writes (accumulates) data (events) in a memory area (or a virtually continuous memory area) and directly stores read data.
  • the data to be managed is arranged and stored (directly storing the data to be managed) in the memory area in order.
  • This ring buffer 121 does not store (indirectly store data to be managed) pointers to the stored memory as write or read pointers in a memory area (or virtually continuous memory area). .
  • the ring buffer 121 loses the boundaries of the write units of data (events) by writing, if it is necessary to process data (events), boundary information must be managed separately.
  • data processing is network transmission by the OS kernel, it is transmitted as a byte stream regardless of data (event) boundaries, so data (event) boundaries are not managed. You don't have to. Also, in cases where the same effect as in the first embodiment can be obtained, the use of other virtual ring buffers is not barred.
  • FIG. 4 is a schematic diagram for explaining an example of data transmission operation.
  • the application execution means 103 processes data by a plurality of threads 1 and 2, and transmits data A and data B as processing results to the same terminal device (more precisely, the same socket or channel). Then, the application writing means 105 writes to the transmission ring buffer 121b corresponding to the socket for communication to the destination terminal.
  • each means of the present invention is required for each channel. It is assumed that processing of threads 1 and 2 occurs asynchronously under a multithread environment.
  • Application writing means 105 performs blocking control so that data A and data B are written at maximum one data per channel, and application writing means 105 writes data A of thread 1 to transmission ring buffer 121b. During this time, the write processing of data B of thread 2 is made to wait.
  • the thread 1 waits for the data C writing process.
  • Writing to the transmission ring buffer 121b starts from the position of the write pointer, and when writing ends, the write pointer is moved next to the write end position.
  • a non-blocking buffer is adopted as the transmission buffer 106b that performs blocking control so that write operations between threads are not mixed in the transmission ring buffer 121b, then the application writing means 105 work efficiently.
  • the write pointer and read pointer of the transmission ring buffer 121b are assigned to a thread for writing (application writing means 105) and a thread for reading (socket), of which at most one is active at a given time. Since the writing means 102) operates exclusively, writing (application writing means 105) and reading (socket writing means 102) can be performed non-blocking and asynchronously.
  • 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 transmission ring buffer 121b (the data from the read pointer to the point immediately before the write pointer at the time of calling) is transmitted. At this point, only data A is stored in the transmission ring buffer 121b. The socket write request means 102a requests the OS execution means 100 (OS kernel) to write the data A in the transmission ring buffer 121, and terminates (1).
  • OS system call for example, AsynchronousSocketChannel.write() of JAVA.
  • the OS kernel 100 determines an appropriate size for the data A (the size is, for example, a network-dependent maximum packet size MTU (Maximum Transmission Unit; for Ethernet, the MTU is 1500 bytes) and various protocol headers. Typically, in the case of TCP/IP on Ethernet, it is divided into MSS (Maximum Segment Size) 1460 bytes, which is obtained by subtracting 20 bytes of TCP header and 20 bytes of IP header, and transmitted to network 4 as data A1 and A2. do. If data B is written from the application writing means 105 to the transmission ring buffer 121b during the event processing of the OS kernel 100, the transmission ring buffer 121b will not be able to store the data B even while the OS kernel 100 is reading. is accumulated non-blocking.
  • MTU Maximum Transmission Unit
  • MSS Maximum Segment Size
  • Application writing means 105 continues to call socket write request means 102a, but socket write request means 102a is processing data A and the CAS flag of flag management means 107 is set. The process ends immediately in a non-blocking manner without transmitting data B (2). Thread 2 can execute the next process without waiting for completion of the relatively long network transmission process (event process of OS kernel 100). At this point, data B is added to the transmission ring buffer 121b, and data A and data B are present.
  • the OS kernel 100 activates the callback processing means 102b and notifies the transmission completion.
  • the callback processing means 102b confirms the number of bytes that have been transmitted. In this case, the transmission of the entire data A has been completed. Exclude from ring buffer 121b.
  • the callback processing means 102b clears the CAS flag of the flag management means 107.
  • FIG. At this point, the transmission ring buffer 121b has data A removed and only data B exists.
  • callback processing means 102b determines whether there is still data to be transmitted in transmission ring buffer 121b (if the read pointer and write pointer match, there is no data to be transmitted). If there is data to be sent, the socket write request means 102a is called. If there is no data to send, terminate. In this case, since the data B already exists in the transmission ring buffer 121b, the socket write request means 102a is called (3).
  • 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 transmission ring buffer 121b (the data from the read pointer to the point immediately before the write pointer at the time of calling). At this point, only data B is accumulated in the transmission ring buffer 121b.
  • the socket write request means 102a requests the OS kernel 100 to write the data B in the transmission ring buffer 121b, and terminates.
  • the OS kernel 100 divides the data B into appropriate sizes and transmits them to the network 4 as data B1, B2, and B3.
  • the transmission ring buffer 121b accumulates the data C in a non-blocking manner and calls the socket write request means 102a.
  • the write means 102 is processing the data B requested to the OS by the immediately preceding socket write request means 102a, and since the CAS flag of the flag management means 107 is set, the socket write request means 102a does not send the data C. Terminate immediately without requesting the OS kernel 100 (4).
  • the ring buffer 121 accumulates the data D in a non-blocking manner and calls the socket write request means 102a. Since the CAS flag of the flag management means 107 is set during the processing of B, the socket write request means 102a immediately terminates without transmitting the data D (5). At this point, data B, data C, and data D are stored in order in the transmission ring buffer 121b.
  • the OS kernel 100 activates the callback processing means 102b and notifies the transmission completion.
  • the callback processing means 102b first confirms that the number of transmission completion bytes is the entire data B, and then sets the read pointer of the transmission ring buffer 121b to the position next to the data B (the head of the data C in this case). Moving. At this time, the transmission ring buffer 121b stores data C and data D with data B excluded. The callback processing means 102b next clears the CAS flag of the flag management means 107, and then confirms that the transmission ring buffer 121b is not empty (in this case, data C and data D are accumulated). After confirmation, the socket write request means 102a is called.
  • 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 buffer 121b are written to the OS kernel 100 (6).
  • the OS kernel 100 divides the data C and data D into appropriate sizes and transmits them to the network 4 as data C1, C2, C3, .
  • the transmission ring buffer 121b accumulates the data E in a non-blocking manner. Since the CAS flag of the management means 107 is set, the socket write request means 102a terminates without transmitting the data E (7).
  • the transmission ring buffer 121b accumulates the data F in a non-blocking manner (8). At this point, the transmission ring buffer 121b has accumulated data C, data D, data E, and data F.
  • the OS kernel 100 completes the transmission of the data C, it happens to start the callback processing means 102b without executing the processing of D this time, and notifies the transmission completion.
  • the OS system call (AsynchronousSocketChannel.write()) does not always guarantee to complete the transmission of all requested data. Only part of the requested data may be sent for reasons such as the OS or network load. Therefore, confirmation of the number of bytes that have been transmitted is essential.
  • this system call provides a gathering write function for specifying multiple buffers (memory chunks) and collectively sending them in one system call. Therefore, even if C and D are not a continuous single memory chunk, but two or more memory chunks, a transmission request can be made with one system call.
  • the aggregate transmission of the OS tries to transmit the specified chunks in order, but depending on the circumstances of the OS, all the specified chunks may be sent, or only some chunks of the specified chunks may be sent.
  • the partial chunk may be the entire partial chunk of a plurality of chunks, or the last chunk may be only the first part of the chunk and may be left unsent.
  • the callback processing means 102b clears the CAS flag of the flag management means 107.
  • the callback processing means 102b sends data to the transmission ring buffer 121b.
  • data in this case, data D, data E, and data F
  • the socket write request means 102a is called.
  • 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 kernel 100 for all the data DEF in the buffer 121b (9).
  • the OS kernel 100 divides the data DEF into appropriate sizes and transmits them to the network 4 as data D1, D2, .
  • the OS kernel 100 when the OS kernel 100 happens to complete the transmission of only the data D, it activates the callback processing means 102b and notifies the transmission completion.
  • the callback processing means 102b confirms the number of transmitted bytes, it happens that only the data D has been transmitted. Since the flag is cleared and the transmission ring buffer is not empty, the socket write request means 102a is called.
  • 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 kernel 100 is requested to write the data EF of 121 (10).
  • the OS kernel 100 divides the data EF into appropriate sizes and transmits them to the network 4 as data E, F1, and F2.
  • the OS kernel 100 transmits the data E and F, it activates the callback processing means 102b and notifies the transmission completion.
  • the callback processing means 102b confirms the number of bytes that have been transmitted, moves the read pointer of the transmission ring buffer 121b to the position next to the data F, and clears the CAS flag of the flag management means 107.
  • FIG. The callback processing means 102b terminates the processing when the transmission ring buffer 121b becomes empty (the read pointer and the write pointer match).
  • data A to F are illustrated as large data that are each transmitted as one or more network packets for ease of explanation.
  • 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.
  • the transmission channel can be efficiently operated without interruption, which is particularly useful in a mode of use such as streaming.
  • the transmission ring buffer 121b is provided between the application writing means 105 and the socket writing means 102, and the transmission ring buffer 121b accumulates the data written by the application writing means 105 in a non-blocking manner.
  • the write operation of the socket write request means 102a is executed according to the CAS flag
  • the CAS flag is managed by the flag management means 107
  • the flag is set when the socket write request means 102a starts writing
  • the OS execution means 100 The flag is cleared by the callback processing means 102b upon receiving the event processing completion notification, so that the writing operation of the application writing means 105 does not directly affect the transmission event processing operation of the OS execution means 100.
  • the waiting time for the application writing means 105 and the OS execution means 100 to correspond to each other is eliminated, and the number of calls for each is reduced.
  • application processing and data transmission are executed in a non-blocking manner for high-speed communication.
  • transmission processing to the network which takes a relatively long time, is performed with a short wait time (latency), continuous processing as much as possible, and non-blocking, giving priority to network transmission processing, increasing transmission throughput, and asynchronous transmission ( Application processing can be executed during the waiting time for NIO) processing.
  • OS resources total amount of memory, number of threads, number of OS function calls
  • OS resources total amount of memory, number of threads, number of OS function calls
  • it can be operated with more compact server specifications, which reduces operating costs.
  • 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.
  • 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.
  • the ring buffer 121 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 buffer 121B (see FIG. 9), the buffering means 106 stores not only the ring buffer 121b (see FIG. 4) but also the first buffer 121b1 and the second buffer 121b as transmission buffers in the memory 12. 2 (see FIG. 10) is different from the first embodiment.
  • the first buffer 121b_1 accepts writing of an event generated as a result of the processing of the thread 103 by the application writing means 105
  • the second buffer 121b_2 accepts the socket writing means 102a. accepts writing of a set of data written for each thread to the first buffer 121b1.
  • the first buffer 121b1 considers a standard event size and stores events in chunks so that chunks are not often left unused.
  • the chunk size is calculated and designed using various existing optimization algorithms, etc.
  • the event is held in a standardized chunk of 256 bytes (if the event size is larger than 256 bytes, it is held in multiple chunks). It is assumed that multiple items are retained.
  • Chunks are managed by a buffer pool, and assuming that the buffer pool is shared by a plurality of channels, if 4096 chunks are prepared as an initial value, the total is 1 MB. If the buffer pool runs short, it is desirable to have a configuration that can be expanded by allocating additional memory chunks. Also, sharing a buffer pool with multiple channels means that different channels and different sockets are used for different destinations, so the present invention will focus on the operation of a single channel, but the same applies to other channels as well. , but if the buffer pools that provide memory chunks to each buffering means are centrally managed, compared to the case where each channel holds an individual buffer pool, Since duplication of memory allocation is eliminated and memory can be accommodated between channels, the total memory allocated as a buffer pool can be saved.
  • the second buffer 121b2 is used for event processing in the OS.
  • the second buffer 121b2 holds transmission data to be processed in normalized chunks of 2048 bytes, considering the page size, which is the preferred data processing size of the OS. Assuming that chunks are managed by a buffer pool and that the buffer pool is shared by a plurality of channels, if 4096 chunks are prepared as an initial value, the total is 8 MB. As with the buffer pool of the first buffer 121b1, when the buffer pool runs short, it is desirable to have a configuration that can be expanded by allocating additional memory chunks.
  • the chunk capacity and the number of chunks of the first buffer 121b- 1 and the second buffer 121b- 2 are appropriately set according to the communication environment and system specifications, and are not limited to the values shown as examples. .
  • the size of the memory chunks is the page size of the server device 1, or 2 of the page size, considering memory boundaries. It is desirable for the efficiency of the memory system to choose from 1/th of a power of , and an arbitrary number of bytes such as 50 bytes or 100 bytes should not be chosen. Also, if a direct buffer suitable for processing in the OS is used as the second buffer, the transmission processing efficiency in the OS will be improved.
  • 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.
  • the application writing means 105 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 intermediate buffer 121B.
  • the callback processing means of the already executing socket writing means 102 continues until there are no more events held by the intermediate buffer 121B. Call the socket writer. This shortens the average processing speed of the application writing means 105 and improves the efficiency of parallel processing of the threads 103 of the application.
  • the first embodiment also applies the usage of the flag management means 107 (the operation of the socket write request means 102a and the callback processing means 102b) emphasizing the parallel operation efficiency of the transmission threads of the application shown in the second embodiment.
  • the usage of the flag management means 107 emphasizing the transmission processing efficiency of the OS shown in the first embodiment (socket write request means 102a and callback processing action of means 102b) can also be applied.
  • the flag management method is not limited to these two types of methods, and other methods for performing event addition and event processing in a non-blocking and asynchronous manner may be used.
  • FIG. 11 and 13 are flowcharts for explaining an example of the operation 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.
  • the socket write request unit 102a confirms the caller (S40), and if the caller is the application write unit 105 (call after adding the event to the first buffer) (S40 Yes), the flag management means 107 is requested to check the state of the flag managed by the flag management means 107 (S41), and if the flag is cleared (S42; Yes), the flag is set (S43). Socket write request means 102a writes an event immediately before application write means 105 writes an event to ring buffer 121b and immediately before termination of corresponding callback processing means 102b executed after socket write request means 102a ends.
  • the call may be a normal method or function call, or may be triggered by signaling to a waiting thread using an OS facility.
  • the flag management means is used to determine whether or not it is possible to request event processing to the OS execution means.
  • the OS execution means is requested to process the event without setting the flag again.
  • the simplest way to notify the caller is to include the caller identifier in the call parameters, but any other method is acceptable. If the flag is set in the former case, then the socket write request means 102a requests the OS execution means 100 to process the event (S44).
  • the process is terminated immediately.
  • the socket write request unit 102a responds to the execution of the callback processing unit 102b. Since the flag has already been set when the socket write request means 102a was executed immediately before, the OS execution means 100 is requested to process the event regardless of the state of the flag (S44). As described above, similarly to FIG.
  • step S44 the socket write request means 102a checks whether there is data to be transmitted in the first buffer 121b1 (S60), and if there is data to be transmitted (S60; Yes), the first If necessary, the event on the buffer 121b- 1 in the buffer 121b-1 is moved to the second buffer 121b- 2 (S61). If the data is simply moved, this step can be omitted and the OS asynchronous send call S63 can be executed immediately for the data in the first buffer.
  • some kind of performance improvement is expected in the move operation, such as changing the memory type of the buffer, changing the memory size of the buffer, changing the arrangement of data in the buffer, the number of moves (number of move events, or , the number of bytes moved), etc., and copies the event held in the memory chunk of the first buffer to the newly allocated memory chunk of the second buffer, and after the copy of the first buffer is completed Release unnecessary memory chunks.
  • the OS uses the second buffer for processing (S63) as described later, so it is better to use a direct buffer suitable for OS processing.
  • 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.
  • All the events held in the first buffer 121b- 1 may be simply moved to the second buffer 121b- 2 at the timing of the transfer.
  • the second buffer uses the direct buffer used for OS processing, and that there is an upper limit to the number of memory chunks and the total number of bytes that can be processed at once by the OS processing request, the usage of the direct buffer is To do this, the number of moving events should be controlled so that the memory chunks held by the second receiving buffer are less than or equal to the size appropriate for the OS processing requirements. For example, an upper limit such as 32 is set for the number of direct buffer memory chunks held by the second buffer.
  • 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.
  • all or part of other measures for improving performance are implemented in order to improve the efficiency of event processing in the subsequent OS.
  • 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.
  • movement is not limited to event-based movement.
  • 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).
  • step S62 If there is no data to be transmitted in the first buffer 121b1 (S60; No), the process proceeds to step S62.
  • 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 write requesting means 102a.
  • the application writing means 105 is asynchronously called by the threads 103 operating in parallel and accumulates events in the first buffer 121b1 in a non-blocking manner.
  • a queue provided by Java java.util.concurrent.ConcurrentLinkedQueue
  • a FIFO buffer that manages pointers to memory chunks is used. Efficient ring buffers can be implemented by reusing memory chunks managed by the buffer pool.
  • the buffer pool memory chunk should be normalized to a memory size slightly larger than the typical event size. Large events that do not fit in memory chunks are stored in multiple chunks. The chunk size is adjusted to be 1/2 power of the page size.
  • the second buffer 121b- 2 can also use a FIFO queue (for example, java.util.concurrent.ConcurrentLinkedQueue) that holds pointers to memory chunks storing event information.
  • the socket write request means 102a issues an OS asynchronous transmission request to the OS execution means 100 to request event processing ( S63). For example, Java's AsynchronousSocketChannel. Call write( ) gathering write to send multiple memory chunks to request processing of multiple events in one call. If there is no data to be transmitted in the second buffer 121b2 (S62; No), the socket write request means 102a requests the flag management means 107 to clear the flag (S64). After confirming that there is no data in the first buffer 121b1 (S60), it is confirmed that there is no data in the second buffer 121b2 (S62).
  • OS asynchronous transmission request For example, Java's AsynchronousSocketChannel. Call write( ) gathering write to send multiple memory chunks to request processing of multiple events in one call.
  • the socket write request means 102a requests the flag management means 107 to clear the flag (S64). After confirming that there is no data in the first buffer 121b1 (S60), it is confirmed that there is no data in the
  • 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 exception processing (disconnection, etc.) such as disconnection of communication or timeout (S54).
  • FIG. 9 is a schematic diagram for explaining an example of data transmission/reception operations according to the second embodiment.
  • the socket reading means 101 receives data from the source 131 of the network 4 via the channel 130 and the socket corresponding to the channel (corresponding to the receiving terminal device).
  • a port with a certain IP address) is read and written to the intermediate buffer 121B.
  • Data is added to intermediate buffer 121B.
  • Separate buffers are prepared for each channel or socket.
  • a channel/socket is used for both transmission and reception, and one channel/socket is prepared for each corresponding terminal device (a specific program with which the terminal device communicates).
  • One application buffer is shown in the drawing, but in practice, it is managed separately for transmission and reception.
  • the intermediate buffer 121B is managed as one buffer pool for all channels. , as a transmission intermediate buffer.
  • the subsequent write operation to the application buffer 120 is omitted because it is common to the first embodiment.
  • the application execution means 103 reads the data in the application buffer 120 and processes it in the thread.
  • the application execution means 103 when transmitting data processed by the thread of the application execution means 103 to the network 4 , the application execution means 103 writes the data processed by the thread to the application buffer 120 .
  • the case where the application writing means 105 performs multithread parallel processing will be mainly described.
  • the application writing means 105 writes an intermediate buffer 121B, in particular the first buffer 121b 1 , corresponding to the destination terminal device, more precisely to the channel or socket. per thread.
  • the first buffer 121b1 data are sequentially written in areas prepared for each thread.
  • the application writing means 105 writes data (process result events) to the intermediate buffer 121B in a non-blocking manner.
  • the socket writing means 102 sequentially moves data from the first buffer 121b- 1 to the second buffer 121b- 2 at arbitrary timing.
  • Moving refers not only to literally moving a memory chunk holding data between buffers, from the first buffer 121b 1 to the second buffer 121b 2 , but also to copying the target data to the second buffer and then moving it to the second buffer. 1 includes the case of deleting from the buffer.
  • movement is not limited to simple one-to-one movement, but can be used to change the buffer type, memory chunk size, arrangement method within the memory chunk, adjust the number of events to be moved, or change the number of events to be moved. It also includes conversion into a data retention form that is easy for execution means to process.
  • the number of buffers such as the third buffer and the fourth buffer may be increased.
  • memory chunks that hold data can be managed in a buffer pool that reuses pre-allocated memory.
  • a buffer pool can also be shared by the first buffer and the second buffer.
  • a single buffer pool can also be shared even when multiple channels manage their own buffers.
  • a buffer pool often holds one or more types of standardized size memory chunks. Since the buffer pool uses the memory allocated from the system when the communication management program is started, allocation and freeing of memory using the buffer pool memory does not involve system calls, and the processing is light. , and does not cause system memory fragmentation.
  • the buffer pool secures an appropriate amount at startup, but if there is a shortage during execution, or when the shortage is predicted, the OS will be overloaded, so if possible, It is preferable to make a request to the OS to secure additional memory and expand the buffer pool at an appropriate time.
  • the types of memory chunks secured by the buffer pool and the size of the chunks are appropriately tuned according to the usage pattern.
  • a single size for example, 256 bytes
  • slightly larger than the average event size is selected from the non-direct buffer managed by the normal heap.
  • a direct buffer of a size and type that is easy for the OS to handle such as a page size or a half of the page size (eg, 2 KB) is selected.
  • the buffers obtained from the OS are used in small portions, so the page size or a value divided by a power of 2 of the page size should be used with the page size and memory boundaries in mind. , do not adopt arbitrary values such as 25 bytes or 50 bytes.
  • the next timing of moving from the first buffer to the second buffer may be every predetermined time interval, or the first buffer 121b- 1 or the chunk stored in the first buffer 121b- 1 . It may be when the amount of data reaches a predetermined amount, or when the number of chunk-accumulated events in the first buffer 121b- 1 or in the first buffer 121b- 1 reaches a predetermined number. There may be.
  • 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 .
  • 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.
  • multiple operations chunk memory type change, chunk size change, movement amount limit, etc.
  • the operations were divided and the intermediate results were stored as additional buffers. can be considered.
  • the movement timing and trigger may be the same for all stages.
  • the socket writing means 102 reads the data in the second buffer 121b2 and writes it to the channel 130 by means of the socket. Data is transmitted to source 131 via channel 130 . At this time, the data is taken out from the second buffer 121b2, and the OS executing means 100 performs transmission processing as a transmission target. 121b2 . Data for which transmission has not been completed will continue to remain in the second buffer 121b2. Here, all the data accumulated in the second buffer 121b2 is transmitted at once. Control may be performed to read and transmit only a portion of the data, instead of reading all at once, for example, in consideration of restrictions. Alternatively, the number of events and the number of bytes transferred from the first buffer 121b- 1 to the second buffer 121b- 2 are limited in advance so that the data accumulated in the second buffer 121b- 2 does not become huge. good too.
  • FIG. 10 is a schematic diagram for explaining an example of data transmission operation.
  • Thread 1 and thread 2 asynchronously generate events A, C, F and events B, D, E, respectively, and call application writing means 105 and socket write request means 102a, and generate events A to F, respectively. to the network 4.
  • Application writing means 105 adds one event generated by thread 1 and thread 2 to first buffer 121b1 and calls socket writing means 102a. If the OS kernel 100 is already executing event processing, the socket writing means 102a terminates without processing. It moves zero or more events to the second buffer 121b2, and requests the OS kernel 100 to process the events held in the second buffer 121b2.
  • the state of whether the OS kernel 100 is processing an event is managed by a CAS flag provided by the flag management means 107 .
  • the callback thread executes the callback processing means 102b asynchronously with both thread 1 and thread 2.
  • FIG. The callback thread confirms the progress of event processing and adjusts the second buffer 121b2 (deleting the processed event from the second buffer or transferring the event from the first buffer to the second buffer). ) to recursively and exclusively call the socket writing means a, and process the events accumulated in the first buffer 121b1 during processing by the OS kernel 100 as well.
  • the callback thread repeats the processes of the socket write request means 102a and the callback processing means 102b until there are no more events held by the intermediate buffer 121B (that is, the first buffer 121b 1 and the second buffer 121b 2 ). operate.
  • the application execution means 103 processes data by a plurality of threads 1 and 2, and transmits event A and event B as processing results to the same terminal device (more precisely, the same socket or channel). Then, the event A and event B are written by the application writing means 105 to the first buffer 121b1 corresponding to the socket for communication to the destination terminal. It is assumed that processing of threads 1 and 2 occurs asynchronously.
  • the first buffer 121b 1 is, for example, a thread-safe, non-blocking ring buffer (for example, it can be realized by registering a pointer to a memory chunk storing an event in a non-blocking, thread-safe FIFO queue java.util.ConcurrentLinkedQueue). .
  • the application writing unit 105 writes events A and B in non-blocking areas (chunks) that are different for each thread (1) and (2).
  • the memory chunks can be, for example, java. nio.
  • the ByteBuffer is also used to manage the start and end positions of the stored events. Also, when storing events in memory chunks of a normalized size, for events larger than the chunk size, events may be stored in chunk groups spanning multiple chunks, and a pointer to the chunk group may be added to the ring buffer. .
  • application writing means 105 calls socket writing request means 102a to request processing of event A of first buffer 121b1 (3). Since the caller is the application writing unit 105, the socket write request unit 102a refers to the CAS flag of the flag management unit 107. Since the flag is not set, the socket write request unit 102a sets the flag (4), and writes the first buffer 121b1. , and since there is an event, event A in the first buffer 121b-1 is moved to the second buffer 121b- 2 (5).
  • the second buffer 121b 2 similarly to the first buffer 121b 1 , the second buffer 121b 2 also stores pointers of memory chunks for storing events in, for example, non-blocking ring buffers (for example, non-blocking and thread-safe FIFO queues java.util.ConcurrentLinkedQueue). can be realized by registering). However, since the number of threads that operate the second buffer is limited to one at most by the flag management means 107, it does not have to be thread-safe.
  • the socket write request means 102a calls the thread 1 to proceed with the next process, and leaves the process to the OS kernel 100 (6). The processing ends without waiting for the processing of the kernel 100 to be completed, and the processing of the thread 1 is returned to (7).
  • socket write requester 102a For event B of thread 2, application writer 105 calls socket write requester 102a to request processing of event B of first buffer 121b1 (8). Since the caller is the application writing means 105, the socket write request means 102a refers to the CAS flag of the flag management means 107 (9). (4) so it is no longer flagged. The socket write request means 102a does not wait until processing becomes possible, ends processing in a non-blocking manner, and returns to the processing of thread 2 (10).
  • the application executing means 103 continues to process data, and the application writing means 105 writes event C as a processing result into the first buffer 121b1 (11).
  • the first buffer 121b1 holds unprocessed events B and C (11).
  • application writing means 105 requests processing of the data in first buffer 121b1 (not only added data C but also already added data B).
  • 102a (50). Since the caller is the application writing means 105, the socket write request means 102a refers to the CAS flag of the flag management means 107. In this case, the flag is already set due to the previous processing of the data A (4). so it can no longer be flagged.
  • the socket write requesting means 102a does not wait until the process becomes ready, but ends the processing of the socket write requesting means 102a in a non-blocking manner and returns to the thread 1 process.
  • the socket write request means 102a when the socket write request means 102a leaves the processing to the OS kernel 100 (6), an OS system call (for example, AsynchronousSocketChannel.write() of JAVA ) to request transmission of event A(12) existing in the second buffer 121b2.
  • the socket write request means 102a requests the OS execution means 100 (OS kernel) to write event A in the second buffer 121b2, ends the process, and returns to the process of thread 1 (7).
  • the OS kernel 100 that has received the transmission request divides event A into appropriate sizes and transmits events A1 and A2 (13), as in the first embodiment. .
  • the size of division, the number of divisions, and the transmission interval depend on the OS, network load, and the like.
  • event B of thread 2 while OS kernel 100 is processing event A, application writing means 105 continues to process event B of first buffer 121b1. 102a is called (8), but socket write request means 102a is still processing event A (4) and the CAS flag of flag management means 107 is set (9). Without moving the event B in the second buffer 121b- 1 to the second buffer 121b- 2 , the application writing means 105 terminates the processing, and the thread 2 proceeds to the next processing (10). At this time, the events B and C are accumulated in the first buffer 121b1, and the event D has not yet been generated (11). The application executing means 103 processes data by the thread 2 and generates an event D at a later timing.
  • the callback processing means 102b is started as the callback thread of the thread 1 (14), and the callback processing means 102b confirms the number of bytes that have been transmitted, and in this case the entire event A has been transmitted, so it deletes event A from the first buffer 121b1 (15).
  • events B and C are present in the first buffer 121b1 (11).
  • the callback processing means 102b calls the socket write request means 102a (16).
  • the socket write request means 102a checks whether events are accumulated in the first buffer 121b-1 . Move to buffer 121b2 (17). In this case, since the capacity of the second buffer 121b2 is sufficient, all the events in the first buffer 121b1 are moved. You may move only a part of the event (for example, only event B). By chance, at a later timing, the application writing means 105 writes the processing result event D of the thread 2 into the first buffer 121b1 (18). At this point, the first buffer 121b1 holds only event D.
  • event C of thread 1 the socket write request means 102a is subsequently called.
  • event C is not moved to the second buffer 121b2
  • the application writing means 105 terminates the processing, returns to the thread 1, and advances the processing (19).
  • the application executing means 103 processes data by the thread 1 and generates an event F at a later timing (20). Also, as described above, the callback thread processes the event B and the event C of the first buffer 121b1 at a later timing.
  • 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.
  • the OS kernel 100 which has been requested to send events B and C by the callback thread, divides events B and C into appropriate sizes and sends them to the network.
  • event B is divided into three and transmitted as events B1, B2, and B3, and the processing ends (the OS kernel completes the processing).
  • the reason why only the event B is sent and not the event C, or the reason why the entire event B is sent instead of a part of the event B depends on the circumstances of the OS and the load on the server device 1 or the network 4 (22 ).
  • event D of thread 2 during the event processing of the OS kernel 100 requested by the callback thread of thread 1, the application writing means 105 continues to process event D of the first buffer 121b1.
  • the socket write request means 102a is called (23), but since the socket write request means 102a is processing events B and C (16) and the CAS flag of the flag management means 107 is set (24), a socket write request is issued.
  • the means 102a does not move the event D in the first buffer 121b- 1 to the second buffer 121b- 2 , the application writing means 105 terminates and returns to thread 2 to proceed with the next process (25).
  • the application execution means 103 continues to process data by thread 2 and generates event E at a later timing (26). At this time, the event D is accumulated (18) in the first buffer 121b1, and the event E has not yet been generated.
  • the OS kernel 100 which is requested to transmit events B and C by the callback thread, completes the transmission of event B and activates the callback processing means 102b (27), and the callback processing means 102b transmits Check the number of bytes completed, and delete event B from the first buffer 121b1, since in this case the entire event B has been transmitted.
  • thread 2 generates event E and writes event E to first buffer 121b1 by means of application writing means 105 .
  • Events D and E are present in the first buffer 121b1 (28).
  • application writing means 105 that has generated event E (26) calls socket writing request means 102a (30).
  • the socket write request means 102a is still processing events C and D (27), and the CAS flag of the flag management means 107 is set (31).
  • the application writing means 105 terminates the processing and returns to thread 2, which advances the next processing (32).
  • the OS kernel 100 When the OS kernel 100 is requested to send events B and C by the callback thread of the thread 1, after completing the transmission of the event B, it again activates the callback thread of the thread 1, and the activated callback processing means 102b , again calls the socket read request means 102a (29).
  • the socket write request means 102a checks whether the event is accumulated in the first buffer 121b - 1 . Move the event (33). At this point, the second buffer 121b2 holds events C, D and E.
  • the socket write request means 102a calls the OS system call because the caller is the callback processing means 102b, and the events C, D, and E of the second buffer 121b2.
  • a transmission request is sent to the OS and the callback thread is terminated (34).
  • the OS kernel 100 attempts to send events C, D, and E.
  • the event C is divided into appropriate sizes (C1, C2, C3), the events C1 and C2 are transmitted, and the processing ends (the OS kernel completes the processing) (35).
  • the reason for transmitting (35) only a part of event C (C1, C2) and not transmitting the remaining event C (C3), event D, and event E is the convenience of the OS, as described above.
  • the event F is accumulated in the first buffer 121b1.
  • OS kernel 100 completes transmission of a part of event C, it activates (36) callback processing means 102b again as a callback thread of thread 1, and callback processing means 102b completes transmission.
  • portions corresponding to C1 and C2 of event C are deleted from the second buffer 121b2.
  • C is stored in a single chunk, the entire chunk cannot be freed until the transmission of C3 is complete.
  • java. nio When the transmission start position and the transmission end position are managed using ByteBuffer, the entire C is released after the processing of C3 is completed, and the transmission start position is moved from C1 to C3 to complete C1 and C2. Then, the socket write request means 102a is called again (37).
  • the socket write request means 102a checks whether the event is accumulated in the first buffer 121b1 because the caller is the callback processing means 102b. Therefore, event F is moved to the second buffer 121b2. Event F moves from the first buffer 121b1 to the second buffer 121b2, the first buffer being empty (38) and the second buffer holding events C3, D, E, F (39).
  • the socket write request means 102a subsequently makes an OS system call and requests the OS execution means 100 (OS kernel) to write events C3, D, E, and F (39) of the second buffer 121b2. Terminate the callback thread (40).
  • the OS kernel 100 which has been requested to transmit events C3, D, E, and F, divides events C and D into appropriate sizes and transmits events C3, D1, and D2 (41).
  • the reason why only the events C3 and D are transmitted and not the events E and F is the convenience of the OS as described above.
  • the OS kernel 100 activates callback processing means 102b as a callback thread (42) after completing the transmission of events C and D, and calls the callback processing means 102b.
  • the back processing means 102b confirms the number of bytes that have been transmitted. ) and event D.
  • the socket write request means 102a is called again (43).
  • 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).
  • the OS kernel 100 which has been requested to transmit events E and F, divides events E and F into appropriate sizes and transmits events E1, E2, and F (46).
  • the OS kernel 100 to which the transmission of the events E and F has been requested activates the callback processing means 102b as a callback thread when the transmission of the events E and F is completed (47). confirms the number of bytes that have been transmitted. In this case, since transmission of all events E and F has been completed, events E and F are deleted from the second buffer 121b2. Then, the socket write request means 102a is called again (48).
  • the socket write request means 102a checks the first buffer 121b- 1 and the second buffer 121b- 2 in order because the caller is the callback processing means 102b. and the second buffer 121b2, the CAS flag of the flag management means 107 is cleared (49) and the callback thread is terminated.
  • the intermediate buffer 121B is provided between the application writing means 105 and the socket writing means 102, and the first buffer 121b1 of the intermediate buffer 121B is used for the writing of the application writing means 105.
  • Write data is accumulated for each thread in a non-blocking manner, the write operation of the socket write request means 102a is executed according to the CAS flag, the CAS flag is managed by the flag management means 107, and the write operation of the socket write request means 102a is executed.
  • a flag is set at the start of loading, and the callback processing means 102b that receives notification of the event processing completion of the OS execution means 100 releases the flag.
  • the events are converted into a format suitable for the processing of the OS execution means, such as 2, and then the events in the second buffer 121b 2 are processed by the OS execution means 100.
  • the write operation does not directly affect the transmission event processing operation of the OS execution means 100 (there is no waiting time for the application writing means 105 and the OS execution means 100 to respond to each, and each event The number of calls to the OS execution means 100 is reduced compared to calling the OS execution means 100), application processing and data transmission can be executed in a non-blocking manner to speed up communication.
  • transmission processing to the network which takes a relatively long time, is performed with a short wait time (latency), continuous processing as much as possible, and non-blocking, giving priority to network transmission processing, increasing transmission throughput, and asynchronous transmission.
  • Application processing can be executed in parallel in a non-blocking manner during the waiting time for (NIO) processing.
  • the socket write request means 102a 1 for requesting event processing to the OS execution means 100 only in response to a call from the application write means 105 and the socket write request means 102a 1 for calling It may be divided into a socket flash writing means 102a2 that requests event processing to the OS execution means 100 only in response to a call from the back processing means 102b.
  • step S40 of FIG. 11 becomes unnecessary
  • step S53 of FIG. 12 changes to "request event processing to OS execution means 100”
  • the operation of FIG. 13 is carried out by socket flash writing means 102a2 .
  • Non-blocking exclusive control by CAS The basis of the present invention is non-blocking OS execution means 100 calling by CAS.
  • 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 in parallel. Therefore, some kind of exclusive control is required.
  • 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.
  • (C) Asynchronous Processing of Event Accumulation and OS Function Calling Accumulation of events can be synchronized with the occurrence of events.
  • the accumulated event processing can be started from the event processing completion callback.
  • event processing is not working at all, for example, another mechanism is required to activate the first event processing.
  • a method is disclosed in which event accumulation is used as a trigger only when event processing is stopped.
  • 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.
  • 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 If memory allocation and deallocation are repeated frequently, calling the OS function each time will be 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 chunks should be allocated.
  • FIG. 5 is a schematic diagram showing a modification of the layer configuration.
  • this application describes 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.
  • the buffers (b) to (e) may be provided at different positions in different layer configurations (a) to (e).
  • data is sequentially transmitted to a TCP or UDP (User Datagram Protocol) channel created by the Java VM (virtual OS).
  • UDP User Datagram Protocol
  • Exclusive control is required when multiple threads use the same channel.
  • RUDP Reliable User Datagram Protocol
  • applications that use UDP sockets must create their own layer of reliability assurance such as ACK (acknowledgement) and retransmission.
  • the difference from A is whether it is a virtual OS or a native OS, so it can be implemented with almost the same configuration and operation as A.
  • NIC drivers are not NDIS, they are specialized and are usually dependent on a particular NIC product.
  • 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.
  • the general usage is language dependent and OS dependent, and is the same as (a).
  • 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.
  • 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.
  • (e) it is 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.
  • each means 100 to 107 of the control unit 10 are realized by programs, but all or part of each means may be realized by hardware such as ASIC.
  • the program used in the above embodiment can be stored in a recording medium such as a CD-ROM and provided.
  • replacement, deletion, addition, etc., of the steps described in the above embodiment are possible without changing the gist of the present invention.
  • the function of each means may be appropriately combined with other means, or may be separated into a plurality of means.
  • processing of network transmission events has been mainly described, but the present invention does not limit the event to be processed to only network transmission events. 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 to 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.
  • a computer buffering means for accumulating one or more 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 at the timing of the start of event processing by the processing means, and cancels the flag at the timing of the end of the callback processing means,
  • the processing request means accepts a call at the timing of accumulation in the buffering means and the termination of the callback processing means, and if the flag is not set according to the flag of the flag management means, the process is not performed.
  • a communication management program that terminates without any delay and processes the events accumulated by the buffering means when set.
  • the buffering means accumulates the event in a ring buffer.
  • 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 the timing of the start of event processing by the processing means, and cancels the flag at the timing of the end of event processing by the callback processing means,
  • the processing request means accepts a call at the timing of accumulation in the buffering means and the termination of the callback processing means, and if the flag is not set according to the flag of the flag management means, the process is not performed.
  • 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 the timing of starting the processing of the event in the processing step, and cancels the flag at the timing of the end of processing the event in the callback processing step,
  • the process request step accepts a call at the timing of accumulation for the buffering step and the termination of the callback processing means, and if the flag is not set according to the flag of the flag management means, the process is not performed.
  • An information processing program, an information processing apparatus, and an information processing method are provided that speed up communication by executing application processing and data transmission in a non-blocking manner.
  • Reference Signs List 1 server devices 2a, 2b, 2c: terminal device 4: network 10: control unit 11: storage unit 12: memory 13: communication unit 100: OS execution means (OS kernel) 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: ring buffer 121B: intermediate buffer 121b1: first buffer 121b2: second buffer 130: channel 131: source

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Multimedia (AREA)
  • Computer And Data Communications (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

【課題】アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化する情報処理プログラム、情報処理装置及び情報処理方法を提供する。 【解決手段】サーバ装置1は、イベントを蓄積するバッファリング手段106と、イベントを処理するソケット書込手段102と、排他的にフラグを立てるフラグ管理手段107とを有し、ソケット書込手段102はソケット書込要求手段102aとコールバック処理手段102bとを含み、フラグ管理手段107は、ソケット書込要求手段102aがイベントの処理の開始前のタイミングで排他的にフラグを立て、コールバック処理手段102bの処理の終了後のタイミングでフラグを解除し、ソケット書込要求手段102aは、呼び出しを受け付けて、当該フラグが立てられた場合はバッファリング手段106が蓄積したイベントを処理する。

Description

情報処理プログラム、情報処理装置及び情報処理方法
 本発明は、情報処理プログラム、情報処理装置及び情報処理方法に関する。
 従来の技術として、データの大きさに応じて使用するバッファを変更してデータを送信する情報処理装置が提案されている(例えば、特許文献1参照)。
 特許文献1に開示された情報処理装置のCPU(Central Processing Unit)は、アプリケーションバッファエリアを占有するアプリケーションタスクとリングバッファエリアを占有するTCP(Transmission Control Protocol)/IP(Internet Protocol)タスクとを並列的に実行する。アプリケーションタスクは、データ生成処理によってアプリケーションバッファエリアに格納されたデータのサイズが閾値以下であるか否かを判別し、判別結果が肯定的であるときアプリケーションバッファエリア上のデータをリングバッファエリアに複製してデータ送信指示を発行する一方、判別結果が否定的であるときアプリケーションバッファエリアの占有権をTCP/IPタスクに一時的に付与してデータ送信指示を発行する。TCP/IPタスクは、自ら占有するメモリエリア上の送信データをデータ送信指示に応答して送信する。
特開2010-55214号公報
 しかし、特許文献1の情報処理装置は、送信するデータ量が少ない場合はリングバッファを用いてデータを送信して、アプリケーションタスクを並列して行い、送信するデータ量が多い場合はTCP/IPタスクを専有的に処理することで通信速度の高速化を図るものの、送信するデータ量が多い場合はアプリケーションタスクがブロッキングされて処理されない、という問題がある。
 従って本発明の目的は、アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化する情報処理プログラム、情報処理装置及び情報処理方法を提供することにある。
 本発明の一態様は、上記目的を達成するため、以下の情報処理プログラム、情報処理装置及び情報処理方法を提供する。
[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、15、16に係る発明によれば、アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化することができる。
図1は、実施の形態に係る通信管理システムの構成の一例を示す概略図である。 図2は、実施の形態に係るサーバ装置の構成例を示すブロック図である。 図3は、データ送受信の動作の一例を説明するための概略図である。 図4は、データ送信動作の一例を説明するための概略図である。 図5は、レイヤ構成の変形例を示す概略図である。 図6は、ソケット書込要求手段の動作例を説明するためのフローチャートである。 図7は、コールバック処理手段の動作例を説明するためのフローチャートである。 図8は、ソケット書込要求手段の動作例を説明するためのフローチャートである。 図9は、データ送受信の動作の別の一例を説明するための概略図である。 図10は、データ送信動作の別の一例を説明するための概略図である。 図11は、ソケット書込要求手段の別の動作例を説明するためのフローチャートである。 図12は、コールバック処理手段の別の動作例を説明するためのフローチャートである。 図13は、ソケット書込要求手段の別の動作例を説明するためのフローチャートである。
[第1の実施の形態]
(通信管理システムの構成)
 図1は、実施の形態に係る通信管理システムの構成の一例を示す概略図である。
 この通信管理システムは、情報処理装置としてのサーバ装置1と、当該サーバ装置1のクライアントとしての端末装置2a、2b、2cとをネットワークによって互いに通信可能に接続することで構成される。通信管理システムに含まれる装置は、パソコン、ゲーム端末、クラウド、仮想マシンであってもよい。ネットワークは、LANやインターネットであってもよいし、仮想ネットワークなどであってもよい。
 サーバ装置1は、サーバ型の情報処理装置であり、操作者の操作する端末装置2a、2b、2cの要求に応じて動作するものであって、本体内に情報を処理するための機能を有するCPU(Central Processing Unit)やHDD(Hard Disk Drive)又はフラッシュメモリ、揮発性メモリ、LANボード(無線/有線)等の電子部品を備える。サーバ装置1は、端末装置2a、2b、2cと通信し、データの送受信を行うことで端末装置2a、2b、2c上で扱うデータの同期を行うものであって、例えば、ゲームサーバ等である。サーバ装置1は、同期動作を行う場合は容量の小さいデータを頻繁にやりとりするものであるが、これに限られるものではない。なお、サーバ装置1は、複数のクラスタによって構成してもよく、分散処理を実行するよう構成してもよい。あるいは、クラウド環境において仮想マシンとして構成してもよい。
 端末装置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台オーダーの端末装置が接続されるような場合であっても通信可能な構成を提供する。
 ネットワーク4は、高速通信が可能な通信ネットワークであり、例えば、イントラネットやLAN(Local Area Network)等の有線又は無線の通信網である。
 一例として、第1の実施の形態における通信管理システムにおいて、複数の参加者が共通の仮想空間における活動、例えばゲームを行う多人数参加型ゲームが実行される。サーバ装置1及び端末装置2a、2b、2cは、ゲームの進行に伴い各装置内でオブジェクトとして保持している情報(同期対象オブジェクト)を、各装置間で同期するために動作し、特にサーバ装置1は、データ通信を高速化すべくアプリケーションとNIC(Network Interface Card)との間にバッファを設けてアプリケーションとNIC間のデータ授受の動作を制御する。言い換えれば、マルチプロセス、マルチスレッドが、共有リソース(ソケットやNIC)に非同期に書き込む要求が大量に発生する場合、データが混ざらないようにシリアライズするには、排他制御が必要となるため、送信通信路を効率よく使用(特に、送信通路がデータで混雑してからのスループット向上)するために、バッファにバッファリングして、当該バッファへの書込で排他制御(ブロッキング)を行い、当該バッファからの共有リソースへの書込はCAS(Compare and Swap)等でロックフリー(ノンブロッキング)な制御をする。動作の詳細について、実施の形態において具体的に説明する。
 また、第1の実施の形態において使用する「オブジェクト」等の語句は、例えば、Java(登録商標)、C++、C#、Python、JavaScript(登録商標)、Ruby等で用いられる同語句と同義で用いられるが、以降、クラス、及びインスタンス化されたクラス(インスタンス)のことを総称して「オブジェクト」と言う場合がある。
(サーバ装置の構成)
 図2は、第1の実施の形態に係るサーバ装置1の構成例を示すブロック図である。以下にサーバ装置1での実装について記述するが、端末装置2a、2b、2cも同様な構成としてもよい。
 サーバ装置1は、CPU(Central Processing Unit)等から構成され、各部を制御するとともに、各種のプログラムを実行する制御部10と、フラッシュメモリ等の記憶媒体から構成され情報を記憶する記憶部11と、揮発性記録媒体から構成され一時的に情報を記憶するメモリ12と、ネットワークを介して外部と通信する通信部13とを備える。
 制御部10は、OS(Operating System)110を実行することで、OS実行手段100(Javaの場合はJVMも含む)として機能し、アプリケーション112を実行することで、アプリケーション実行手段103、アプリケーション読出手段104、アプリケーション書込手段105として機能し、情報処理プログラムとしての通信管理プログラム111を実行することで、ソケット読出手段101、ソケット書込手段102、バッファリング手段106(受信バッファ106aと送信バッファ106bを含む)、フラグ管理手段107等として機能する。
 OS実行手段100(OSカーネル)は、OS110を実行し、OS110が有する各機能を提供する。OS実行手段100は、特に通信部13(NIC)を制御してネットワークにデータを送信し、ネットワークからデータを受信する。なお、JAVAを利用している場合は、Java VMもOSの一部とみなし、OS実行手段100によって実行されるものとする。
 アプリケーション実行手段103は、処理手段としてアプリケーション112を実行し、アプリケーション112が有する各機能を提供するものであり、実行に伴い単一又は複数のスレッドを処理する。典型的には、それぞれのスレッドは、単一又は複数の端末装置とそれぞれ対応する単一又は複数のソケット(端末装置2a、2b、又は、2cの通信対象プログラムのIPアドレス及びポート番号)を介してネットワーク通信(送受信)を行う。
 アプリケーション読出手段104は、アプリケーション112が有する機能として特に、スレッドの受信処理のために受信対象となるソケット(端末装置2a、2b、又は、2c)に対応する受信バッファ106aのデータを読み出す。
 アプリケーション書込手段105は、スレッドの処理の結果生成されたデータを送信対象となるソケット(端末装置2a、2b、又は、2c)に対応する送信処理のために送信バッファに書き込む。書き込まれたデータは通常は書き込まれた順に送信バッファ121bに追加される。例えば、ゲームサーバがゲームオブジェクトの同期処理のため、同期情報のリレー処理を行う場合、アプリケーション書込手段105は、端末装置2aから同期情報のデータ受信し、スレッドで受信データを処理した結果、端末装置2b、及び、2cに同期情報データを送信する。アプリケーション書込手段105は、それぞれの端末装置に対応する2個のソケットに対応する2個の送信バッファ121bにデータを書き込む。アプリケーション書込手段105は、送信バッファ121bにデータを追加した後、ソケット書込要求手段102aを呼び出す。
 ソケット読出手段101は、OS110が有する機能として特に、ネットワークとの通信においてソケットによって受信したデータを後述する受信バッファ106aに読み出す。
 処理手段としてのソケット書込手段102は、処理要求手段としてのソケット書込要求手段102aとコールバック処理手段102bとして機能する。
 図6及び図8は、ソケット書込要求手段102aの動作例を説明するためのフローチャートである。また、図7は、コールバック処理手段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の処理の間に他のスレッドが実行されない工夫を行っている。
 また、図8に示すように、ソケット書込要求手段102aは、ステップS13において送信バッファ106bに送信対象のデータがあるか確認し(S30)、送信対象のデータがある場合(S30;Yes)、OS実行手段100にOS非同期送信要求を行ってイベントの処理を要求する(S31)。また、ソケット書込要求手段102aは、送信対象のデータがない場合(S30;No)、フラグ管理手段107に依頼して、フラグを解除する(S32)。
 図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)。
 ソケット書込要求手段102a及びコールバック処理手段102bの他の実装としては、以下のように構成してもよい。例えば、コールバック処理手段102bは、OS実行手段100がソケット書込要求手段102aの書込イベントの処理を完了した場合に完了通知を受け付けて(非同期に)実行された送信結果を受け取る。送信結果が異常の場合は、通信断、タイムアウトなどの例外処理(接続の切断など)を行い、終了する。送信結果が正常の場合は、送信完了分を送信バッファから削除する。引き続き、コールバック処理手段102bは、送信バッファに送信対象データが存在することを確認し、確認結果が肯定的であれば、ソケット書込要求手段102aに呼び出しを行う。確認結果が否定的であれば、フラグ管理手段107に依頼して、フラグを解除して処理を終了する。
 バッファリング手段106は、メモリ12に2種類のバッファ領域、受信バッファ106aと送信バッファ106bを用意し、どちらも読み出し及び書き出しの対象を提供するとともに、読み出し及び書き出しをするデータを管理する。バッファを介することでバッファに対する読み出しと書き出しとを非同期に行うことができる。受信バッファ106aは、ソケット読出手段101が書き込み、アプリケーション読出手段104が読み出す。送信バッファ106bは、アプリケーション書込手段105が書き込み、ソケット書込手段102が読み出す。なお、バッファリング手段106(106a及び106b)は、データをノンブロッキングに読み書きする。バッファに必要なメモリを都度実行時に割り当てるのはCPUの効率が悪いので、事前に大きなメモリ領域(1個以上のブロック)を確保して、それを細分化したメモリチャンクをバッファプールに追加してバッファプールを用いた独自のメモリ管理をし、確保済のメモリブロックを再利用して使い回し、実行時の処理効率を向上させるのは一般的である。また、これらのメモリチャンクを組合せて、論理的にリングバッファを構成することも一般的である。ここでは、バッファ領域はバッファプールの一種であるリングバッファ121(受信バッファ106aとして受信リングバッファ121a、及び、送信バッファ106bとして送信リングバッファ121b)を用いた場合について説明するが、必ずしもリングバッファである必要はなく、論理的に無限長のバッファを提供できるバッファであればよく、好ましくはOSカーネルでの処理に好適なダイレクトバッファ等のヒープ領域外のメモリ領域に作成される高速に入出力が可能な一時記憶領域を用いる。
 ダイレクトバッファは、実メモリ空間に存在するため、OSの処理実行においては、ダイレクトバッファ上のデータ処理は、仮想メモリ空間に存在する通常の非ダイレクトバッファ上のデータ処理に比べて、内部的なメモリ操作回数を削減し、処理時間を短くできることが知られている。なお、ダイレクトバッファは、非ダイレクトバッファに比べて、アプリケーションにとっては、メモリの割当・解放にOSの処理時間がかかることが知られている。特にダイレクトバッファの場合は、アプリケーションがメモリの割当・解放を高頻度に実行するのは適切ではなく、後述のバッファプールなどを活用して、事前に確保したメモリを使い回すことが望ましい。また、ダイレクトバッファはOSの処理対象としては好適であるが、一方で、アプリケーションの処理対象において、ダイレクトバッファのメモリアクセス(メモリ読取及びメモリ書込)は非ダイレクトバッファのメモリアクセスに比べて時間がかかるため、通常の処理のためにダイレクトバッファを利用することは不適切であることも知られている。ダイレクトバッファは濫用せずに、OSに処理要求をするデータの格納に特化した使用に限定するのが好適である。また、ダイレクトバッファは、当該アプリケーションだけでなく、当該情報装置で実行する他のアプリケーションも利用する共用のリソースであり、濫用すると当該情報装置の他のアプリケーションの稼働に影響を与える可能性もあり、適切に使用量を節約することが望ましい。以上に第1の実施形態を念頭に好適な利用方法を例として示したが、本発明の利用方法を限定するものではない。
 次に、バッファプールとは、アプリケーションの実行時に素早く動的に必要なメモリ領域を確保するために、アプリケーションの起動時などにメインメモリの空き領域からある程度大きな領域を一括して、複数のメモリブロックとして確保したものとする。バッファプールは、メモリ管理をOSに依頼せず、アプリケーションとして実装し、メモリが必要になったときに、確保されているメモリブロックから適切なサイズのメモリ(メモリチャンク)を借り出し(メモリ割当)、使い終わって不要になったメモリはバッファプールに返却して再利用する(メモリ解放)。バッファプールは様々実装が知られている。通常、メモリブロックはページサイズなど大きなサイズなので、ここでは、アプリケーションで使いやすい1種類あるいは2種類以上の規格化されたサイズのメモリチャンクにあらかじめ分割して、バッファプールに登録する。チャンクサイズは、通常、ページサイズの2の累乗数分の1となるように調整する。2の累乗数分の1とすることで、メモリブロックを無駄なく分割できる。また、規格化されたチャンクサイズのメモリブロックを再利用することで、メモリフラグメンテーションの発生を回避できる。また、メモリをアプリケーションでバッファプールとして管理することは、必要な都度OSにメモリの割当、解放を利用する場合に比べて、個々のメモリ割当・解放に、OS呼出のオーバヘッドなどが発生しないので、メモリ割当・解放の処理が効率化されることが知られている。バッファプールを採用する場合、プールに登録するメモリチャンクのサイズ、種類、数は用途に応じてさまざまな設計方針が考えられる。以上に第1の実施形態を念頭に好適な利用方法を例として示したが、本発明の利用方法を限定するものではない。
 さて、第1の実施の形態では、バッファプールを用いる場合、メモリチャンクのサイズとして、OSの処理に適したサイズに規格化されたチャンクサイズ(例えば、ページサイズとしてメモリブロックそのまま、あるいは、その半分など)を利用し、メモリの種類としては、OSの処理に適したダイレクトバッファのメモリを利用する。OSの処理に適した大きなサイズ(例えば、ページサイズ)のメモリチャンクに、イベントデータをぎっしりと詰め込むことにより、非常に小さいサイズのイベントデータをそれぞれ別のチャンクに保持する場合に比べて、OSが提供する非同期送信機能としてAsynchronousSocketChannel.write() の集約書込(gathering write)に指定するメモリチャンクの数を効果的に削減し、また、OSでの処理効率はよくなる。OSは同じバイト数のデータを処理する場合、格納するチャンクの数が少ないほうが、内部的処理が速くなることが知られている。例えば、チャンクサイズは、ページサイズあるいはその半分など、より具体的には1KBや2KBなどの単一のサイズを採用する。また、OSの処理のために確保するメモリブロックの種類としては、ヒープに確保される通常のメモリ(非ダイレクトバッファ)ではなく、OSの処理に適したダイレクトバッファを使うとさらにOSでの処理効率がよい。ダイレクトバッファの採用は、バッファプールと組み合わせても、バッファプールを使わずにその都度メモリ割当・解放を行う場合でも使える技術であるが、バッファプールと組み合わせて使うことで、OSでの処理により適した技術となる。以上に第1の実施形態を念頭に好適な利用方法を例として示したが、本発明の利用方法を限定するものではない。
 フラグ管理手段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のバッファ121bに蓄積されたタイミングに依存して、すでにフラグを立てて排他的に実行中であるソケット書込要求手段102a自身、あるいは当該ソケット書込要求手段102aに対応するコールバック処理手段102bが、後に送信バッファが空でない場合に呼び出すソケット書込要求手段102aにより、非同期送信呼び出しがなされる。なお、前述のように、点線で囲まれたフラグの操作(状態確認や設定のステップS10,S11,S12)はマルチスレッド環境下で他スレッドによる割り込みによる影響がないようにアトミックに実行される必要があり、フラグ管理手段107が提供する(Compare and Swap)の機能を利用する。
 記憶部11は、制御部10を上述した各手段100-107として動作させるOS110、通信管理プログラム111、アプリケーション112等を記憶する。なお、各手段100~107として機能させるための対象は、OS110、通信管理プログラム111、アプリケーション112を適宜入れ替えて行うものであってもよい。また、記憶部は、リレーショナル・データベースやファイルシステムなどを用いる。なお、高速化のために、Redisなどインメモリデータベースを利用、あるいは、併用してもよい。
 メモリ12は、バッファリング手段106及びその他図示しない手段により制御され、情報を一時的に記憶する。
 なお、端末装置2a、2b、2cは、サーバ装置1と同様の構成に加え、操作部及び表示部を備える。サーバ装置1と構成が共通する部分については説明を省略する。
(情報処理装置の動作)
 次に、第1の実施形態の作用を、(1)基本動作、(2)データ送信動作に分けて説明する。
(1)基本動作
 一例として、複数のユーザが、複数のゲームオブジェクトを同期させて同一の仮想空間(ルーム)での体験(ゲームプレイ)を共有するために、同じ仮想空間に参加する。ゲームの進行は各端末装置2a、2b、2cで行い、サーバ装置1は、ゲームの進行は行わず、オブジェクトの同期動作のみを行ってもよいし、サーバ装置1がゲームの進行も行ってもよい。
 サーバ装置1の図示しない参加者管理手段は、ルームへの参加要求を受信すると、参加者に対してユーザID、ユーザ名、ソケットID、参加日時とともに記憶部11の当該ルームIDに関連付けられた参加者管理情報に記録する。
 端末装置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の送受信の動作詳細について説明する。
 図3は、データ送受信の動作の一例を説明するための概略図である。
 まず、ネットワーク4からサーバ装置1がデータを受信する場合、ネットワーク4のソース131からあるチャネル130を介し、ソケット読出手段101がチャネルに対応するソケット(受信元端末装置に対応するあるIPアドレスのあるポート)によって受信したデータを読み出して受信リングバッファ121aの書込ポインタの位置に書き込む。データは受信リングバッファ121aに追加される。なお、バッファはチャネルあるいはソケットごとに別々に用意する。また、チャネル/ソケットは送受信共用で、対応する端末装置(端末装置の通信相手となる特定のプログラム)ごとに1つ用意する。アプリバッファは、1つで図示しているが、実際は送受信別に管理する。また、リングバッファは、プールとしては、全チャネルで1つとして管理されており、1つで図示しているが、リングバッファ121は、チャネルごと、送受信別々に、それぞれ独立なポインタの管理があり、チャネルごとに、別々の受信リングバッファ121a、送信リングバッファ121bとして区別する。
 次に、アプリケーション読出手段104は、受信元端末装置に対応(チャネルあるいはソケット)した受信リングバッファ121aのデータを読出ポインタの位置から読み出してアプリバッファ120に書き込む。データは受信リングバッファ121aから取り出され、受信リングバッファ121aから除外される。ここでアプリバッファ120はアプリケーションが独自に管理するもので、バッファリング手段106が提供するものではない。アプリバッファは、別のバッファリング手段が提供する。たとえば、OS機能(通常のメモリ割当、メモリ解放)がアプリバッファを提供してもよい。メモリを再利用してメモリ管理を効率化するためには、バッファリング手段106同等の機能が提供するように別のバッファリング手段を構成して、アプリバッファを提供してもよい。
 アプリケーション実行手段103は、アプリバッファ120のデータを読み出してスレッドにて処理する。
 また、アプリケーション実行手段103のスレッドで処理されたデータをネットワーク4に送信する場合、アプリケーション実行手段103は、スレッドで処理されたデータをアプリバッファ120に書き込む。
 次に、アプリケーション書込手段105は、アプリバッファ120のデータを意図する送信先端末装置に応じて、送信先端末装置、より厳密には、チャネルあるいはソケットに対応する送信リングバッファ121bの書込ポインタの位置に書き込む。この結果、データは送信リングバッファ121bに追加される。データを書き込み終わると、書込ポインタを進めて、書込終了位置の次に移動する。次回、アプリケーション書込手段105がデータを書き込む時は、移動後の書込ポインタを使用するので、次回書き込むデータは、今回書き込んだデータの後ろに追加される。一方で、アプリバッファ120のデータは、送信リングバッファ121にコピーされた後は不要なり、アプリケーション実行手段103はこのバッファ領域を再利用できる。なお、送信リングバッファ121bはチャネルあるいはソケットごとに用意する。
 次に、ソケット書込手段102は、送信リングバッファ121bの読出ポインタの位置から書き出しポインタの位置の手前までのデータを読み出し、ソケットによってチャネル130に書き込む。データは、チャネル130を介してソース131に送信される。読出ポインタは、送信に成功したバイト数だけ進めて、送信が完了したデータの次の位置に移動する。この時、データは送信リングバッファ121bから取り出され、送信対象としてOS実行手段100が送信処理をし、送信が完了したデータ(取り出したデータの全部あるいは一部)については、送信リングバッファ121bから除外される。送信が完了しなかったデータについては、引き続き送信リングバッファ121bにとどまる。ここでは、送信リングバッファ121bに蓄積されたデータを全部一度に送信するものとしたが、送信リングバッファ121bに蓄積されているデータが巨大になった場合は、OS送信機能呼出の制限を考慮するなど、全部一度に読み出さず、一部だけを読み出して送信する制御をしてもよい。
 なお、上記したようにリングバッファ121は、メモリ領域(あるいは、仮想的に連続なメモリ領域)にデータ(イベント)を順次書込み(蓄積)し、読み出しするデータを直接格納するリングバッファであり、格納するデータを順番にメモリ領域に配置・格納(管理するデータを直接的に格納)するものである。このリングバッファ121は、格納したメモリへのポインタをメモリ領域(あるいは、仮想的に連続なメモリ領域)に書込又は読出ポインタとして順番に格納(管理するデータを間接的に格納)するものではない。また、このリングバッファ121は、書込みによりデータ(イベント)の書込単位の境界はなくなるため、データ(イベント)単位で処理する必要がある場合は、境界情報を別途管理しなければならない。第1の実施の形態では、データ処理(イベント処理)は、OSカーネルによるネットワーク送信であるので、データ(イベント)の境界にかかわらずバイトストリームとして送信するので、データ(イベント)の境界は管理しなくてよい。また、第1の実施の形態と同様の効果が得られるようなケースの場合は、他の仮想的なリングバッファの使用を妨げるものではない。
 以下、アプリケーション実行手段103のスレッドで処理されたデータをOS実行手段100からネットワーク4に送信する場合について詳細に説明する。
(2)データ送信動作
 図4は、データ送信動作の一例を説明するための概略図である。
 アプリケーション実行手段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)を実行できる。
 次に、ソケット書込要求手段102aは、フラグ管理手段107のCASフラグを参照し、フラグが立っていない場合、フラグを立てて、OSシステムコール(例えばJAVAのAsynchronousSocketChannel.write())呼び出しを行い、送信リングバッファ121bに蓄積されているデータ(読出しポインタから呼出時点での書込ポインタの一つ前までのデータ)を送信する。この時点では送信リングバッファ121bにはデータAのみ蓄積されている。ソケット書込要求手段102aは、送信リングバッファ121のデータAをOS実行手段100(OSカーネル)に書き込み要求をして終了する(1)。
 次に、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が存在する。
 次に、OSカーネル100は、データAの送信を完了するとコールバック処理手段102bを起動して、送信完了を通知する。コールバック処理手段102bは、送信完了したバイト数を確認し、この場合はデータA全体が送信完了しているので、送信リングバッファ121bの読出ポインタをデータAの直後へ移動し、データAを送信リングバッファ121bから除外する。次に、コールバック処理手段102bは、フラグ管理手段107のCASフラグを解除する。この時点で、送信リングバッファ121bは、データAが除外され、データBのみが存在する。次に、コールバック処理手段102bは、送信リングバッファ121bにまだ送信すべきデータがあるか(読出ポインタと書込ポインタが一致していれば送信すべきデータはない)を判定する。送信すべきデータがある場合は、ソケット書込要求手段102aを呼び出す。送信すべきデータがない場合は終了する。この場合はすでに、データBが送信リングバッファ121bに存在しているので、ソケット書込要求手段102aを呼び出す(3)。
 次に、ソケット書込要求手段102aは、フラグ管理手段107に依頼して、CASフラグを参照し、フラグが立っていないので、フラグを立てて、OSシステムコール(AsynchronousSocketChannel.write())呼び出しを行い、送信リングバッファ121bに蓄積されているデータ(読出しポインタから呼出時点での書込ポインタの一つ前までのデータ)を送信する。この時点では送信リングバッファ121bにデータBのみ蓄積されている。ソケット書込要求手段102aは、送信リングバッファ121bのデータBをOSカーネル100に書き込み要求をして終了する。
 次に、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が順番に蓄積されている。
 次に、OSカーネル100は、データBの送信を完了するとコールバック処理手段102bを起動して、送信完了を通知する。コールバック処理手段102bは、まず、送信完了バイト数がデータB全体であることを確認した上で、送信リングバッファ121bの読出ポインタをデータBの次の位置(この場合はデータCの先頭)に移動する。この時点では送信リングバッファ121bは、データBが除外されて、データCとデータDを蓄積している。コールバック処理手段102bは、次に、フラグ管理手段107のCASフラグを解除して、その次に、送信リングバッファ121bは空でない(この場合はデータC及びデータDが蓄積されている)ことを確認して、ソケット書込要求手段102aを呼び出す。
 次に、ソケット書込要求手段102aは、フラグ管理手段107のCASフラグを参照し、フラグが立っていないので、フラグを立てて、OSシステムコール(AsynchronousSocketChannel.write())呼び出しを行い、送信リングバッファ121bのデータCとデータDをOSカーネル100に書き込む(6)。
 次に、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を蓄積している。
 次に、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を呼び出す。
 次に、ソケット書込要求手段102aは、フラグ管理手段107のCASフラグを参照し、フラグが立っていないので、フラグを立てて、OSシステムコール(AsynchronousSocketChannel.write())呼び出しを行い、送信リングバッファ121bのすべてのデータDEFをOSカーネル100に書き込み要求する(9)。
 次に、OSカーネル100は、データDEFを適切なサイズに分割してデータD1、D2、…としてネットワーク4に送信する。
 次に、OSカーネル100は、たまたまデータDだけの送信を完了するとコールバック処理手段102bを起動して、送信完了を通知する。コールバック処理手段102bは、送信済バイト数を確認すると、偶然データDだけが送信完了となっていたので、送信リングバッファ121bの読出ポインタをデータEの先頭に移動し、フラグ管理手段107のCASフラグを解除して、送信リングバッファが空ではないので、ソケット書込要求手段102aを呼び出す。
 次に、ソケット書込要求手段102aは、フラグ管理手段107のCASフラグを参照し、フラグが立っていないので、フラグを立てて、OSシステムコール(AsynchronousSocketChannel.write())呼び出しを行い、リングバッファ121のデータEFをOSカーネル100に書き込み要求する(10)。
 次に、OSカーネル100は、データEFを適切なサイズに分割してデータE、F1、F2としてネットワーク4に送信する。
 次に、OSカーネル100は、データE、Fの送信をするとコールバック処理手段102bを起動して、送信完了を通知する。コールバック処理手段102bは、送信完了バイト数を確認し、送信リングバッファ121bの読出ポインタをデータFの次に移動させ、フラグ管理手段107のCASフラグを解除する。コールバック処理手段102bは、送信リングバッファ121bが空(読出ポインタと書込ポインタが一致)になり、処理を終了する
 以上の例では、説明しやすいように、データA-Fはそれぞれが1個以上のネットワークパケットとして送信されるような大きなデータとして図示した。ゲームサーバでオブジェクトの同期情報をストリーミングのように送受信する際には、個々のデータのサイズはネットワークの送信パケットサイズにくらべて非常に小さく、データが蓄積されれば、多数のデータがひとつのネットワーク送信パケットとして送信される。したがって、CASによるノンブロッキングなソケット書込手段は、OSのロック機能を使用する場合に比べて、著しくオーバヘッドが小さくなり、また、複数のデータをまとめて連続なブロックに配置したり、複数のデータをまとめて1回のOS送信要求で送ったりすることにより、送信チャネルを切れ目なく効率よく稼働させることができ、特にストリーミングのような利用形態では有用である。
(第1の実施の形態の効果)
 上記した実施の形態によれば、アプリケーション書込手段105とソケット書込手段102の間に送信リングバッファ121bを設け、送信リングバッファ121bはアプリケーション書込手段105の書込データをノンブロッキングに蓄積して、ソケット書込要求手段102aの書込動作をCASフラグに応じて実行し、CASフラグをフラグ管理手段107によって管理し、ソケット書込要求手段102aの書込開始でフラグを立て、OS実行手段100のイベント処理完了の通知を受けたコールバック処理手段102bがフラグを解除するようにしたため、アプリケーション書込手段105の書き込み動作がOS実行手段100の送信イベント処理の動作に直接影響を及ぼさないようになり(アプリケーション書込手段105、OS実行手段100がそれぞれに対応するための待ち時間がなくなり、また、それぞれの呼出回数が削減され)、アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化することができる。特に、所要時間の比較的長いネットワークへの送信処理を、ウェイト時間(レイテンシ)短く、なるべく連続処理、かつ、ノンブロッキングに実行することで、ネットワーク送信処理を優先し、送信スループットを上げ、非同期送信(NIO)の処理待ちの間の時間にアプリ処理を実行することができる。
 また、アプリケーションが消費するOSリソース(総メモリ量、スレッド数、OS機能呼び出し回数)を削減し、処理の高速化を実現できる。また、レンタルサーバやクラウドサービスなどで運用する場合は、よりコンパクトなサーバ仕様で動作させることができ、運用コストが削減される。
(第2の実施の形態)
 第2の実施の形態は、送信バッファとしての中間バッファが2種類存在する点、アプリケーション書込手段105がマルチスレッド時にノンブロッキングである点で第1の実施の形態と異なる。アプリケーション書込手段105がノンブロッキングで並行処理が可能となり、第1の実施の形態に比べて、アプリケーションの処理効率が改善される。なお、第1の実施の形態と共通の構成、動作については記載を省略する場合がある。まず、第2の実施の形態における通信管理システムの構成、及びサーバ装置の構成については、それぞれ、第1の実施の形態で示した図1及び図2と同じなので記載を省略する。図1及び図2の説明の記載で、第1の実施の形態に特化した動作や機能については、第1の実施の形態とのちがいも含めて、以下に説明する。
 図9及び図10に示すように、構成において、第1の実施の形態(図3及び図4)と比較して、第2の実施の形態では、リングバッファ121(図3参照。)が中間バッファ121B(図9参照。)に置き換えられる点、バッファリング手段106がメモリ12に送信バッファとして、リングバッファ121b(図4参照。)だけでなく、第1のバッファ121bと第2のバッファ121bを用意する点(図10参照。)で第1の実施の形態と構成が異なる。
 図10に示すように、第1のバッファ121bは、アプリケーション書込手段105により、スレッド103の処理の結果生成されたイベントの書き込みを受け付け、第2のバッファ121bは、ソケット書込手段102aにより、第1のバッファ121bにスレッド毎に書き込まれたデータの集合の書込を受け付ける。イベントを規格化されたメモリチャンクに保持する場合、第1のバッファ121bでは、一例として、標準的なイベントサイズを考慮し、イベントをチャンクに格納した場合にチャンクの使い残しがあまり発生しないように、既存の各種最適化アルゴリズムなどを用いてチャンクサイズを計算・設計するものとし、ここでは256バイトの規格化されたチャンクにイベントを保持(イベントサイズが256バイトより大きければ複数チャンクに保持)したものを複数保持するものとする。チャンクはバッファプールで管理し、バッファプールを複数のチャネルで共有すると想定して、初期値として4096個用意すると合計1MBである。バッファプールは不足した場合は、追加でメモリチャンクを割り当てて、拡張できる構成が望ましい。また、ここでバッファプールを複数チャネルで共有するとは、異なる送信先ごとに異なるチャネル、異なるソケットを使うため、本発明は単一のチャネルの動作を中心に記述するが、他チャネルでもそれぞれが同様に独立したバッファリング手段106を保持するが、それぞれのバッファリング手段にメモリチャンクを提供するバッファプールは一元的に管理すれば、各チャネルで個別にバッファプールを保持する場合に比べて、バッファプールのメモリ確保の重複を排除して、チャネル間でメモリを融通できるため、バッファプールとして確保する総メモリを節約できる。一方で、第2のバッファ121bはOSでのイベント処理に使用される。第2のバッファ121bは、一例として、OSの好適なデータ処理サイズであるページサイズを考慮し、ここでは2048バイトの規格化されたチャンクをに処理すべき送信データを保持するものとする。チャンクをバッファプールで管理し、バッファプールを複数のチャネルで共有すると想定して、初期値として4096個用意すると合計8MBである。第1のバッファ121bのバッファプールと同様に、バッファプールは不足した場合は、追加でメモリチャンクを割り当てて、拡張できる構成が望ましい。なお、第1のバッファ121bと第2のバッファ121bのそれぞれのチャンク容量及びチャンク数は通信環境やシステムの仕様に合わせて適宜設定するため、例として示した値に限定されるものではない。ただし、バッファプールのメモリチャンクは、あらかじめまとめて取得した大きなメモリを分割して使用するので、メモリチャンクのサイズは、メモリ境界を考慮して、サーバ装置1のページサイズ、又は、ページサイズの2の累乗数分の1から選ぶことがメモリシステムの効率上望ましく、50バイトや100バイトのような任意のバイト数を選択すべきではない。また、第2のバッファは、OSでの処理に適したダイレクトバッファを使用するとOSでの送信処理効率がよくなる。
 また、図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種類の手法に限定するものではなく、イベント追加とイベント処理をノンブロッキングかつ非同期に行うための他の手法を用いてもよい。
 図11及び図13は、ソケット書込要求手段102aの動作例を説明するためのフローチャートである。また、図12は、コールバック処理手段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)の機能を利用する。
 また、図13にOS実行手段100の動作を示す。ソケット書込要求手段102aは、ステップS44(図11)において第1のバッファ121bに送信対象のデータがあるか確認し(S60)、送信対象のデータがある場合(S60;Yes)、第1のバッファ121b上のイベントを第2のバッファ121bに必要に応じて移動する(S61)。単に移動するだけならば、このステップは省略して、第1のバッファのデータを対象として、いきなりOS非同期送信呼出S63を実行すればよく、移動を省く分だけ処理の効率はよくなる。移動するからには、移動操作においてなんらかの性能の向上が期待される操作、例えば、バッファのメモリタイプの変更、バッファのメモリサイズの変更、バッファ内のデータの配置の変更、移動個数(移動イベント数、あるいは、移動バイト数)の制御などを行い、第1のバッファのメモリチャンクに保持されているイベントを、第2のバッファの新たに割り当てたメモリチャンクにコピーし、第1のバッファのコピー終了後の不要なメモリチャンクを解放する。
 なお、バッファが保持するメモリチャンクの割当や解放はバッファプールを用いると効率がよい。以下の各種バリエーションではバッファプールを仮定し、規格化されたサイズのメモリチャンクを用いたバッファを念頭に記述するが、本発明は、それらのすべての操作、あるいは、一部の操作だけと限定せず、通常に都度割当解放するメモリチャンクであっても、また、チャンクのサイズがばらばらであっても、以下の各種バリエーション、及び、その他の有用な操作を除外するものではない。
 まず、メモリチャンクのタイプは、第2のバッファを後述するようにOSが処理で使用(S63)するので、OSの処理に適したダイレクトバッファを使用するとよい。
 次にバッファのサイズやデータの配置を検討する。OSは同じサイズのデータでも、大きなメモリチャンク1個で処理をする方が、小さなチャンクを数多く処理するより効率がよい。そこで、大きなメモリチャンクを用意し、複数のイベントをひとつのメモリチャンクに順番に配置することで、OSが処理するメモリチャンクの個数を削減するとよい。
 次に移動について検討する。移動のタイミングで、ごく単純に、第1のバッファ121bが保持すすべてのイベントを第2のバッファ121bに移動してしまってもよい。しかし、第2のバッファはOS処理に使うダイレクトバッファを使用すること、OS処理要求が一度に処理できるメモリチャンクの数や総バイト数には上限があることを考慮すると、ダイレクトバッファの使用量を抑制するためには、移動するイベントの数は、受け入れる第2のバッファが保持するメモリチャンクが、OS処理要求に適切な分量以下になるように制御するとよい。たとえば、第2のバッファの保持するダイレクトバッファのメモリチャンクの数に対して、例えば32個程度などの上限を設定し、OSの処理が滞るなどの原因で、第2のバッファがすでに相当量のメモリチャンク(この例では32個に近い数のメモリチャンク)を保持している場合、移動を上限の範囲(この例では例えば32個、あるいは33個などの予め定める上限値)で停止する、あるいは、すでに上限を超えていれば移動を行わない(0個の移動を行う)。このように、第2バッファ121bが保持するメモリチャンク数に上限などの制限を設けることで、通信不調などで滞ったイベントは、第1のバッファ121bに蓄積され、サーバ装置1全体で共有するダイレクトバッファリソースを使う第2のバッファ121bを肥大化させることはない。逆に第2のバッファが保持するチャンクがほとんどない健全な状態では、第1のバッファ121bのイベントすべてを移動できる。
 第1のバッファ121bから第2のバッファ121bへのイベントの移動は、このようなメモリチャンクのタイプの変更やメモリチャンクのサイズの変更やメモリチャンク内のデータ配置の変更や移動個数の制御あるいはその他の性能向上の工夫の全部あるいは一部だけを実施して、後段のOSでのイベント処理効率をよくするために行う。
 以上、2個のバッファ(第1のバッファ121b1と第2のバッファ121b2)の例を記載したが、バッファの個数を2個に限定するものではない。メモリチャンクのタイプの変更やメモリチャンクのサイズの変更やメモリチャンク内のデータ配置の変更や移動個数の制御あるいはその他の性能向上の工夫は、2個のバッファ間の1回の移動ですべて実施する必要はなく、3個以上のバッファを用いて、多段に順次実行してもよい。
 また、イベント単位の移動の例を記載したが、移動をイベント単位に限定するものではない。ネットワーク送信などOS処理システムが、個々のイベントの境界にとらわれず、蓄積されたバイト単位に処理をする場合、バッファ間のイベントの移動はイベント単位(0個以上の複数個のイベント)に限定されない。あるイベントの一部分だけでもよいし、連続するイベントの部分を結合したもの(例えば、イベントA,イベントB、イベントCが順番に蓄積されていた時に、イベントAの前半が移動した後は、イベントAの後半の一部(イベントAの残りの後半)、イベントB全部、イベントCの前半の一部を連続するイベントの部分を結合したもの)でもよい。
 また、第1のバッファ121bに送信対象のデータがない場合(S60;No)、ステップS62へと進む。
 なお、第1のバッファ121bへイベントを追加するのは、アプリケーション書込手段105である。アプリケーション書込手段105は、第1のバッファ121bへイベントを追加後(図10)に、ソケット書込要求手段102aを呼び出す。アプリケーション書込手段105は、並行動作する複数スレッド103から非同期に呼出され、ノンブロッキングで第1のバッファ121bにイベントを蓄積する。バッファとしては、たとえば、Javaが提供するキュー(java.util.concurrent.ConcurrentLinkedQueue)を、メモリチャンクへのポインタを管理するFIFOバッファを利用する。バッファプールが管理する、メモリチャンクを再利用することで、効率のよいリングバッファを実現できる。バッファプールのメモリチャンクは典型的なイベントサイズより少し大きめのメモリサイズで規格化するとよい。メモリチャンクにはいりきらない大きなイベントは複数のチャンクに保管する。チャンクサイズは、ページサイズの2の累乗数分の1となるように調整する。第2のバッファ121bも、第1のバッファ121b同様に、イベント情報格納したメモリチャンクへのポインタを保持するFIFOキュー(例えば、java.util.concurrent.ConcurrentLinkedQueue)が使用できる。
 次に、ソケット書込要求手段102aは、第2のバッファ121bに送信対象のデータがある場合(S62;Yes)、OS実行手段100にOS非同期送信要求を行ってイベントの処理を要求する(S63)。例えば、JavaのAsynchronousSocketChannel.write()の集約書込(gathering write)を呼び出して、複数メモリチャンクを送信対象として、1回の呼び出しで複数のイベントの処理を要求する。また、ソケット書込要求手段102aは、第2のバッファ121bに送信対象のデータがない場合(S62;No)、フラグ管理手段107に依頼して、フラグを解除する(S64)。第1のバッファ121bにデータがないことを確認(S60)後、第2のバッファ121bにもデータがないことを確認(S62)したので、中間バッファ121B(第1のバッファ121b及び第2のバッファ121b)が保持するデータをすべて送信し終わったとみなして、フラグを解除して、場合によってはフラグをたてたまま複数回連続的に行ってきたOS非同期送信呼び出しを終了する。送信し終わったとみなした後、フラグを解除するまでの間に、第1のバッファ121b1にイベントが追加された場合は、次のイベントとともにOS処理が実行される。
 図12に示すコールバック処理手段102bは、OS実行手段100がソケット書込要求手段102aの書込イベントの処理を完了した場合に、OS実行手段100から完了通知を受け付けて、対応するソケット書込要求手段102aとは非同期に実行する。コールバック処理手段102bは、OS実行手段100が実行したネットワーク送信結果を受け取る(S50)。送信結果が正常の場合は(S51;Yes)、コールバック処理手段102bは、送信完了分を第2のバッファ121bから削除し(S52)、ソケット書込要求手段102aに呼び出しを行う(S53)。また、送信結果が異常の場合は(S51;No)、コールバック処理手段102bは、通信断、タイムアウトなどの例外処理(接続の切断など)を行う(S54)。
(情報処理装置の動作)
 第2の実施の形態の作用を、(1)基本動作、(2)データ送信動作に分けて説明する。
 図9は、第2の実施の形態のデータ送受信の動作の一例を説明するための概略図である。
(1)基本動作
 まず、ネットワーク4からサーバ装置1がデータを受信する場合、ネットワーク4のソース131からあるチャネル130を介し、ソケット読出手段101がチャネルに対応するソケット(受信元端末装置に対応するあるIPアドレスのあるポート)によって受信したデータを読み出して中間バッファ121Bに書き込む。データは中間バッファ121Bに追加される。なお、バッファはチャネルあるいはソケットごとに別々に用意する。また、チャネル/ソケットは送受信共用で、対応する端末装置(端末装置の通信相手となる特定のプログラム)ごとに1つ用意する。アプリバッファは、1つで図示しているが、実際は送受信別に管理する。また、中間バッファ121Bは、バッファプールとしては、全チャネルで1つとして管理されており、1つで図示しているが、チャネルごと、送受信別々に管理され、チャネルごとに、別々の受信中間バッファ、送信中間バッファとして区別する。
 以降のアプリバッファ120への書込動作は第1の実施の形態と共通するため省略する。
 次に、アプリケーション実行手段103は、アプリバッファ120のデータを読み出してスレッドにて処理する。
 また、アプリケーション実行手段103のスレッドで処理されたデータをネットワーク4に送信する場合、アプリケーション実行手段103は、スレッドで処理されたデータをアプリバッファ120に書き込む。第2の実施の形態ではアプリケーション書込手段105がマルチスレッドで並行処理される場合をメインに説明する。
 アプリケーション書込手段105は、アプリバッファ120のデータを意図する送信先端末装置に応じて、送信先端末装置、より厳密には、チャネルあるいはソケットに対応する中間バッファ121B、特に第1のバッファ121bにスレッド毎に書き込む。第1のバッファ121bには、スレッド毎に用意された領域に順次データが書き込まれる。アプリケーション書込手段105の並行処理の効率をよくするために、アプリケーション書込手段105はノンブロキングに中間バッファ121Bにデータ(処理結果のイベント)を書き込む。
 次に、ソケット書込手段102は、任意のタイミングで第1のバッファ121bから第2のバッファ121bへ順次データを移動する。移動とは、データを保持するメモリチャンクを第1のバッファ121bから第2のバッファ121bへと文字通りバッファ間で移動する場合だけでなく、対象データを第2のバッファへコピーした後に、第1のバッファからは削除する場合を含む。また、移動とは、単なる1対1の移動にとどまらず、移動によりバッファのタイプ、メモリチャンクのサイズ、メモリチャンク内での配置方法を変更したり、移動するイベント個数の調整をしたり、OS実行手段が処理しやすいデータ保持形態に変換したりすることも含む。これらの変換を段階的に実施するためには、第3のバッファ、第4のバッファなどさらにバッファ個数(バッファの段数)を増やしてもよい。また、バッファの利用都度に発生するメモリの割当・解放の負荷を軽減するために、データを保持するメモリチャンクはあらかじめまとめて割り当てたメモリを再利用するバッファプールで管理することができる。第1のバッファ、第2のバッファでバッファプールを共有することもできる。また、複数チャネルでそれぞれのバッファ管理を行う場合でも、単一のバッファプールを共有することもできる。バッファプールでは、多くの場合、規格化されたサイズのメモリチャンクを1種類あるいは複数種類保持する。バッファプールは通信管理プログラム起動時にシステムから確保したメモリを使い回すため、バッファプールのメモリを使ったメモリの割当・解放はシステムコールを伴わず処理が軽い、頻繁で複雑なメモリ利用をしても、システムメモリのフラグメンテーションを引き起こさないなどの効果がある。バッファプールは起動時に適切量を確保するが、実行時に不足が起きてしまった場合は、その時点、あるいは、不足が予測された時点で、OSに負荷を与えてしまうので、可能であればある適当なタイミングを見計らって、OSにリクエストして追加のメモリを確保し、バッファプールを拡張することが望ましい。バッファプールが確保するメモリチャンクのメモリの種類やチャンクのサイズは利用形態で適切にチューニングする。第1のバッファで扱うメモリチャンクとしては、通常のヒープが管理する非ダイレクトバッファから平均的なイベントサイズより少し大きな単一サイズ(例えば256バイト)を選択する。第2のバッファで扱うメモリチャンクとしては、OSが扱いやすいサイズとタイプ、例えばページサイズ、あるいはページサイズの半分(例えば2KB)のダイレクトバッファを選択する。メモリプールのサイズは、OSからまとめて取得したバッファを小分けにして使うので、ページサイズやメモリ境界を意識して、ページサイズ、あるいは、ページサイズの2の累乗数分の1の値を採用し、25バイトや50バイトのような任意の値を採用しない。
 次に第1のバッファから第2のバッファへ移動するタイミングは、予め定めた時間間隔毎であってもよいし、第1のバッファ121b又は第1のバッファ121b内のチャンクに蓄積されたデータ量が予め定めた量になった場合であってもよいし、第1のバッファ121b又は第1のバッファ121b内のチャンク蓄積されたイベントの数が予め定めた数になった場合であってもよい。
 ソケット書込手段102の起動のトリガ、あるいは、第1のバッファ121bから第2のバッファ121bへのデータの移動のトリガは、ポーリングやタイマなどであってもよいし、すべてあるいは一部のアプリケーション書込手段105の実行直後であってもよい。
 なお、3段以上のバッファを使用する場合において、格段のバッファ間のデータの移動のタイミング、トリガ、移動方法などは、それぞれの段間で、上記記載の第1バッファと第2バッファについて記述した方法をそれぞれの段で独立に採用することができる。上記の例では移動の際に複数の操作(チャンクのメモリタイプの変更、チャンクサイズの変更、移動量の制限など)を同時に行ったが、操作を分割して、途中結果を追加のバッファとして保持することが考えられる。その場合には、移動のタイミング、トリガはすべての段で同じであってもよい。
 次に、ソケット書込手段102は、第2のバッファ121bのデータを読み出し、ソケットによってチャネル130に書き込む。データは、チャネル130を介してソース131に送信される。この時、データは第2のバッファ121bから取り出され、送信対象としてOS実行手段100が送信処理をし、送信が完了したデータ(取り出したデータの全部あるいは一部)については、第2のバッファ121bから削除される。送信が完了しなかったデータについては、引き続き第2のバッファ121bにとどまる。ここでは、第2のバッファ121bに蓄積されたデータを全部一度に送信するものとしたが、第2のバッファ121bに蓄積されているデータが巨大になった場合は、OS送信機能呼出の制限を考慮するなど、全部一度に読み出さず、一部だけを読み出して送信する制御をしてもよい。あるいは、第2のバッファ121bが蓄積するデータが巨大にならないように、第1のバッファ121bから第2のバッファ121bへ移動するイベントの数やバイト数を移動の際にあらかじめ制限してもよい。
 以下、アプリケーション実行手段103のスレッドで処理されたデータをOS実行手段100からネットワーク4に送信する場合について詳細に説明する。
(2)データ送信動作
 図10は、データ送信動作の一例を説明するための概略図である。スレッド1とスレッド2が、非同期にそれぞれイベントA,C,F,及びイベントB,D,Eを順次生成し、アプリケーション書込手段105、ソケット書込要求手段102aを呼び出し、それぞれのイベントA-Fをネットワーク4に送信する。アプリケーション書込手段105は、スレッド1及びスレッド2が生成したイベント1個を第1のバッファ121bに追加し、ソケット書込手段102aを呼び出す。ソケット書込手段102aは、OSカーネル100がすでにイベント処理を実行中の場合は処理を行わないで終了するが、OSカーネル100がイベント処理を実行中でない場合は、第1のバッファ121bが保持する0個以上のイベントを第2のバッファ121bへ移動し、第2のバッファ121bが保持するイベントについて、OSカーネル100にイベントの処理を依頼する。OSカーネル100がイベントの処理中であるかどうかの状態は、フラグ管理手段107が提供するCASフラグにより管理される。OSカーネル100は要求されたイベントの処理を完了すると、コールバックスレッド(スレッド1のコールバックスレッド)で、コールバック処理手段102bを、スレッド1及びスレッド2とも非同期に実行する。コールバックスレッドは、イベント処理の進捗状況を確認して、第2のバッファ121bを調整後(処理済のイベントを第2のバッファから削除したり、第1のバッファから第2のバッファへイベントを移動したりして)、ソケット書込手段aを再帰的かつ排他的に呼び出し、OSカーネル100が処理中に第1のバッファ121bに蓄積されたイベントについても、イベント処理を行う。コールバックスレッドは、ソケット書込要求手段102a及びコールバック処理手段102bの処理を繰り返して、中間バッファ121B(すなわち、第1のバッファ121b及び第2のバッファ121b)が保持するイベントがなくなるまで稼働する。
 アプリケーション実行手段103は、例えば、複数のスレッド1、スレッド2によりデータを処理し、処理結果のイベントA、イベントBを同一の端末装置(より厳密には、同一のソケットあるいはチャネル)に送信するために、当該イベントA、イベントBはアプリケーション書込手段105により送信先端末へ通信するソケットに対応する第1のバッファ121bに書き込まれる。スレッド1、スレッド2の処理は非同期に発生するものとする。第1のバッファ121bは、例えばスレッドセーフでノンブロッキングなリングバッファ(例えば、ノンブロッキングでスレッドセーフなFIFOキュー java.util.ConcurrentLinkedQueue にイベントを格納するメモリチャンクのポインタを登録することで実現可能)である。アプリケーション書込手段105は、イベントA、イベントBをスレッド毎に異なる領域(チャンク)にノンブロッキングにイベントを書き込む(1)(2)。特に、イベントのサイズのメモリチャンクの代わりに、規格化されたサイズのメモリチャンクを用いる場合は、メモリチャンクは、例えば、java.nio.ByteBufferを用いて、保管しているイベントの開始位置と終了位置も管理する。また、規格化されたサイズのメモリチャンクにイベントを保管する場合、チャンクサイズより大きなイベントについては、イベントを複数チャンクにわたるチャンクグループに保管し、チャンクグループへのポインタをリングバッファに追加してもよい。
 さて、まず、スレッド1のイベントAについては、アプリケーション書込手段105は第1のバッファ121bのイベントAの処理を要求すべくソケット書込要求手段102aを呼び出す(3)。ソケット書込要求手段102aは、呼出元がアプリケーション書込手段105なので、フラグ管理手段107のCASフラグを参照し、フラグが立っていないので、フラグを立てて(4)、第1のバッファ121bにイベントが蓄積されているか確認し、イベントがあるので第1のバッファ121bのイベントAを第2のバッファ121bへ移動する(5)。ここで、第2のバッファ121bも、第1のバッファ121b同様に、例えばノンブロッキングなリングバッファ(例えば、ノンブロッキングでスレッドセーフなFIFOキュー java.util.ConcurrentLinkedQueue にイベントを格納するメモリチャンクのポインタを登録することで実現可能)であってもよい。ただし、第2のバッファの操作を行うスレッドは、フラグ管理手段107により、高々1個に制御されているので、スレッドセーフでなくてもよい。また、ソケット書込要求手段102aは、イベントAを第2のバッファ121bへ移動した後、スレッド1に次の処理を進めるよう呼び出しを行い、処理はOSカーネル100にまかせて(6)、OSカーネル100の処理の完了をまたずに終了し、スレッド1の処理に戻る(7)。
 一方で、スレッド2のイベントBについては、アプリケーション書込手段105は第1のバッファ121bのイベントBの処理を要求すべくソケット書込要求手段102aを呼び出す(8)。ソケット書込要求手段102aは、呼出元がアプリケーション書込手段105なので、フラグ管理手段107のCASフラグを参照し(9)、この場合は先のイベントAの処理のためにすでにフラグが立っている(4)ため、もはやフラグをたてられない。ソケット書込要求手段102aは、処理ができるようになるまで待たず、ノンブロッキングで処理を終了してスレッド2の処理に戻る(10)。
 スレッド1については、アプリケーション実行手段103は、引き続きデータを処理し、アプリケーション書込手段105は処理結果のイベントCを第1のバッファ121bに書き込む(11)。第1のバッファ121bは、未処理のイベントBとイベントCを保持している(11)。スレッド1のイベントCについては、アプリケーション書込手段105は第1のバッファ121b1のデータ(追加したデータCだけでなく、すでに追加されているデータBも)の処理を要求すべくソケット書込要求手段102aを呼び出す(50)。ソケット書込要求手段102aは、呼出元がアプリケーション書込手段105なので、フラグ管理手段107のCASフラグを参照し、この場合は先のデータAの処理のためにすでにフラグが立っている(4)ため、もはやフラグをたてられない。ソケット書込要求手段102aは、処理ができるようになるまで待たず、ノンブロッキングでソケット書込要求手段102aの処理を終了してスレッド1の処理に戻る。
 スレッド1のイベントAのネットワーク送信については、具体的には、ソケット書込要求手段102aが、OSカーネル100に処理をまかせる(6)際には、OSシステムコール(例えばJAVAのAsynchronousSocketChannel.write())呼び出しを行い、第2のバッファ121bに存在するイベントA(12)を指定して送信要求する。ソケット書込要求手段102aは、第2のバッファ121bのイベントAをOS実行手段100(OSカーネル)に書き込み要求をして終了し、スレッド1の処理に戻る(7)。
 スレッド1のイベントAのネットワーク送信については、送信依頼されたOSカーネル100は、第1の実施の形態と同様に、イベントAを適切なサイズに分割してイベントA1、A2を送信する(13)。分割のサイズ、分割の個数、送信間隔はOSやネットワークの負荷などに依存する。
 また、一方で、スレッド2のイベントBについて、OSカーネル100がイベントAの処理中に、アプリケーション書込手段105は、第1のバッファ121bのイベントBを処理すべく、引き続きソケット書込要求手段102aを呼び出す(8)が、ソケット書込要求手段102aは、まだイベントAが処理中(4)でフラグ管理手段107のCASフラグが立っている(9)のでソケット書込要求手段102aは第1のバッファ121bのイベントBを第2のバッファ121bへ移動せず、アプリケーション書込手段105は処理を終了し、スレッド2は次の処理を進める(10)。この時点では、第1のバッファ121bには、イベントB、Cが蓄積されており、まだイベントDは生成されていない(11)。アプリケーション実行手段103は、スレッド2によりデータを処理して、後のタイミングでイベントDを生成する。
 次に、スレッド1よりイベントAの送信依頼されたOSカーネル100は、イベントAの送信を完了すると、コールバック処理手段102bをスレッド1のコールバックスレッドとして起動して(14)、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントA全体が送信完了しているので、第1のバッファ121bからイベントAを削除する(15)。この時点で第1のバッファ121bにはイベントB、Cが存在する(11)。その後、コールバック処理手段102bは、ソケット書込要求手段102aを呼び出す(16)。
 引き続き、コールバックスレッドにおいて、ソケット書込要求手段102aは、第1のバッファ121bにイベントが蓄積されているか確認し、イベントがあるので第1のバッファ121bのイベントB、Cを第2のバッファ121bへ移動する(17)。ここでは、第2のバッファ121b2の容量に十分余裕があるので、第1のバッファ121b1のイベントすべてを移動したが、第2のバッファ121b2の容量などを考慮して、第1のバッファ121b1が蓄積するイベントの一部だけ(例えばイベントBだけ)を移動してもよい。たまたま、この後のタイミングで、スレッド2のイベントDについて、アプリケーション書込手段105は処理結果のイベントDを第1のバッファ121bに書き込む(18)。この時点では、第1のバッファ121b1はイベントDだけを保持している。
 さて、スレッド1のイベントCについては、引き続きソケット書込要求手段102aを呼び出すが、フラグ管理手段107のCASフラグが立っているので、ソケット書込要求手段102aは第1のバッファ121bのイベントB、イベントCを第2のバッファ121bへ移動せず、アプリケーション書込手段105は処理を終了し、スレッド1に戻り処理を進める(19)。アプリケーション実行手段103は、スレッド1によりデータを処理し、後のタイミングでイベントFを生成する(20)。また、この第1バッファ121b1のイベントBとイベントCについては、前述したように、後のタイミングで、コールバックスレッドによりイベント処理が行われることになる。
 次に、コールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bの場合なので、引き続きOSシステムコール呼び出しを行い、第2のバッファ121bのイベントBとイベントCを送信要求する(21)。ソケット書込要求手段102aは、第2のバッファ121bのイベントBをOS実行手段100(OSカーネル)に書き込み要求をしてコールバックスレッドを終了する。
 次に、コールバックスレッドよりイベントB、Cの送信依頼をされたOSカーネル100は、イベントB及びイベントCを適切なサイズに分割してネットワークに送信する。まずイベントBを3分割してイベントB1、B2、B3と送信して、終了(OSカーネルは処理を完了)する。イベントBのみ送信してイベントCを送信しない理由、あるいはイベントBの一部でなくイベントB全体を送信した理由は、OSの都合であり、サーバ装置1又はネットワーク4の負荷などの状況による(22)。
 また、スレッド2のイベントDについて、スレッド1のコールバックスレッドに依頼されたOSカーネル100のイベント処理中に、アプリケーション書込手段105は、第1のバッファ121bのイベントDを処理すべく、引き続きソケット書込要求手段102aを呼び出す(23)が、ソケット書込要求手段102aはイベントB、Cの処理中(16)でフラグ管理手段107のCASフラグが立っている(24)のでソケット書込要求手段102aは第1のバッファ121bのイベントDを第2のバッファ121bへ移動せず、アプリケーション書込手段105は終了し、スレッド2に戻り次の処理を進める(25)。アプリケーション実行手段103は、引き続きスレッド2によりデータを処理して、後のタイミングでイベントEを生成する(26)。この時点で、第1のバッファ121bには、イベントDが蓄積(18)されており、まだイベントEは生成されていない。
 次に、コールバックスレッドよりイベントB、Cの送信依頼をされたOSカーネル100は、イベントBの送信を完了すると、コールバック処理手段102bを起動して(27)、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントB全体が送信完了しているので、第1のバッファ121bからイベントBを削除する。
 この時点で、スレッド2は、イベントEを生成し、アプリケーション書込手段105によりイベントEを第1のバッファ121bに書き込む。第1のバッファ121bにはイベントD、Eが存在する(28)。スレッド2において、イベントEを生成(26)したアプリケーション書込手段105は、ソケット書込要求手段102aを呼び出す(30)。ソケット書込要求手段102aは、まだイベントC及びイベントDの処理中(27)でフラグ管理手段107のCASフラグが立っている(31)のでソケット書込要求手段102aは第1のバッファ121bのイベントD及びEを第2のバッファ121bへ移動せず、アプリケーション書込手段105は処理を終了しスレッド2に戻り、スレッド2は次の処理を進める(32)。
 スレッド1のコールバックスレッドよりイベントB、Cの送信依頼をされたOSカーネル100が、イベントBの送信を完了後に、再び、スレッド1のコールバックスレッドを起動し、起動したコールバック処理手段102bは、再び、ソケット読み込み要求手段102aを呼び出す(29)。ソケット書込要求手段102aは、第1のバッファ121bにイベントが蓄積されているか確認し、イベントがあるので第1のバッファ121bのイベントD、E(28)を第2のバッファ121bへイベントを移動する(33)。この時点で、第2のバッファ121b2はイベントC、D、Eを保持する。
 次に、スレッド1のコールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bなので、OSシステムコール呼び出しを行い、第2のバッファ121bのイベントC、D、EをOSに送信要求してコールバックスレッドを終了(34)する。
 次に、OSカーネル100は、イベントC,D,Eを送信しようとする。まずイベントCを適切なサイズに分割(C1,C2,C3)してイベントC1、C2を送信して終了(OSカーネルは処理を完了)する(35)。イベントCの一部(C1,C2)のみを送信(35)して、残りのイベントC(C3)、イベントD、イベントEを送信しない理由は、前述したようにOSの都合である。この時点で、第1のバッファ121bには、イベントFが蓄積されている。
 次に、OSカーネル100は、イベントCの一部の送信を完了すると、再び、スレッド1のコールバックスレッドとして、コールバック処理手段102bを起動(36)して、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントCのうちC1、C2が送信完了しているので、第2のバッファ121bからイベントCのうちC1、C2に相当する部分を削除する。Cが単一のチャンクに格納されている場合、C3の送信が完了するまではチャンク全体のメモリ解放はできない。例えば、java.nio.ByteBufferを用いて送信開始位置と送信終了位置を管理する場合、C全体の解放はC3の処理終了後とし、C1,C2の完了は、送信開始位置をC1からC3に移動すればよい。そして再び、ソケット書込要求手段102aを呼び出す(37)。
 次に、コールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bなので、第1のバッファ121bにイベントが蓄積されているか確認するが、イベントFが蓄積されていたので、イベントFを第2のバッファ121b2へ移動する。イベントFは第1のバッファ121b1から第2のバッファ121b2へ移動し、第1のバッファはイベントがなくなり(38)、第2のバッファはイベントC3、D、E、F(39)を保持する。ソケット書込要求手段102aは、引き続き、OSシステムコール呼び出しを行い、第2のバッファ121bのイベントC3、D、E、F(39)をOS実行手段100(OSカーネル)に書き込み要求をしてコールバックスレッドを終了する(40)。
 次に、イベントC3、D、E、Fの送信依頼されたOSカーネル100は、イベントC、Dを適切なサイズに分割してイベントC3、D1、D2を送信する(41)。イベントC3とDのみ送信してイベントE、Fを送信しない理由は、前述したようにOSの都合である。
 次に、イベントC3、D、E、Fの送信依頼されたOSカーネル100は、イベントC、Dの送信を完了すると、コールバックスレッドとして、コールバック処理手段102bを起動して(42)、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントCのうちC3が、イベントDのすべてが送信完了しているので、第2のバッファ121bからイベントC3(あるいはイベントC全体)およびイベントDを削除する。そして再び、ソケット書込要求手段102aを呼び出す(43)。
 次に、コールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bなので、まず第1のバッファ121bにイベントが蓄積されているか確認し、イベントがない(38)ので第2のバッファ121bにイベントを移動せず、OSシステムコール呼び出しを行い、第2のバッファ121bのイベントE、F(44)をOS実行手段100(OSカーネル)に書き込み要求をしてコールバックスレッドを終了する(45)。
 次に、イベントE、Fの送信依頼されたOSカーネル100は、イベントE、Fを適切なサイズに分割してイベントE1、E2、Fを送信する(46)。
 次に、イベントE、Fの送信依頼されたOSカーネル100は、イベントE、Fの送信を完了すると、コールバックスレッドとして、コールバック処理手段102bを起動して(47)、コールバック処理手段102bは送信完了したバイト数を確認し、この場合はイベントE、Fのすべてが送信完了しているので、第2のバッファ121bからイベントE、Fを削除する。そして再び、ソケット書込要求手段102aを呼び出す(48)。
 その後、コールバックスレッドにおいて、ソケット書込要求手段102aは、呼出元がコールバック処理手段102bなので、第1のバッファ121b及び第2のバッファ121bを順に確認するが、第1のバッファ121b及び第2のバッファ121bのいずれにもイベントがなくなっているので、フラグ管理手段107のCASフラグを解除(49)し、コールバックスレッドを終了する。
(第2の実施の形態の効果)
 上記した第2の実施の形態によれば、アプリケーション書込手段105とソケット書込手段102の間に中間バッファ121Bを設け、中間バッファ121Bの第1のバッファ121bはアプリケーション書込手段105の書込データをスレッド毎にノンブロッキングに蓄積して、ソケット書込要求手段102aの書込動作をCASフラグに応じて実行し、CASフラグをフラグ管理手段107によって管理し、ソケット書込要求手段102aの書込開始でフラグを立て、OS実行手段100のイベント処理完了の通知を受けたコールバック処理手段102bがフラグを解除するとともに、第1のバッファ121bにイベントが存在する場合は第2のバッファ121bにイベントをまとめるなどOS実行手段の処理に適した形式に変換した上で移動してからOS実行手段100により第2のバッファ121bのイベントを処理するようにしたため、アプリケーション書込手段105の書き込み動作がOS実行手段100の送信イベント処理の動作に直接影響を及ぼさないようになり(アプリケーション書込手段105、OS実行手段100がそれぞれに対応するための待ち時間がなくなり、また、イベントごとにOS実行手段100を呼び出す場合に比べてOS実行手段100の呼出回数が削減され)、アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化することができる。特に、所要時間の比較的長いネットワークへの送信処理を、ウェイト時間(レイテンシ)短く、なるべく連続処理、かつ、ノンブロッキングに実行することで、ネットワーク送信処理を優先し、送信スループットを上げつつ、非同期送信(NIO)の処理待ちの間の時間にアプリ処理をノンブロッキングに並列実行することができる。
(変形例)
 上記した第2の実施の形態において、ソケット書込要求手段102aを、アプリケーション書込手段105からの呼び出しにのみ応じてOS実行手段100にイベント処理を要求するソケット書込要求手段102aと、コールバック処理手段102bの呼び出しにのみ応じてOS実行手段100にイベント処理を要求するソケットフラッシュ書込手段102aとに分けてもよい。この場合、図11のステップS40が不要となり、図12のステップS53が「OS実行手段100にイベント処理を要求する」に変わり、図13の動作をソケットフラッシュ書込手段102aが担うこととなる。このように実装した場合についても第2の実施の形態と同様の上記効果を奏する。
[他の実施の形態]
 なお、本発明は、上記実施の形態に限定されず、本発明の趣旨を逸脱しない範囲で種々な変形や組み合わせが可能である。
 (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に依頼するのではなく、確保済のメモリを再利用するバッファプールは一般的である。メモリのフラグメンテーションやそれに伴うガベージコレクションを回避し、メモリの再利用を促進するには、バッファプールは、規格化したメモリチャンクの集合として管理し、アプリケーションが使用するメモリサイズに応じて、必要個数のチャンクを結合して使うのも一般的である。仮想的にリングバッファを実現するには、メモリのバファプールを用いるのがよい。チャンクのサイズや個数、また、使用するメモリの種類(ダイレクトバファであるか非ダイレクトバッファであるか)は適用するアプリケーションにより適切に選択するものであり、実施例及びその変形として開示した手法による選択に限定されるものではない。
 図5は、レイヤ構成の変形例を示す概略図である。
 例えば、本願は、OSI(Open Systems Interconnection)参照モデルの7層のうち、アプリケーション層(アプリケーション112)とプレゼンテーション層及びセッション層(通信管理プログラム111)との間にバッファ(a)を設けた例を説明したが、イ~オの異なる層構成で、異なる位置にバッファ(b)~(e)を設けてもよい。
 ここで、送信スループットを上げるためには、下位の送信に関するレイヤで待ち、下位のレイヤでレイテンシが発生しないためには、上位のアプリは下位への依頼・呼出はロックフリー(ノンブロッキング)であることが望ましい。上位から下位へはなんらかの集約が発生するので、マルチタスク環境では各スレッドのデータが混ざらないように通常はなんらかの排他制御が必要となる。排他制御にOSの「ロック(Mutex)」を使用すると処理負荷が重くなるため、ロックフリーなアルゴリズムが望ましい。特にゲームサーバのように、同期のためのパケットをストリーミングのように大量に他頻度に送信するような場合は、パケット送信単位でロックがかかるのは望ましくない。ウ~オではOSの排他制御は使えないため、アプリケーションによる排他制御を独自に行う必要がある。
 ア(第1の実施の形態および第2の実施の形態)の場合、Java VM(仮想OS)によって作成されたTCP又はUDP(User Datagram Protocol)チャネルにデータを順次送信する。同一チャネルを複数スレッドで利用する場合には排他制御が必要となる。RUDP(Reliable User Datagram Protocol)の場合は、UDPソケットを使うアプリがACK(肯定応答)や再送などの信頼性保証のレイヤを独自に作成する必要がある。
 イの場合、アとの相違点は仮想OSかNative OSかの違いであるため、アとほぼ同じ構成、動作で実現可能である。
 ウの場合、ステートレス(コネクションレス)なUDPで実現可能性がある。OSの内部のレイヤを直接呼び出すことは、通常できないため実現可能性は低いが、直接呼び出す構成があれば可能となる。複数のアプリケーション及びスレッドが、NICを共用する複数の送信先(端末装置)に対する通信全てについて集約が必要となる。
 エの場合、OSのプロトコルスタックをバイパスして高速化することができる。プロトコルスタックを独自に制作する必要がある。(例えばDPDK(Data Plane Development Kit)等を用いることができる。https://www.dpdk.org/)。NICドライバは、NDISではなく特殊となり、通常は特定のNICプロダクト依存となる。UDPの場合、データグラムとして、ソケットを介さずに直接送信が可能な場合もある。OSの内部のレイヤを直接呼び出すことは、通常できないため実現可能性は低いが、DPDKのように専用のNICドライバがあれば可能となる。ウ同様に、複数のアプリケーション及びスレッドが、NICを共用する複数の送信先(端末装置)に対する通信全てについて集約が必要となる。
 オの場合、アプリケーションが完全にハードウェア依存となるため、組込みシステムなど特殊用途以外で用いられる。ウ同様に、複数のアプリケーション及びスレッドが、NICを共用する複数の送信先(端末装置)に対する通信全てについて集約が必要となる。
 次に、各バッファ(a)~(e)について説明する。
 (a)の場合、一般的用法としてはJAVA限定、OS非依存のものとなり、ソケット単位でのマルチスレッドのアプリパケット(アプリ送信単位)が混ざらないように集約するものとなる。
 (b)の場合、一般的用法としては言語依存、OSに依存することもあり、(a)と同様となる。(a)経由の場合はそのままパラメータのパススルーで引き渡してもよいし、分散書込の場合は、送信バイトバッファが連続領域にあれば一つの送信バッファにまとめるなどの最適化をしてもよい。ここで、分散書込とは、例えばJavaのAsynchronousSocketChannel.write()の機能で、1つ以上の可変長のデータブロックをグループ化した複数のバッファを指定して送信要求するものを指す。
 (c)の場合、通常はOS内部、OSカーネルの作業となり、アプリは横断的に対応してプロトコルごとに集約する。なお、プロトコルヘッダの追加が必要となる。TCPソケットに書かれた時点でコネクションごとのデータストリーム状態、アプリパケットの送信単位の境界は問題としない。適当な大きさに分割して、プロトコルドライバに渡す。その際に、データのコピーや詰替えが発生する可能性がある。UDPソケットの場合は、コネクションレスのため、ソケットに書きまれればバッファリングされずに送信され、まとめて送ることはない。RUDPで複数のデータをまとめて送る場合には、UDPソケットに書き込む前にまとめてから書き込む。
 (d)の場合、通常はOS内部、プロトコルドライバの作業となり、アプリは横断的に対応して、各種プロトコルをNICごとに集約する。なお、プロトコルヘッダの追加が必要となる。各パケットの結合、分割、プロトコルヘッダを追加した、全データをNICごとに集約する。
 (e)の場合、NIC内部の作業となる。ネットワークタイプに応じた分割、結合、圧縮などの加工、ヘッダなどの追加をして、ビット列に対応する電気信号に変換して、通信回線に送信する。
 上記実施の形態では制御部10の各手段100~107の機能をプログラムで実現したが、各手段の全て又は一部をASIC等のハードウェアによって実現してもよい。また、上記実施の形態で用いたプログラムをCD-ROM等の記録媒体に記憶して提供することもできる。また、上記実施の形態で説明した上記ステップの入れ替え、削除、追加等は本発明の要旨を変更しない範囲内で可能である。また、各手段の機能は適宜他の手段に結合してもよいし、複数の手段に分離してもよい。
 上記実施の形態では、主にネットワークの送信イベントの処理について記述したが、本発明は、処理する対象のイベントをネットワーク送信イベントのみに限定するものではない。本発明の各手段のすべて又は一部は、ネットワークの送信以外のイベント処理、特にOS機能に処理操作を依頼する比較的長時間を要する処理(OS機能が非同期処理を可能とするために処理要求手段とコールバック手段とを提供する処理、典型的には各種I/O操作)、より具体的には、ネットワークやディスクなど各種メディアなどに対する出力操作に、対応する要求手段とコールバック手段を差し替えることで、適用できる。また、OS機能を順次複数回呼び出してイベント処理するには、本発明のイベント処理の仕組みを複数段組み合わせることができる。
[1]コンピュータを、
 1以上のイベントを蓄積するバッファリング手段と、
 前記蓄積したイベントを処理する処理手段と、
 呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段として機能させ、
 前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理手段とを含み、
 前記フラグ管理手段は、前記処理手段のイベントの処理の開始のタイミングで排他的にフラグを立て、前記コールバック処理手段の終了のタイミングでフラグを解除し、
 前記処理要求手段は、前記バッファリング手段に対する蓄積及び前記コールバック処理手段の終了のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する通信管理プログラム。
[2]前記バッファリング手段は、ノンブロッキングキューに前記イベントを蓄積する前記[1]に記載の通信管理プログラム。
[3]前記バッファリング手段は、メモリプールに前記イベントを蓄積する前記[1]又は[2]に記載の通信管理プログラム。
[4]前記バッファリング手段は、リングバッファに前記イベントを蓄積する[1]又は[2]に記載の通信管理プログラム。
[5]1以上のイベントを蓄積するバッファリング手段と、
 前記蓄積したイベントを処理する処理手段と、
 呼び出しを受け付けて排他的にフラグを立てるフラグ管理手段とを有し、
 前記処理手段は、イベントの処理を要求する処理要求手段と、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理手段とを含み、
 前記フラグ管理手段は、前記処理手段のイベントの処理の開始のタイミングで排他的にフラグを立て、前記コールバック処理手段のイベントの処理の終了のタイミングでフラグを解除し、
 前記処理要求手段は、前記バッファリング手段に対する蓄積及び前記コールバック処理手段の終了のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する情報処理装置。
[6]1以上のイベントをノンブロッキングに蓄積するバッファリングステップと、
 前記蓄積したイベントを処理する処理ステップと、
 呼び出しを受け付けて排他的にフラグを立てるフラグ管理ステップとを有し、
 前記処理ステップは、イベントの処理を要求する処理要求ステップと、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理ステップとを含み、
 前記フラグ管理ステップは、前記処理ステップのイベントの処理の開始のタイミングで排他的にフラグを立て、前記コールバック処理ステップのイベントの処理の終了のタイミングでフラグを解除し、
 前記処理要求ステップは、前記バッファリングステップに対する蓄積及び前記コールバック処理手段の終了のタイミングで呼び出しを受け付けて、前記フラグ管理手段のフラグに応じて当該フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は前記バッファリング手段が蓄積した前記イベントを処理する通信管理方法。
 アプリケーション処理及びデータの送信をノンブロッキングに実行して通信を高速化する情報処理プログラム、情報処理装置及び情報処理方法を提供する。
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    :中間バッファ
121b   :第1のバッファ
121b   :第2のバッファ
130     :チャネル
131     :ソース

Claims (16)

  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.  コンピュータにおいて実行される情報処理方法であって、
     処理対象とするイベントを蓄積するイベント蓄積ステップと、
     前記イベントを蓄積するバッファリングステップと、
     前記蓄積したイベントを処理する処理ステップと、
     呼び出しを受け付けて排他的にフラグを立てるフラグ管理ステップとを有し、
     前記処理ステップは、イベントの処理を要求する処理要求ステップと、イベントの処理を完了した場合に完了通知を受けて実行するコールバック処理ステップとを含み、
     前記フラグ管理ステップは、前記処理要求ステップにおけるイベントの処理の開始前のタイミングで排他的にフラグを立て、前記コールバック処理ステップにおける処理の終了後のタイミングでフラグを解除し、
     前記処理要求ステップは、前記イベント蓄積ステップにおけるイベント蓄積終了後のタイミング及び前記コールバック処理ステップにおけるイベント処理終了後のタイミングで呼び出しを受け付けて、前記フラグが、立てられなかった場合は処理をせずに終了し、立てられた場合は蓄積した前記イベントを処理する情報処理方法。
     
     
PCT/JP2022/025042 2021-07-30 2022-06-23 情報処理プログラム、情報処理装置及び情報処理方法 WO2023008008A1 (ja)

Priority Applications (4)

Application Number Priority Date Filing Date Title
CN202280004572.XA CN115917519B (zh) 2021-07-30 2022-06-23 存储有信息处理程序的记录介质、信息处理装置和信息处理方法
KR1020227044708A KR102521873B1 (ko) 2021-07-30 2022-06-23 정보 처리 프로그램, 정보 처리 장치, 및 정보 처리 방법
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 (4)

Application Number Priority Date Filing Date Title
JP2021125358A JP6998000B1 (ja) 2021-07-30 2021-07-30 通信管理プログラム、情報処理装置及び通信管理方法
JP2021-125358 2021-07-30
JP2021200032A JP7061301B1 (ja) 2021-12-09 2021-12-09 情報処理プログラム、情報処理装置及び情報処理方法
JP2021-200032 2021-12-09

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/071,627 Continuation US11762663B2 (en) 2021-07-30 2022-11-30 Information processing program, information processing device, and information processing method

Publications (1)

Publication Number Publication Date
WO2023008008A1 true WO2023008008A1 (ja) 2023-02-02

Family

ID=85087867

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2022/025042 WO2023008008A1 (ja) 2021-07-30 2022-06-23 情報処理プログラム、情報処理装置及び情報処理方法

Country Status (5)

Country Link
US (1) US11762663B2 (ja)
EP (1) EP4152168A4 (ja)
KR (1) KR102521873B1 (ja)
CN (1) CN115917519B (ja)
WO (1) WO2023008008A1 (ja)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0962772A (ja) * 1995-08-25 1997-03-07 Oki Electric Ind Co Ltd 文字認識装置
JP2010055214A (ja) 2008-08-26 2010-03-11 Sanyo Electric Co Ltd データ処理装置
JP2017062540A (ja) * 2015-09-24 2017-03-30 富士ゼロックス株式会社 片方向オペレーティングシステム間通信システム及びプログラム
CN112579097A (zh) * 2020-12-21 2021-03-30 广州博冠信息科技有限公司 软件项目构建方法、装置、存储介质及电子设备
CN112667217A (zh) * 2019-10-16 2021-04-16 上汽通用汽车有限公司 一种基于智能车联网架构的车端开发模块

Family Cites Families (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07281930A (ja) * 1994-04-08 1995-10-27 Nec Corp 情報処理装置動作測定解析システム
US7127535B1 (en) * 1996-11-22 2006-10-24 Veritas Operating Corporation System and method for multiplexed data back-up
US6243769B1 (en) * 1997-07-18 2001-06-05 Micron Technology, Inc. Dynamic buffer allocation for a computer system
US6073190A (en) * 1997-07-18 2000-06-06 Micron Electronics, Inc. System for dynamic buffer allocation comprising control logic for controlling a first address buffer and a first data buffer as a matched pair
JP4086345B2 (ja) * 1997-09-09 2008-05-14 キヤノン株式会社 通信制御方法及び装置及び通信システム
US6058434A (en) * 1997-11-26 2000-05-02 Acuity Imaging, Llc Apparent network interface for and between embedded and host processors
US20020031132A1 (en) * 2000-05-25 2002-03-14 Mcwilliams Patrick UTOPIA-LVDS bridge
JP4345559B2 (ja) * 2004-04-15 2009-10-14 ソニー株式会社 情報処理装置および情報処理方法、並びにプログラムおよびプログラム記録媒体
JP2006004042A (ja) * 2004-06-16 2006-01-05 Renesas Technology Corp データ処理装置
US20080126625A1 (en) * 2006-07-17 2008-05-29 International Business Machines Corporation Just-in-time buffer allocation for use in event completion style input/output models
JP2009015429A (ja) * 2007-07-02 2009-01-22 Nec Corp データ処理装置、データ処理方法、およびデータ処理プログラム
WO2011158320A1 (ja) * 2010-06-14 2011-12-22 富士通株式会社 マルチコアプロセッサシステム、キャッシュコヒーレンシ制御方法、およびキャッシュコヒーレンシ制御プログラム
KR101876574B1 (ko) * 2012-02-02 2018-07-09 에스케이하이닉스 주식회사 데이터 입출력 컨트롤러 및 이를 포함하는 시스템
JP6040840B2 (ja) 2013-03-29 2016-12-07 富士通株式会社 演算処理装置、情報処理装置及び情報処理装置の制御方法
JP5718974B2 (ja) * 2013-05-22 2015-05-13 日本電信電話株式会社 情報処理装置、情報処理方法、および、情報処理プログラム
JP6351363B2 (ja) * 2013-08-01 2018-07-04 キヤノン株式会社 通信装置およびそのデータ処理方法
CN103501245B (zh) * 2013-09-26 2017-02-08 北京搜狐互联网信息服务有限公司 一种网络事件处理方法及装置
GB2563384B (en) * 2017-06-07 2019-12-25 Advanced Risc Mach Ltd Programmable instruction buffering
JP2019067301A (ja) * 2017-10-04 2019-04-25 株式会社日立製作所 プログラム実行装置およびプログラム実行方法
CN112667212A (zh) * 2020-12-29 2021-04-16 中国平安人寿保险股份有限公司 埋点数据可视化方法、装置、终端和存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0962772A (ja) * 1995-08-25 1997-03-07 Oki Electric Ind Co Ltd 文字認識装置
JP2010055214A (ja) 2008-08-26 2010-03-11 Sanyo Electric Co Ltd データ処理装置
JP2017062540A (ja) * 2015-09-24 2017-03-30 富士ゼロックス株式会社 片方向オペレーティングシステム間通信システム及びプログラム
CN112667217A (zh) * 2019-10-16 2021-04-16 上汽通用汽车有限公司 一种基于智能车联网架构的车端开发模块
CN112579097A (zh) * 2020-12-21 2021-03-30 广州博冠信息科技有限公司 软件项目构建方法、装置、存储介质及电子设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4152168A4

Also Published As

Publication number Publication date
US11762663B2 (en) 2023-09-19
CN115917519B (zh) 2023-09-08
US20230205536A1 (en) 2023-06-29
KR102521873B1 (ko) 2023-04-13
EP4152168A1 (en) 2023-03-22
CN115917519A (zh) 2023-04-04
KR20230019252A (ko) 2023-02-07
EP4152168A4 (en) 2024-05-08

Similar Documents

Publication Publication Date Title
US11762581B2 (en) Method, device, and system for controlling data read/write command in NVMe over fabric architecture
US6418478B1 (en) Pipelined high speed data transfer mechanism
US10387202B2 (en) Quality of service implementation in a networked storage system with hierarchical schedulers
EP0891585B1 (en) A method and apparatus for client managed flow control on a limited memory computer system
KR101006260B1 (ko) 네트워크 프로토콜 처리의 오프로드에서 메모리 관리를 지원하기 위한 장치 및 방법
KR100992282B1 (ko) 통신 접속 수립 방법과 시스템, 데이터 전송 방법과 시스템, 및 컴퓨터 판독 가능한 저장 매체
US7054925B2 (en) Efficient method for determining record based I/O on top of streaming protocols
US11411885B2 (en) Network-accessible data volume modification
US20040003085A1 (en) Active application socket management
EP2618257B1 (en) Scalable sockets
CN113709131B (zh) 一种网络数据传输方法、装置、计算机设备及可读介质
CN111459417A (zh) 一种面向NVMeoF存储网络的无锁传输方法及系统
US20230281141A1 (en) Method for order-preserving execution of write request and network device
WO2023008008A1 (ja) 情報処理プログラム、情報処理装置及び情報処理方法
CN110445580B (zh) 数据发送方法及装置、存储介质、电子装置
WO2023221990A1 (zh) Udp报文的分发方法、设备及可读存储介质
JP7061301B1 (ja) 情報処理プログラム、情報処理装置及び情報処理方法
CN108347341A (zh) 一种用于调整虚拟机加速能力的加速能力调整方法及装置
WO2022151766A1 (zh) 一种io请求流水线处理设备、方法、系统及存储介质
JP6998000B1 (ja) 通信管理プログラム、情報処理装置及び通信管理方法
CN109478151B (zh) 网络可访问数据卷修改
US8792351B1 (en) Method and system for network communication
Ostrowski et al. Scalable publish-subscribe in a managed framework
KR19980086586A (ko) Tcp/ip 소켓 애플리케이션을 이용한 시스템 자원 저감 툴

Legal Events

Date Code Title Description
ENP Entry into the national phase

Ref document number: 2022808933

Country of ref document: EP

Effective date: 20221130

ENP Entry into the national phase

Ref document number: 20227044708

Country of ref document: KR

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE