A data processing method and device, electronic equipment and storage medium

By determining the type of IO operation and processing it accordingly, synchronous operations are executed directly in the coroutine and pushed to the queue to wait for asynchronous operations. This solves the problem of high IO operation complexity in distributed storage systems and achieves more efficient IO processing.

CN115599287BActive Publication Date: 2025-11-21SANGFOR TECH INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110722964.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-28
Publication Date
2025-11-21
Estimated Expiration
2041-06-28

AI Technical Summary

Technical Problem

The high complexity of I/O operations in distributed storage systems leads to increased I/O latency, which is particularly noticeable when the workload is heavy.

Method used

By determining the type of I/O operation, synchronous operations are directly switched to a coroutine for execution, while asynchronous operations are pushed to a coroutine queue to await scheduling. For synchronous callback operations, they are also directly switched to a coroutine for execution, reducing the number of coroutine switches and enqueueing operations.

Benefits of technology

It reduces the complexity of I/O operations, reduces I/O latency, and improves the processing efficiency of I/O operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115599287B_ABST
    Figure CN115599287B_ABST
Patent Text Reader

Abstract

The application discloses a data processing method and device, an electronic device and a computer readable storage medium. The method comprises the following steps: receiving a submission request of an IO operation; judging whether the operation type of the IO operation is a synchronous type; if the operation type of the IO operation is the synchronous type, switching the IO operation to a coroutine for execution. The data processing method provided by the application can judge whether the operation type of the IO operation is the synchronous type when receiving the submission request of the IO operation. If the operation type is the synchronous type, the IO operation is directly switched to the coroutine for execution, and the IO operation does not need to be pushed to the coroutine queue for waiting, so that the number of coroutine switching times and the number of enqueue times are reduced, the path of the synchronous IO operation is shortened, the complexity of the synchronous IO operation is reduced, the processing efficiency of the IO operation is improved, and the IO time delay is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computers, and more particularly, to a data processing method and device, an electronic device, and a computer readable storage medium. BACKGROUND

[0002] Distributed storage systems have become the mainstream trend of storage systems. A distributed storage system is composed of distributed storage system software and hardware. In terms of hardware, a distributed storage system is composed of multiple storage hosts connected through a network. Each host often contains multiple storage devices, such as mechanical hard disks or solid state disks.

[0003] In the distributed storage system software, due to the need for a certain time delay for IO (Chinese: Input Output, English: Input Output) disk landing, in order to improve the utilization rate of threads, coroutines are widely used in IO submission tasks. In related technologies, IO operations need to push coroutine queues to wait for scheduling, resulting in high complexity of IO operations. When the business volume is large, the number of IO operations is large, and the coroutine queue is lengthened, resulting in an increase in IO time delay.

[0004] Therefore, how to reduce the complexity of IO operations and reduce IO time delay is a technical problem that needs to be solved by those skilled in the art. SUMMARY

[0005] The present application aims to provide a data processing method and device, an electronic device, and a computer readable storage medium, which reduce the complexity of IO operations and reduce IO time delay.

[0006] To achieve the above-mentioned purpose, the present application provides a data processing method, comprising:

[0007] receiving a submission request of an IO operation;

[0008] determining whether the operation type of the IO operation is a synchronous type;

[0009] if the operation type of the IO operation is a synchronous type, switching the IO operation to be executed in a coroutine.

[0010] Further comprising:

[0011] if the operation type of the IO operation is an asynchronous type, pushing the IO operation into a first coroutine queue, the first coroutine queue being used to wait for scheduling to execute the IO operation.

[0012] The pushing of the IO operation into the first coroutine queue comprises:

[0013] pushing the IO operation and the corresponding coroutine context into the first coroutine queue.

[0014] Correspondingly, the method further comprises:

[0015] If the IO operation is scheduled, the IO operation and the corresponding coroutine context are taken out from the first coroutine queue, and the execution in the coroutine is switched.

[0016] After the execution of the IO operation, the method further comprises:

[0017] If the callback operation corresponding to the IO operation is received, it is judged whether the operation type of the IO operation is a synchronous type.

[0018] If the operation type of the IO operation is the synchronous type, the callback operation is executed by using a target coroutine; wherein the target coroutine is the coroutine for executing the IO operation.

[0019] The method further comprises:

[0020] If the operation type of the IO operation is an asynchronous type, the callback operation is pushed into a second coroutine queue; wherein the second coroutine queue is used for waiting for scheduling to execute the callback operation.

[0021] The method further comprises:

[0022] The callback operation and the corresponding coroutine context are pushed into the second coroutine queue.

[0023] Correspondingly, the method further comprises:

[0024] If the callback operation is scheduled, the callback operation and the corresponding coroutine context are taken out from the second coroutine queue, and the execution in the coroutine is switched.

[0025] The method further comprises:

[0026] Based on the operation type mark of the IO operation, it is judged whether the operation type of the IO operation is a synchronous type; wherein the operation type mark is a parameter marked when the IO operation is created.

[0027] To achieve the above object, the application provides a data processing device, comprising:

[0028] A receiving module is configured to receive a submission request of an IO operation.

[0029] A first judging module is configured to judge whether the operation type of the IO operation is a synchronous type.

[0030] The switching module is configured to switch the IO operation to be executed in a coroutine when the operation type of the IO operation is a synchronous type.

[0031] To achieve the above object, the present application provides an electronic device, comprising:

[0032] a memory configured to store a computer program;

[0033] a processor configured to execute the computer program to implement the steps of the data processing method.

[0034] To achieve the above object, the present application provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the data processing method.

[0035] According to the above scheme, the data processing method provided by the present application comprises: receiving a submission request of an IO operation; judging whether the operation type of the IO operation is a synchronous type; and if the operation type of the IO operation is a synchronous type, switching the IO operation to be executed in a coroutine.

[0036] The data processing method provided by the present application, when receiving a submission request of an IO operation, first judges whether the operation type is a synchronous type, and if yes, directly switches to be executed in a coroutine, without being pushed to a coroutine queue to wait, thereby reducing the number of coroutine switching and the number of enqueuing, shortening the path of synchronous IO operation, reducing the complexity of synchronous IO operation, improving the processing efficiency of IO operation, and reducing the IO time delay. The present application also discloses a data processing device, an electronic device and a computer readable storage medium, which can also achieve the above technical effects.

[0037] It should be understood that the above general description and the following detailed description are only exemplary and cannot limit the present application. BRIEF DESCRIPTION OF DRAWINGS

[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description only some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creating any creative labor. The drawings are used to provide further understanding of the present disclosure and constitute a part of the specification, and are used to explain the present disclosure together with the following specific embodiments, but do not constitute a limitation to the present disclosure. In the drawings:

[0039] Figure 1 Flowchart of a one-time IO operation of a storage system in the related art;

[0040] Figure 2 a flow chart of a data processing method according to an example embodiment;

[0041] Figure 3 a flow chart of another data processing method according to an example embodiment;

[0042] Figure 4 a structural diagram of a data processing apparatus according to an example embodiment;

[0043] Figure 5 a structural diagram of an electronic device according to an example embodiment. DETAILED DESCRIPTION

[0044] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative labor fall within the scope of protection of the present application. In addition, in the embodiments of the present application, "first", "second", etc. are used to distinguish similar objects, not necessarily to describe a specific order or sequence.

[0045] The applicant of the present application has found that the IO operation complexity of a storage system is high in the related art. Specifically, the flow of one IO operation of the storage system in the related art is as shown in Figure 1 When submitting the IO, the current coroutine context is saved first, the IO operation and the corresponding coroutine context are pushed into the coroutine queue, and the scheduling of the coroutine queue is waited, corresponding to steps ① and ②. The coroutine queue processing function takes out the IO operation and the corresponding coroutine context from the coroutine queue, corresponding to step ③, switches to coroutine execution, corresponding to steps ④ and ⑤. After the current coroutine execution is completed, the next IO operation is processed in the coroutine queue, corresponding to step ⑥. When the IO operation is completed, the data and the coroutine context are pushed into the coroutine queue again through a callback, and the scheduling of the coroutine queue is waited, corresponding to steps ⑦ and ⑧.

[0046] As can be seen, in one IO operation, it needs to be enqueued twice, i.e. steps ② and ⑧, dequeued twice, i.e. step ③ is executed twice, switched into the coroutine twice, i.e. step ⑤ is executed twice, and switched out of the coroutine twice, i.e. step ⑥ is executed twice. In summary, in the related art, the IO operation complexity of the storage system is high, when the business volume is large, the number of IO operations is large, and the lengthening of the coroutine queue leads to the increase of the time delay of the IO.

[0047] Therefore, in the present application, when receiving the submission request of the IO operation, first determine the operation type thereof. For the IO operation of the synchronous type, directly switch to the execution in the coroutine, without pushing to the coroutine queue to wait, reducing the number of coroutine switching and the number of enqueuing, shortening the path of the synchronous IO operation, reducing the complexity of the synchronous IO operation, and reducing the IO delay. For the IO operation of the asynchronous type, push to the coroutine queue to wait for scheduling. In addition, for the callback operation corresponding to the IO operation of the synchronous type, also does not need to push to the coroutine queue to wait, but directly switches to the execution in the current coroutine, further reducing the number of coroutine switching and the number of enqueuing, shortening the path of the synchronous IO operation, reducing the complexity of the synchronous IO operation, and reducing the IO delay. For the callback operation corresponding to the IO operation of the asynchronous type, push to the coroutine queue to wait for scheduling.

[0048] The embodiment of the present application discloses a data processing method, which reduces the complexity of the IO operation and reduces the IO delay.

[0049] Referring to Figure 2 , a flow chart of a data processing method according to an exemplary embodiment is shown, as Figure 2 shown, comprising:

[0050] S101: receiving a submission request of an IO operation;

[0051] The embodiment can be applied to the read-write scene in the storage system with the storage medium of the SSD (Chinese full name: solid state disk, English full name: Solid State Disk). In the present step, the submission request of the IO operation is received. It can be understood that due to the difference of the storage medium, the IO operation can be divided into the synchronous IO and the asynchronous IO. The coroutine context of the synchronous IO is the current thread, while the coroutine context of the asynchronous IO can be in different threads. In the specific implementation, the operation type can be marked when the IO operation is created. For example, for the IO operation generated in the storage medium supporting only the synchronous type, the operation type is marked as the synchronous type, for the IO operation generated in the storage medium supporting only the asynchronous type, the operation type is marked as the asynchronous type, and for the IO operation generated in the storage medium supporting the synchronous type and the asynchronous type, the operation type can be marked artificially according to the business demand.

[0052] S102: judging whether the operation type of the IO operation is the synchronous type;

[0053] In the specific implementation, whether the operation type of the IO operation is the synchronous type is judged, if yes, S103 is entered, and if not, S104 is entered. As a feasible implementation manner, the present step can comprise: judging whether the operation type of the IO operation is the synchronous type based on the operation type marking of the IO operation.

[0054] S103: If the operation type of the IO operation is a synchronous type, switching the IO operation to execute in a coroutine;

[0055] In this step, for the IO operation of the synchronous type, directly switching to execute in the coroutine, without pushing to the coroutine queue to wait, reducing the number of coroutine switching and the number of enqueuing, shortening the path of the synchronous IO operation, reducing the complexity of the synchronous IO operation, and reducing the IO latency.

[0056] S104: If the operation type of the IO operation is an asynchronous type, pushing the IO operation to a first coroutine queue, the first coroutine queue being used to wait for scheduling to execute the IO operation.

[0057] In this step, for the IO operation of the asynchronous type, pushing to the first coroutine queue to wait for scheduling. As a feasible implementation manner, this step can include: pushing the IO operation and the corresponding coroutine context to the first coroutine queue; if the IO operation is scheduled, taking out the IO operation and the corresponding coroutine context from the first coroutine queue, and switching to execute in the coroutine. In a specific implementation, the IO operation of the asynchronous type and the corresponding coroutine context are pushed to the first coroutine queue, and when the IO operation reaches the scheduling time, the coroutine queue processing function takes out the IO operation and the corresponding coroutine context from the first coroutine queue, and switches to execute in the coroutine.

[0058] The data processing method provided by the embodiment of the application, when receiving the submission request of the IO operation, first judges whether the operation type is a synchronous type, if yes, directly switching to execute in the coroutine, without pushing to the coroutine queue to wait, reducing the number of coroutine switching and the number of enqueuing, shortening the path of the synchronous IO operation, reducing the complexity of the synchronous IO operation, and improving the processing efficiency of the IO operation.

[0059] The embodiment of the application discloses a data processing method, and relative to the previous embodiment, the technical scheme is further described and optimized. Specifically:

[0060] Referring to Figure 3 , a flowchart of another data processing method according to an example embodiment is shown, as Figure 3 shown, including:

[0061] S201: receiving a submission request of an IO operation;

[0062] S202: judging whether the operation type of the IO operation is a synchronous type;

[0063] S203: if the operation type of the IO operation is a synchronous type, switching the IO operation to execute in a coroutine;

[0064] S204: If the operation type of the IO operation is asynchronous, then the IO operation is pushed to the first coroutine queue, and the first coroutine queue is used to wait for the IO operation to be scheduled for execution;

[0065] S205: If a callback operation corresponding to the IO operation is received, determine whether the operation type of the IO operation is synchronous.

[0066] In this embodiment, after the IO operation is completed, if a callback operation corresponding to the IO operation is received, the operation type can be determined based on the operation type flag of the IO operation to determine whether it is a synchronous type. If yes, proceed to S206; otherwise, proceed to S207.

[0067] S206: If the operation type of the IO operation is synchronous, then the callback operation is executed using the target coroutine; wherein, the target coroutine is the coroutine that executes the IO operation;

[0068] In this step, the callback operations corresponding to synchronous IO operations do not need to be pushed to the coroutine queue to wait. Instead, they are directly switched to the current coroutine, i.e., the coroutine that performs the above IO operation, to further reduce the number of coroutine switches and enqueues, shorten the path of synchronous IO operations, reduce the complexity of synchronous IO operations, and reduce IO latency.

[0069] S207: If the operation type of the IO operation is asynchronous, the callback operation is pushed to the second coroutine queue, which is used to wait for the callback operation to be scheduled.

[0070] In this step, callback operations corresponding to asynchronous I / O operations are pushed to a second coroutine queue for scheduling. As a possible implementation, this step may include: pushing the callback operation and its corresponding coroutine context to the second coroutine queue; if the callback operation is scheduled, retrieving the callback operation and its corresponding coroutine context from the second coroutine queue and switching to the coroutine for execution. In a specific implementation, the callback operation corresponding to the asynchronous I / O operation and its corresponding coroutine context are pushed to the second coroutine queue. When the callback operation reaches its scheduling time, the coroutine queue processing function retrieves the callback operation and its corresponding coroutine context from the second coroutine queue and switches to the coroutine for execution. It is understood that the coroutines executing the asynchronous I / O operation and its corresponding callback operation can be the same coroutine or different coroutines.

[0071] The data processing method provided in the embodiments of the present application, when receiving a submission request of an IO operation, first judges whether the operation type of the IO operation is a synchronous type, if yes, directly switches to execution in a coroutine, without being pushed to a coroutine queue to wait, reduces the number of coroutine switching and the number of enqueuing, shortens the path of synchronous IO operation, reduces the complexity of synchronous IO operation, improves the processing efficiency of IO operation, and reduces IO latency. In addition, the data processing method provided in the embodiments of the present application, for the callback operation corresponding to the IO operation of the synchronous type, also does not need to be pushed to the coroutine queue to wait, but is directly switched to execution in the current coroutine, further reduces the number of coroutine switching and the number of enqueuing, shortens the path of synchronous IO operation, reduces the complexity of synchronous IO operation, and reduces IO latency.

[0072] A data processing apparatus provided in the embodiments of the present application is introduced below, and the data processing apparatus described below can be referred to with the data processing method described above.

[0073] Referring to Figure 4 , a structural diagram of a data processing apparatus according to an exemplary embodiment is shown, as Figure 4 shown, comprising:

[0074] The receiving module 401 is configured to receive a submission request of an IO operation.

[0075] The first judging module 402 is configured to judge whether the operation type of the IO operation is a synchronous type.

[0076] The first switching module 403 is configured to, when the operation type of the IO operation is a synchronous type, switch the IO operation to execution in a coroutine.

[0077] The data processing apparatus provided in the embodiments of the present application, when receiving a submission request of an IO operation, first judges whether the operation type of the IO operation is a synchronous type, if yes, directly switches to execution in a coroutine, without being pushed to a coroutine queue to wait, reduces the number of coroutine switching and the number of enqueuing, shortens the path of synchronous IO operation, reduces the complexity of synchronous IO operation, and improves the processing efficiency of IO operation.

[0078] On the basis of the above-mentioned embodiments, as a preferred implementation manner, further comprising:

[0079] The first pushing module is configured to, when the operation type of the IO operation is an asynchronous type, push the IO operation to a first coroutine queue, and the first coroutine queue is configured to wait for scheduling to execute the IO operation.

[0080] On the basis of the above-mentioned embodiments, as a preferred implementation, the first pushing module is specifically a module that, when the operation type of the IO operation is an asynchronous type, pushes the IO operation and the corresponding coroutine context into the first coroutine queue.

[0081] Correspondingly, the apparatus comprises:

[0082] The second switching module is configured to, if the IO operation is scheduled, take out the IO operation and the corresponding coroutine context from the first coroutine queue and switch to execution in a coroutine.

[0083] On the basis of the above-mentioned embodiments, as a preferred implementation, the apparatus further comprises:

[0084] The second judging module is configured to, after execution of the IO operation, if a callback operation corresponding to the IO operation is received, judge whether the operation type of the IO operation is a synchronous type.

[0085] The execution module is configured to, when the operation type of the IO operation is a synchronous type, execute the callback operation by using a target coroutine; wherein the target coroutine is a coroutine that executes the IO operation.

[0086] On the basis of the above-mentioned embodiments, as a preferred implementation, the apparatus further comprises:

[0087] The second pushing module is configured to, when the operation type of the IO operation is an asynchronous type, push the callback operation into a second coroutine queue, the second coroutine queue being configured to wait for scheduling to execute the callback operation.

[0088] On the basis of the above-mentioned embodiments, as a preferred implementation, the second pushing module is specifically a module that, when the operation type of the IO operation is an asynchronous type, pushes the callback operation and the corresponding coroutine context into the second coroutine queue.

[0089] Correspondingly, the apparatus comprises:

[0090] The third switching module is configured to, if the callback operation is scheduled, take out the callback operation and the corresponding coroutine context from the second coroutine queue and switch to execution in a coroutine.

[0091] On the basis of the above-mentioned embodiments, as a preferred implementation, the first judging module 402 is specifically a module that judges whether the operation type of the IO operation is a synchronous type based on an operation type marker of the IO operation; wherein the operation type marker is a parameter marked when the IO operation is created.

[0092] As to the apparatus in the above-mentioned embodiments, the specific manners in which the respective modules perform operations have been described in detail in the embodiments related to the method, and thus will not be described in detail here.

[0093] Based on the hardware implementation of the above-mentioned program modules, and in order to implement the method of the embodiments of the present application, the embodiments of the present application further provide an electronic device, Figure 5 For the structure diagram of an electronic device according to an exemplary embodiment, as shown in Figure 5 The electronic device includes:

[0094] The communication interface 1 is capable of information interaction with other devices such as network devices and the like;

[0095] The processor 2 is connected with the communication interface 1 to realize information interaction with other devices, and is used to execute the data processing method provided by one or more technical solutions described above when running the computer program. The computer program is stored on the memory 3.

[0096] Of course, in actual application, various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between the components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus and a status signal bus. However, in order to clearly illustrate, all kinds of buses are marked as the bus system 4 in Figure 5 .

[0097] The memory 3 in the embodiments of the present application is used to store various types of data to support the operation of the electronic device. Examples of these data include: any computer program used to operate on the electronic device.

[0098] It can be understood that the memory 3 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a ferromagnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM). The magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM) used as an external cache. By way of example but not limitation, many forms of RAM can be used, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), sync link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memory 2 described in the embodiments of the present application is intended to include, but not limited to, these and any other suitable types of memories.

[0099] The method disclosed in the embodiments of the present application can be applied to or implemented by the processor 2. The processor 2 can be an integrated circuit chip having a processing capability of signals. In the implementation, each step of the method can be completed by integrated logic circuits of hardware in the processor 2 or instructions in the form of software. The processor 2 described above can be a general processor, a DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiments of the present application, the execution can be directly completed by a hardware decoding processor or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 3. The processor 2 reads the program in the memory 3 and combines the hardware to complete the steps of the foregoing method.

[0100] The processor 2 implements the corresponding flow in each method of the embodiments of the present application when executing the program. For brevity, the foregoing will not be repeated here.

[0101] In the exemplary embodiments, the embodiments of the present application also provide a storage medium, i.e., a computer storage medium, specifically a computer readable storage medium, such as the memory 3 storing a computer program, which can be executed by the processor 2 to complete the steps of the foregoing method. The computer readable storage medium can be an FRAM, a ROM, a PROM, an EPROM, an EEPROM, a Flash Memory, a magnetic surface memory, an optical disc, or a CD-ROM, etc.

[0102] Those skilled in the art can understand that all or part of the steps of the foregoing method embodiments can be completed by program instruction related hardware, and the foregoing program can be stored in a computer readable storage medium. When the program is executed, the execution includes the steps of the foregoing method embodiments. The foregoing storage medium includes a mobile storage device, a ROM, a RAM, a magnetic disc or an optical disc, etc. various storage medium that can store program codes.

[0103] Alternatively, the above-mentioned integrated units of the present application, if realized in the form of software function modules and sold or used as independent products, can also be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions for causing an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the embodiments of the present application. The aforementioned storage medium includes: mobile storage devices, ROM, RAM, magnetic disks or optical disks, and various media that can store program codes.

[0104] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A data processing method, characterized by, The method comprises: receiving a submission request of an IO operation; judging whether the operation type of the IO operation is a synchronous type; if the operation type of the IO operation is the synchronous type, switching the IO operation to be executed in a coroutine.

2. The data processing method of claim 1, wherein, The method further comprises: if the operation type of the IO operation is an asynchronous type, pushing the IO operation to a first coroutine queue, the first coroutine queue being used for waiting for scheduling to execute the IO operation.

3. The data processing method of claim 2, wherein, The method of pushing the IO operation to the first coroutine queue comprises: pushing the IO operation and a corresponding coroutine context to the first coroutine queue. Correspondingly, the method further comprises: if the IO operation is scheduled, taking out the IO operation and the corresponding coroutine context from the first coroutine queue, and switching to be executed in a coroutine.

4. The data processing method of claim 1, wherein, After the IO operation is executed, the method further comprises: if a callback operation corresponding to the IO operation is received, judging whether the operation type of the IO operation is a synchronous type; if the operation type of the IO operation is the synchronous type, executing the callback operation by using a target coroutine; wherein the target coroutine is a coroutine for executing the IO operation.

5. The data processing method of claim 4, wherein, The method further comprises: if the operation type of the IO operation is the asynchronous type, pushing the callback operation to a second coroutine queue, the second coroutine queue being used for waiting for scheduling to execute the callback operation.

6. The data processing method of claim 5, wherein, The method of pushing the callback operation to the second coroutine queue comprises: pushing the callback operation and a corresponding coroutine context to the second coroutine queue. Correspondingly, the method further comprises: if the callback operation is scheduled, taking out the callback operation and the corresponding coroutine context from the second coroutine queue, and switching to be executed in a coroutine.

7. The data processing method according to any one of claims 1 to 6, characterized in that, The method of judging whether the operation type of the IO operation is a synchronous type comprises: judging whether the operation type of the IO operation is a synchronous type based on an operation type mark of the IO operation; wherein the operation type mark is a parameter marked when the IO operation is created.

8. A data processing apparatus, characterized by, The method comprises: a receiving module configured to receive a submission request of an IO operation; a first judging module configured to judge whether the operation type of the IO operation is a synchronous type; a switching module configured to switch the IO operation to be executed in a coroutine when the operation type of the IO operation is the synchronous type.

9. An electronic device, comprising: The method comprises: a memory configured to store a computer program; a processor configured to execute the computer program to implement the steps of the data processing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer program is stored on the computer readable storage medium, and the computer program is executed by the processor to implement the steps of the data processing method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Asynchronous task execution method, device and system

    CN106980546A

  • A task processing method and a task processing device

    CN109558255A