A method and an application of multi-process single-write multi-read lock-free shared memory

A shared memory, single write multiple read technology, applied in the direction of multi-program device, program control design, resource allocation, etc., can solve problems such as high overhead, performance impact, conflicts, etc., to improve data access performance, high-performance real-time data The effect of accessibility

Active Publication Date: 2019-02-01
JIANGSU SECURITIES
View PDF4 Cites 17 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

The key performance factor for data sharing between multiple processes through shared memory is the data synchronization mechanism. However, most in-memory databases currently improve data access performance by designing efficient locking mechanisms. These solutions can indeed meet the needs of most application s...

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • A method and an application of multi-process single-write multi-read lock-free shared memory
  • A method and an application of multi-process single-write multi-read lock-free shared memory
  • A method and an application of multi-process single-write multi-read lock-free shared memory

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0057] Embodiment 1: A method for multi-process single-write-multiple-read lock-free shared memory. When data is updated, first re-apply for an unused shared memory space from the shared memory pool for the data to be updated, and then write the data into After the memory space, modify the key value relationship of the data to ensure that the reading process can get the updated data, and at the same time, reclaim the memory of the old data area.

[0058] Further, the step of reapplying for an unused shared memory space from the shared memory for the data to be updated includes:

[0059] 1) Apply for shared memory space from the shared memory pool according to the steps of the memory management process;

[0060] The steps to write data into this memory space include:

[0061] 2) Initialize the ref field in the memory space to 0, initialize len to the data length data_len, and copy the data to be added / updated to the data area;

[0062] The steps for modifying the key-value re...

Embodiment 2

[0099] Embodiment 2: In order to further improve the data access performance of the shared memory, the present invention proposes a lock-free shared memory scheme, fully utilizes the characteristics of atomic operations, and completely avoids the use of locks from the design, so as to provide High-performance real-time data access capabilities. The core idea of ​​the present invention is: reapply for an unused shared memory space for the data to be updated from the shared memory, modify the key (key) value (value) relationship of the data after writing the data into the memory space, and ensure that the read The process can get the updated data; at the same time, the memory of the old data area will be reclaimed for the next memory allocation of new data or updated data, which is essentially a scheme of exchanging space for time. Since the key-value relationship is updated only after the data is updated, any data area will not be read and written at the same time, which can co...

Embodiment 3

[0181] Embodiment 3: as Figure 8 As shown, an embodiment of a multi-process single-write-multiple-read lock-free shared memory scheme of the present invention, we use the real-time market tick data of the A-share market (about 3400 stocks) as the target data, the data key is the stock code, the character String type, the market data structure has a fixed length of 984 bytes. The writing process receives market data in real time and writes it into the shared memory, and multiple reading processes frequently query the latest real-time market data from the shared memory, and the target securities to be queried are randomly distributed.

[0182] The operating environment of this embodiment is Windows7SP1 64-bit operating system, memory 8G, and CPU is Intel E5-2650 2.2GHz dual-core processor.

[0183] (1) Process initialization:

[0184] Start the write process, create and map the lock-free shared memory data structure, including three shared memory areas: shared data offset add...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

Aiming at the problems that multiple processes simultaneously read and write the same shared memory data area, the data is frequently updated, and the kernel lock causes serious performance loss, theinvention provides a multi-process single-write multi-read lockless shared memory method and application, which avoids the use of locks through data structure design and atomic operation. When the data is updated, a piece of unused shared memory space is re-applied from the shared memory for the data to be updated, and the data is written into the memory space and the data key value relationship is modified; At the same time, the presence of the old data area ensures that it is recycled when no thread reads, Memory allocation for the next new or updated data, As that key-value relationship isupdate only after the data is update, any data area is not read and written at the same time, and the use of the lock can be completely avoided. The invention fully utilizes the atomic operation characteristic and completely avoids the use of the lock, thereby realizing the real-time data access capability with high performance when the data is updated at high frequency. The shared memory data access performance is improved.

Description

technical field [0001] The present invention relates to a fast trading method for brokers based on a memory database, specifically a lock-free shared memory method in a multi-process single-write-multiple-read scenario, which is applied to real-time high-frequency data between multiple processes through shared memory technology Shared scenarios can be used as a technology for designing high-performance key-value in-memory databases. Background technique [0002] As my country's securities market matures, the proportion of professional investors such as institutions in the securities market will also increase. In mature stock markets such as Hong Kong and the United States, more than 70% of the transaction volume is completed by institutional investors. With the continuous growth of institutional clients and high-end clients of securities companies, the increasing number of programmatic transactions, the demand for fast and safe high-end channels is also becoming more and mor...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
IPC IPC(8): G06F9/50
CPCG06F9/5016
Inventor 邱小铭邢正俊吕正荣
Owner JIANGSU SECURITIES
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products