Efficient logging method for multiple channels of futures counter

By adopting a multi-channel efficient logging method in the futures counter system, the slow log and fast log of each thread are independently processed, and the performance bottleneck caused by locking the log system under multi-threads is solved, the system's processing performance is improved and the formatted write files is supported.

CN119597684APending Publication Date: 2025-03-11ACCELECOM INFORMATION & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411626663.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

In a multi-threaded scenario, the uplink and downlink processing performance of the futures counter system is affected due to locking in multi-threaded scenarios.

Method used

Using multi-channel efficient logging method, each thread channel module registers slow logs and fast log channels, and registers fast log callback functions. The front end of the log system processes the slow log and fast log respectively and puts it into the corresponding channel. When the backend processes the slow log, writes the file to the file, and when processing the fast log, callback function is called to format it and writes it to the file.

Benefits of technology

Processing multi-threaded logs through independent channels avoids the bottleneck of locks, improves the processing performance of the futures counter system, and supports formatting and writing files to the required files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119597684A_ABST
    Figure CN119597684A_ABST
Patent Text Reader

Abstract

The invention provides an efficient logging method for multiple channels of a futures counter. S01, each thread channel module registers a slow log channel and a fast log channel, and registers a fast log callback function; s02, the log system front end of each line channel formats slow log parameters into a text and then puts the text into a slow channel. And S03, the log system front end of each line channel puts the fast log memory address into a fast channel. And step S04, writing the text into the file when the log system rear end of each line channel processes the slow log, calling a callback when the log system rear end processes the fast log, formatting the callback function into the text, and writing the text into the file. According to the efficient logging method for the multiple channels of the futures counter, the operation scene of the counter is distinguished, each thread is an independent channel, the problem of locking under multiple threads is solved, and meanwhile data of each log channel supports formatted file writing according to requirements.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] The invention belongs to the field of financial futures counters and relates to a multi-channel efficient log method for futures counters. Background Art

[0002] In the financial futures counter system, the transaction data volume is relatively large, and the performance requirements for entrustment requests and entrustment returns are extreme. In addition, the futures counter also requires recording each entrustment request and return data in a log file for record keeping. Conventional log systems are generally locked in multi-threaded scenarios, but this kind of locking will cause performance bottlenecks for the extreme performance of the counter and large data volumes, affecting the uplink and downlink processing performance of the counter system. Summary of the invention

[0003] 1. Technical problems to be solved: Conventional log systems in multi-threaded scenarios are generally locked, which affects the upstream and downstream processing performance of the counter system.

[0004] 2. Technical solution: In order to solve the above problems, the present invention provides an efficient logging method for multiple channels of a futures counter, comprising the following steps.

[0005] Step S01: Each thread channel module registers a slow log and a fast log channel, and registers a fast log callback function.

[0006] Step S02: The log system front end of each line channel formats the slow log parameters into text and puts it into the slow channel.

[0007] Step S03: The log system front end of each line channel puts the fast log memory address into the fast channel.

[0008] Step S04: The log system backend of each line channel writes the text to a file when processing slow logs, and calls a callback first when processing fast logs, and the callback function formats the text into a file after writing it.

[0009] Each thread module uses the slow log and fast log interfaces to record data and send data entries to their corresponding channels.

[0010] The log system front end of each line divides each log in the channel into two parts for processing: data header and data field; data header processing includes adding log length, level, type, thread ID, timestamp, slow log data field is text, and fast log data field is memory address.

[0011] For each slow log, the level, thread ID, timestamp and text content are added to the queue. For each fast log, a callback is executed, and the log is formatted into text and then added with the timestamp and thread ID and added to the queue. The log system backend of each line channel sorts the log entries by timestamp and takes the entries one by one from the sorted queue.

[0012] Each line channel has its own independent slow log and fast log channels, which do not interfere with each other. 3. Beneficial effects: The present invention provides an efficient logging method for multiple channels of a futures counter, which distinguishes the operation scenarios of the counter; each thread is an independent channel, which solves the locking problem under multiple threads, and at the same time, the data of each log channel supports writing into a file in the required format. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 is a schematic diagram of the method of the present invention DETAILED DESCRIPTION

[0014] The present invention is described in detail below with reference to the accompanying drawings.

[0015] like Figure 1 As shown, an efficient logging method for multiple channels of a futures counter includes the following steps: Step S01: Each thread channel module registers a slow log and a fast log channel, and registers a fast log callback function.

[0016] Logs with low performance requirements are called slow logs, and logs with high performance requirements are called fast logs. For example, uplink orders and downlink reports are fast logs.

[0017] In one embodiment, each thread channel module uses slow log and fast log interfaces to record data and send data entries to their respective corresponding channels without interfering with each other. Each thread is an independent channel, solving the locking problem under multi-threading.

[0018] In one embodiment, the counter system is divided into the front end and the back end. The front end only records the memory data, and the back end processes the data. This method is to defer more work to the back end for processing. At the same time, the slow log focuses more on the ease of use of the interface, and only the process of writing files is handed over to the back end. The fast log focuses on performance, and the process of formatting and writing files is handed over to the back end.

[0019] Step S02: The log system front end of each line channel formats the slow log parameters into text and puts it into the slow channel.

[0020] Step S03: The log system front end of each line channel puts the fast log memory address into the fast channel.

[0021] Step S04: The log system backend of each line channel writes the text to a file when processing slow logs, and calls a callback first when processing fast logs, and the callback function formats the text into a file after writing it.

[0022] In one embodiment, the front end of the log system of each line divides each log in the channel into two parts for processing: a data header and a data field; the data header processing includes adding the log length, level, type, thread ID, and timestamp. The slow log data field is text, and the fast log data field is a memory address. Adding header information such as timestamp, thread ID, and channel ID before the log can record the characteristics of the log, facilitate processing and analysis, and can also reorder the back-end logs based on this, which can avoid the log disorder problem caused by multi-channel printing logs.

[0023] In one embodiment, for each slow log front-end interface, the level, thread ID, timestamp and text content are added to the channel, and for each fast log front-end interface, the memory address, timestamp and thread ID are added to the channel. The log system back-end sorts the log entries of all line channels according to the timestamp, and takes the entry timestamp and text content from the sorted queue one by one for processing. For the slow log, it is directly printed to the file, and for the fast log, the callback function is called to print the fast log to the file in the required format.

[0024] Although the present invention has been disclosed as above in terms of preferred embodiments, they are not intended to limit the present invention. Anyone skilled in the art can make various changes or modifications without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection defined by the claims of this application.

Claims

1. An efficient logging method for multiple channels of a futures counter, comprising the following steps: Step S01: Each thread channel module registers the slow log and fast log channels, and registers the fast log callback function; Step S02: the log system front end of each line channel formats the slow log parameters into text and puts it into the slow channel; Step S03: The log system front end of each line channel puts the fast log memory address into the fast channel; Step S04: The log system backend of each line channel writes the text to a file when processing slow logs, and calls a callback first when processing fast logs, and the callback function formats the text into a file after writing it.

2. The efficient logging method for multiple channels of futures counters as claimed in claim 1, characterized in that: Each thread channel module uses the slow log and fast log interfaces to record data and send data entries to their corresponding channels.

3. The efficient logging method for multiple channels of futures counters as claimed in claim 1, characterized in that: The log system front end of each line divides each log in the channel into two parts for processing: data header and data field; data header processing includes adding log length, level, type, thread ID, timestamp, slow log data field is text, and fast log data field is memory address.

4. The efficient logging method for multiple channels of futures counters as claimed in claim 3, characterized in that: For each slow log, the level, thread ID, timestamp and text content are added to the queue. For each fast log, a callback is executed, and the log is formatted into text and then added with the timestamp and thread ID and added to the queue. The log system backend of each line channel sorts the log entries by timestamp and takes the entries one by one from the sorted queue.

5. The efficient logging method for multiple channels of futures counters as claimed in claim 1, characterized in that: Each line channel has its own independent slow log and fast log channels, which do not interfere with each other.