A method, apparatus, device, and computer-readable storage medium for task processing
By dividing the data space into multiple data blocks and using a polling algorithm to execute task queues, the problem of the storage system exhausted computing power in scenarios with frequent IO access is solved, and data processing performance is improved.
Patent Information
- Application Number
- CN202310231980.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-10
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2043-03-10
AI Technical Summary
In the scenario of frequent IO access, existing storage systems have excessive computing burdens on intelligent read-out algorithms, resulting in exhaustion of computing power and affecting data processing performance.
The data space is divided into multiple data blocks according to the access address and the set division granularity, and the system tasks are recorded in the thread pool queue. The task queue is executed in turn through the polling algorithm to avoid repeated writing of unexecuted system tasks and reduce the number of system tasks executed.
By reducing the number of executions of system tasks, the data processing performance of the storage system is improved and the utilization efficiency of computing resources is optimized.
Smart Images

Figure CN116243868B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data storage, and particularly to a method, apparatus, device, and computer-readable storage medium for processing tasks. Background Art
[0002] In a storage system, due to the performance difference between memory and disk, in order to improve the system access efficiency, copies of some data are cached in the memory. When accessing data, first try to access the cache. If the cache misses, then access the backend disk. Prefetching is to put the data that may be accessed subsequently in advance into the cache, so that subsequent data access can directly access the cache without accessing the backend disk, thereby improving the access efficiency.
[0003] However, which data will be accessed subsequently is unknown, so it is necessary to determine which data to put into the cache in advance through a prefetching algorithm. The quality of the prefetching algorithm determines the cache hit rate of subsequent data access. In order to improve the cache hit rate, a more intelligent prefetching algorithm has been proposed currently, but at the same time, this prefetching algorithm also introduces a huge computational burden. Especially in the scenario where IO access is frequent, in the current way of executing a prefetching algorithm every time an IO access is received, it is very easy to exhaust the computing power of the storage product.
[0004] It can be seen that how to improve the data processing performance of the storage system is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of the embodiments of this application is to provide a method, apparatus, device, and computer-readable storage medium for processing tasks, which can improve the data processing performance of the storage system.
[0006] To solve the above technical problems, an embodiment of this application provides a method for processing tasks, including:
[0007] Divide the data space into multiple data blocks according to the disk access address and the set division granularity;
[0008] When the IO access task for the target data block is completed, determine whether the system task corresponding to the target data block is recorded in the thread pool queue; where the target data block is any one of all the data blocks; and the thread pool queue contains multiple task queues;
[0009] When the system task corresponding to the target data block is recorded in the thread pool queue, keep the system task recorded in the thread pool queue unchanged;
[0010] When the system task corresponding to the target data block is not recorded in the thread pool queue, add the system task to the corresponding task queue;
[0011] Execute the tasks recorded in the thread pool queue in sequence according to the set polling algorithm.
[0012] Optionally, when the system task corresponding to the target data block is not recorded in the thread pool queue, adding the system task to the corresponding task queue includes:
[0013] When the system task corresponding to the target data block is not recorded in the thread pool queue, add the system task to the corresponding task queue according to the corresponding relationship between the data block and the task queue.
[0014] Optionally, when the system task corresponding to the target data block is not recorded in the thread pool queue, adding the system task to the corresponding task queue includes:
[0015] When the system task corresponding to the target data block is not recorded in the thread pool queue, add the system task to the currently polled task queue according to the task queue polling mechanism.
[0016] Optionally, the executing the tasks recorded in the thread pool queue in sequence according to the set polling algorithm includes:
[0017] Judge whether the number of tasks executed in the current task queue is greater than the preset threshold;
[0018] When the number of tasks executed in the current task queue is greater than or equal to the preset threshold, jump to the next task queue adjacent to the current task queue and execute the tasks recorded in the next task queue;
[0019] When the number of tasks executed in the current task queue is less than the preset threshold, increment the number of tasks executed by one each time a task recorded in the current task queue is executed.
[0020] Optionally, when the system task corresponding to the target data block is not recorded in the thread pool queue, adding the system task to the corresponding task queue includes:
[0021] When the system task corresponding to the target data block is not recorded in the thread pool queue, add the task pointer of the system task to the corresponding task queue.
[0022] Optionally, for the setting of the partitioning granularity, the method includes:
[0023] Determine the partitioning granularity based on the performance requirements of the current business scenario.
[0024] Optionally, after dividing the data space into multiple data blocks according to the disk access address and the set division granularity, the following steps are further included:
[0025] Set respective multi-thread protection locks for each of the data blocks.
[0026] An embodiment of the present application further provides a task processing device, including a division unit, a judgment unit, a holding unit, an adding unit, and a polling unit;
[0027] The division unit is configured to divide the data space into multiple data blocks according to the disk access address and the set division granularity;
[0028] The judgment unit is configured to, when the IO access task for the target data block is completed, judge whether the system task corresponding to the target data block is recorded in the thread pool queue; where the target data block is any one of all the data blocks; and the thread pool queue contains multiple task queues;
[0029] The holding unit is configured to, when the system task corresponding to the target data block is recorded in the thread pool queue, keep the system task recorded in the thread pool queue unchanged;
[0030] The adding unit is configured to, when the system task corresponding to the target data block is not recorded in the thread pool queue, add the system task to the corresponding task queue;
[0031] The polling unit is configured to sequentially execute the tasks recorded in the thread pool queue according to the set polling algorithm.
[0032] Optionally, the adding unit is configured to, when the system task corresponding to the target data block is not recorded in the thread pool queue, add the system task to the corresponding task queue according to the correspondence between the data block and the task queue.
[0033] Optionally, the adding unit is configured to, when the system task corresponding to the target data block is not recorded in the thread pool queue, add the system task to the currently polled task queue according to the task queue polling mechanism.
[0034] Optionally, the polling unit includes a judgment subunit, a jump sub-unit, and a recording subunit;
[0035] The judgment subunit is configured to judge whether the number of tasks executed in the current task queue is greater than a preset threshold;
[0036] The jump rotor unit is used to jump to the next task queue adjacent to the current task queue and execute the tasks recorded in the next task queue when the number of tasks executed in the current task queue is greater than or equal to a preset threshold;
[0037] The recording subunit is used to increment the number of tasks executed by one each time a task recorded in the current task queue is executed when the number of tasks executed in the current task queue is less than the preset threshold.
[0038] Optionally, the adding unit is used to add the task pointer of the system task to the corresponding task queue when the system task corresponding to the target data block is not recorded in the thread pool queue.
[0039] Optionally, for the setting of the division granularity, the device includes a determining unit;
[0040] The determining unit is used to determine the division granularity based on the performance requirements of the current service scenario.
[0041] Optionally, it further includes a setting unit;
[0042] The setting unit is used to set respective multi-thread protection locks for each of the data blocks.
[0043] An embodiment of the present application further provides an electronic device, including:
[0044] A memory for storing a computer program;
[0045] A processor for executing the computer program to implement the steps of the task processing method as described above.
[0046] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the task processing method as described above are implemented.
[0047] As can be seen from the above technical solution, the data space is divided into multiple data blocks according to the disk access address and the set division granularity; when the IO access task for the target data block is completed, it is judged whether the system task corresponding to the target data block is recorded in the thread pool queue; where the target data block is any one of all data blocks; the thread pool queue contains multiple task queues. The multiple task queues can be executed in a round-robin manner. When the system task corresponding to the target data block is recorded in the thread pool queue, it means that the system task corresponding to the target data block has not been executed yet. In order to avoid high resource consumption caused by multiple executions of the system task for the same target data block, it is not necessary to write the system task corresponding to the target data block into the thread pool queue again, and the system task recorded in the thread pool queue can remain unchanged. When the system task corresponding to the target data block is not recorded in the thread pool queue, it means that there is no system task corresponding to the target data block in the thread pool. At this time, the system task can be added to the corresponding task queue. The tasks recorded in the thread pool queue are executed in sequence according to the set round-robin algorithm. In this technical solution, by dividing the data blocks and setting different task queues, the round-robin execution of the system tasks corresponding to different data blocks can be realized. During the round-robin, if the system task corresponding to the target data block has not been executed yet, when an IO access task for the target data block is received during this period, it is not necessary to write the system task into the thread pool queue again. Compared with the traditional method of executing a system task every time an IO access task is received, the present application greatly reduces the number of times the system task needs to be executed and improves the data processing performance of the storage system. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] To more clearly illustrate the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0049] Figure 1 It is a flowchart of a method for processing tasks provided by an embodiment of the present application;
[0050] Figure 2 It is a schematic diagram of the processing flow of a data block system task provided by an embodiment of the present application;
[0051] Figure 3 It is a schematic diagram of the structure of a task processing device provided by an embodiment of the present application;
[0052] Figure 4 It is a structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0053] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0054] The terms "including" and "having" in the specification and claims of the present application, and any variations related to "including" and "having", are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may include steps or units not listed.
[0055] In order to enable those skilled in the art of the present technology to better understand the solutions of the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0056] In the traditional method, a system task is executed every time an IO access task is received. This processing method will greatly consume the computing power of the storage product. Taking the system task as a prefetch task as an example, assuming that the IO access task is a read task, the prefetch operation will read more data than the data required by the IO access task. If there are a large number of IO access tasks for the data on the same disk within a short period of time, according to the traditional method, a large amount of data needs to be prefetched, and such an operation is likely to exhaust the computing power of the storage product.
[0057] Currently, the industry uses a timer solution to sample the system tasks that need to be executed. However, a millisecond-level timer cannot meet the microsecond-level requirements of the storage product. And a microsecond-level timer belongs to a high-precision timer, with excessive performance loss and extremely easy to cause abnormalities in other mechanisms. Moreover, the microsecond-level timer itself is disabled by operating systems such as WIN10 and cannot be applied to storage products with strict requirements for performance and security.
[0058] Therefore, the embodiments of the present application provide a method, apparatus, device, and computer-readable storage medium for task processing. According to the disk access address and the set partitioning granularity, the data space is divided into multiple data blocks, ensuring the independent storage of different types of data on the same disk. Each data block has its corresponding system task. In the embodiments of the present application, the thread pool is divided into different task queues, and the tasks recorded in the thread pool queue are sequentially executed according to the set polling algorithm. The processing methods of the tasks corresponding to each data block are similar. Taking any one of all data blocks, i.e., the target data block, as an example, after completing the IO access task for the target data block, if the system task corresponding to the target data block is recorded in the thread pool queue, there is no need to write the system task corresponding to the target data block into the thread pool queue again, and the system tasks recorded in the thread pool queue can remain unchanged. If the system task corresponding to the target data block is not recorded in the thread pool queue, the system task can be added to the corresponding task queue at this time.
[0059] By partitioning the data blocks and setting different task queues, it is possible to achieve the polling execution of the system tasks corresponding to different data blocks. During the polling, if the system task corresponding to the target data block has not been executed yet, when an IO access task for the target data block is received during this period, there is no need to write the system task into the thread pool queue again, greatly reducing the number of times the system tasks need to be executed and improving the data processing performance of the storage system.
[0060] Next, a method for task processing provided by the embodiments of the present application will be introduced in detail. Figure 1 FIG. is a flowchart of a method for task processing provided by the embodiments of the present application. The method includes:
[0061] S101: Divide the data space into multiple data blocks according to the disk access address and the set partitioning granularity.
[0062] The amount of data involved in a single IO access task in different business scenarios often varies. To better meet the requirements of the current business scenario, in specific implementations, the partitioning granularity can be determined based on the performance requirements of the current business scenario.
[0063] A storage system often contains multiple disks, and each disk has its corresponding disk access address. For different disks, the corresponding partitioning granularities can be the same or different, and can be flexibly set according to actual needs.
[0064] The disk access address is used to indicate the location of the disk. Based on the access address, the corresponding disk can be accessed. Combining the set partitioning granularity, the data space corresponding to the disk can be divided into multiple data blocks.
[0065] For example, the partitioning granularity can be set to 32 KB. Assuming that the storage space of a disk is 500 G, 500 G can be divided based on 32 KB as the basic unit.
[0066] S102: When the IO access task for the target data block is completed, determine whether the system task corresponding to the target data block is recorded in the thread pool queue.
[0067] The system task can be a task set according to the current business scenario. The system task can include a prefetch task, an authorization task, a power-on / off task, etc. For the convenience of introduction, the system task is taken as an example of a prefetch task to expand the description.
[0068] Each data block has its corresponding system task, and the system task can be recorded in the thread pool. In the embodiment of the present application, the thread pool queue contains multiple task queues. The tasks recorded in the multiple task queues can be executed in a polling manner.
[0069] The processing methods of the system tasks corresponding to each data block are similar. Taking any one of all data blocks, that is, the target data block, as an example, when the IO access task for the target data block is completed, it can be determined whether the system task corresponding to the target data block is recorded in the thread pool queue.
[0070] If the system task corresponding to the target data block is recorded in the thread pool queue, it means that the system task corresponding to the target data block has not been executed yet. At this time, there is no need to repeatedly write the system task into the thread pool, that is, execute S103.
[0071] If the system task corresponding to the target data block is not recorded in the thread pool queue, it means that the system task corresponding to the target data block has been executed. At this time, when the IO access task for the target data block is completed, it is necessary to write the system task into the thread pool again, that is, execute S104.
[0072] S103: Keep the system tasks recorded in the thread pool queue unchanged.
[0073] S104: Add the system task to the corresponding task queue.
[0074] In the embodiment of the present application, the system tasks corresponding to each data block can be written into the current task queue in a polling manner. That is, if the system task corresponding to the target data block is not recorded in the thread pool queue, the system task can be added to the currently polled task queue according to the task queue polling mechanism.
[0075] In addition to the polling method, a correspondence between data blocks and task queues can also be established. When the system task corresponding to the target data block is not recorded in the thread pool queue, the system task is added to the corresponding task queue based on the correspondence between the data block and the task queue.
[0076] S105: Execute the tasks recorded in the thread pool queue in sequence according to the set polling algorithm.
[0077] The thread pool queue contains multiple task queues. In actual applications, the tasks recorded in each task queue can be executed in sequence according to the polling algorithm.
[0078] There may be multiple tasks recorded in a task queue. In order to prevent a single task queue from taking up too long during polling, the number of tasks executed by a single task queue can be limited.
[0079] When the tasks recorded in the thread pool queue are executed in sequence according to the set polling algorithm, it can be determined whether the number of tasks executed in the current task queue is greater than a preset threshold.
[0080] When the number of tasks executed in the current task queue is greater than or equal to the preset threshold, it means that it has taken a long time to execute the tasks recorded in the task queue. In order to balance the processing of all task queues, you can jump to the next task queue adjacent to the current task queue and execute the tasks recorded in the next task queue.
[0081] When the number of tasks executed in the current task queue is less than the preset threshold, the number of tasks executed can be increased by one each time a task recorded in the current task queue is executed until the task recorded in the current task queue is completed or the number of tasks executed in the current task queue is greater than or equal to the preset threshold, then you can jump to the next task queue.
[0082] In an embodiment of the present application, when adding a system task to a task queue, only the task pointer corresponding to the system task may be written, and the corresponding processing function may be accessed based on the task pointer, thereby completing the system task.
[0083] Figure 2 A schematic diagram of a processing flow of a data block system task provided in an embodiment of the present application, Figure 2Taking data block 1 as an example, assume that there are three IO access tasks corresponding to data block 1, namely data block 1 - IO1, data block 1 - IO2, and data block 1 - IO3. The task processing flow corresponding to data block 1 can be divided into the following 5 timing steps. Timing 1: Process the first IO access task corresponding to data block 1. Timing 2: Assume that the system task of data block 1 is not in the thread pool queue, and data block 1 has a corresponding relationship with task queue 3, then the system task of data block 1 can be added to task queue 3 belonging to cpu1. Timing 3: After processing the second and third IO access tasks corresponding to data block 1, check in sequence whether the system task corresponding to data block 1 is already in the thread pool task queue. If the system task corresponding to data block 1 is already in the thread pool task queue, then its system task will not be added to the thread pool again. Timing 4: The cpu executes the tasks recorded in each task queue according to its own polling algorithm. Timing 5: When accessing the system task of data block 1 in task queue 3, according to the task pointer recorded in task queue 3, the corresponding processing function can be called, so as to execute the system task of data block 1. From Figure 2 the process, it can be seen that data block 1 is accessed by IO 3 times successively, and only one system task is recorded in the thread pool queue. Compared with the traditional method, in which a system task is executed every time an IO access is received, according to the implementation process of this application, only one system task corresponding to data block 1 needs to be executed.
[0084] Considering that in practical applications, the same data block may be accessed by multiple threads simultaneously. To avoid interference caused by operations between different threads, multi - thread protection locks corresponding to each data block can be set.
[0085] By setting multi - thread protection locks, the orderly execution of multiple thread tasks can be guaranteed. For example, for multiple read tasks, there is no interference between multiple read tasks, so the multi - thread protection lock can be for parallel processing of read tasks. For multiple write tasks, since there is interference between different write tasks, the multi - thread protection lock can be for serial processing of write tasks.
[0086] As can be seen from the above technical solution, the data space is divided into multiple data blocks according to the disk access address and the set division granularity; when the IO access task for the target data block is completed, it is judged whether the system task corresponding to the target data block is recorded in the thread pool queue; wherein, the target data block is any one of all data blocks; the thread pool queue contains multiple task queues. The multiple task queues can be executed in a polling manner. When the system task corresponding to the target data block is recorded in the thread pool queue, it indicates that the system task corresponding to the target data block has not been executed yet. In order to avoid high resource consumption caused by multiple executions of the system task for the same target data block, it is not necessary to write the system task corresponding to the target data block into the thread pool queue again, and the system task recorded in the thread pool queue can remain unchanged. When the system task corresponding to the target data block is not recorded in the thread pool queue, it indicates that there is no system task corresponding to the target data block in the thread pool. At this time, the system task can be added to the corresponding task queue. The tasks recorded in the thread pool queue are sequentially executed according to the set polling algorithm. In this technical solution, by dividing the data blocks and setting different task queues, the polling execution of the system tasks corresponding to different data blocks can be realized. During the polling, if the system task corresponding to the target data block has not been executed yet, when an IO access task for the target data block is received during this period, there is no need to write the system task into the thread pool queue again. Compared with the traditional method of executing a system task every time an IO access task is received, the present application greatly reduces the number of times the system task needs to be executed and improves the data processing performance of the storage system.
[0087] Figure 3 FIG. 4 is a schematic structural diagram of a task processing device provided by an embodiment of the present application, including a division unit 31, a judgment unit 32, a retention unit 33, an addition unit 34, and a polling unit 35;
[0088] The division unit 31 is configured to divide the data space into multiple data blocks according to the disk access address and the set division granularity;
[0089] The disk access address is used to indicate the position of the disk. According to the access address, the corresponding disk can be accessed. Combining the set division granularity, the data space corresponding to the disk can be divided into multiple data blocks.
[0090] The judgment unit 32 is configured to judge whether the system task corresponding to the target data block is recorded in the thread pool queue when the IO access task for the target data block is completed; wherein, the target data block is any one of all data blocks; the thread pool queue contains multiple task queues;
[0091] Each data block has its corresponding system task, and the system task can be recorded in the thread pool. In the embodiments of the present application, the thread pool queue contains multiple task queues. The multiple task queues can be executed in a polling manner.
[0092] The holding unit 33 is configured to keep the system task recorded in the thread pool queue unchanged when the system task corresponding to the target data block is recorded in the thread pool queue;
[0093] When the system task corresponding to the target data block is recorded in the thread pool queue, it indicates that the system task corresponding to the target data block has not been executed yet. At this time, there is no need to repeatedly write the system task into the thread pool, that is, keep the system task recorded in the thread pool queue unchanged.
[0094] The adding unit 34 is configured to add the system task to the corresponding task queue when the system task corresponding to the target data block is not recorded in the thread pool queue;
[0095] When the system task corresponding to the target data block is not recorded in the thread pool queue, it indicates that the system task corresponding to the target data block has been executed. At this time, after completing the IO access task for the target data block, it is necessary to rewrite the system task into the thread pool, that is, add the system task to the corresponding task queue.
[0096] The polling unit 35 is configured to sequentially execute the tasks recorded in the thread pool queue according to the set polling algorithm.
[0097] Optionally, the adding unit is configured to add the system task to the corresponding task queue according to the correspondence between the data block and the task queue when the system task corresponding to the target data block is not recorded in the thread pool queue.
[0098] Optionally, the adding unit is configured to add the system task to the currently polled task queue according to the task queue polling mechanism when the system task corresponding to the target data block is not recorded in the thread pool queue.
[0099] Optionally, the polling unit includes a judgment subunit, a jump subunit, and a recording subunit;
[0100] The judgment subunit is configured to judge whether the number of tasks executed in the current task queue is greater than a preset threshold;
[0101] The jump subunit is configured to jump to the next task queue adjacent to the current task queue and execute the task recorded in the next task queue when the number of tasks executed in the current task queue is greater than or equal to the preset threshold;
[0102] A recording subunit, configured to increment the task execution count by one each time a task recorded in the current task queue is executed when the number of tasks executed in the current task queue is less than a preset threshold.
[0103] Optionally, an adding unit is configured to add the task pointer of the system task to the corresponding task queue when the system task corresponding to the target data block is not recorded in the thread pool queue.
[0104] Optionally, for setting the partitioning granularity, the apparatus includes a determining unit;
[0105] The determining unit is configured to determine the partitioning granularity based on the performance requirements of the current service scenario.
[0106] Optionally, it further includes a setting unit;
[0107] The setting unit is configured to set a respective multi-thread protection lock for each data block.
[0108] Figure 3 For the description of the features in the corresponding embodiments, reference may be made to Figure 1 the relevant descriptions of the corresponding embodiments, which will not be elaborated herein one by one.
[0109] As can be seen from the above technical solution, the data space is divided into multiple data blocks according to the disk access address and the set division granularity; when the IO access task for the target data block is completed, it is judged whether the system task corresponding to the target data block is recorded in the thread pool queue; wherein, the target data block is any one of all data blocks; the thread pool queue contains multiple task queues. The multiple task queues can be executed in a polling manner. When the system task corresponding to the target data block is recorded in the thread pool queue, it means that the system task corresponding to the target data block has not been executed yet. In order to avoid high resource consumption caused by multiple executions of the system task for the same target data block, it is not necessary to write the system task corresponding to the target data block into the thread pool queue again, and the system task recorded in the thread pool queue can remain unchanged. When the system task corresponding to the target data block is not recorded in the thread pool queue, it means that there is no system task corresponding to the target data block in the thread pool. At this time, the system task can be added to the corresponding task queue. The tasks recorded in the thread pool queue are executed in sequence according to the set polling algorithm. In this technical solution, by dividing the data blocks and setting different task queues, the polling execution of the system tasks corresponding to different data blocks can be realized. During the polling, if the system task corresponding to the target data block has not been executed yet, when an IO access task for the target data block is received during this period, there is no need to write the system task into the thread pool queue again. Compared with the traditional method of executing a system task every time an IO access task is received, the present application greatly reduces the number of times the system task needs to be executed and improves the data processing performance of the storage system.
[0110] Figure 4 The structural diagram of an electronic device provided by an embodiment of the present application is as Figure 4 shown. The electronic device includes: a memory 20 for storing a computer program;
[0111] a processor 21 for implementing the steps of the processing method of the tasks in the above embodiment when executing the computer program.
[0112] The electronic device provided in this embodiment may include, but is not limited to, a smart phone, a tablet computer, a notebook computer, or a desktop computer, etc.
[0113] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor used to process data in the wake state, also known as the CPU (Central Processing Unit); the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may further include an AI (Artificial Intelligence) processor, and the AI processor is used to process computational operations related to machine learning.
[0114] The memory 20 may include one or more computer-readable storage media, and the computer-readable storage media may be non-transitory. The memory 20 may further include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201. After the computer program is loaded and executed by the processor 21, it can implement the relevant steps of the processing method of the tasks disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 20 may further include an operating system 202 and data 203, etc., and the storage method may be transient storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include, but is not limited to, partitioning granularity, system tasks, etc.
[0115] In some embodiments, the electronic device may further include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.
[0116] Those skilled in the art can understand that Figure 4 the structure shown in
[0117] It can be understood that if the task processing method in the above embodiments is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods in the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), electrically erasable programmable ROMs, registers, hard disks, removable disks, CD-ROMs, magnetic disks, or optical discs.
[0118] Based on this, the embodiments of the present invention further provide a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the steps of the task processing method as described above are implemented.
[0119] The above has introduced in detail a task processing method, device, equipment, and computer-readable storage medium provided by the embodiments of the present application. The various embodiments in the specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method part.
[0120] Those skilled in the art can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of the examples have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0121] The above has introduced in detail a method, apparatus, device, and computer-readable storage medium for processing a task provided in this application. Specific examples are used in this article to elaborate on the principles and implementation manners of the present invention. The descriptions of the above embodiments are only used to help understand the method and its core idea of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and modifications can still be made to this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A method for processing a task, characterized in that, including: dividing a data space into a plurality of data blocks according to an access disk address and a set division granularity; when an IO access task for a target data block is completed, determining whether a system task corresponding to the target data block is recorded in a thread pool queue; wherein, the target data block is any one of all the data blocks; the thread pool queue includes a plurality of task queues; when the system task corresponding to the target data block is recorded in the thread pool queue, keeping the system task recorded in the thread pool queue unchanged; when the system task corresponding to the target data block is not recorded in the thread pool queue, adding the system task to a corresponding task queue; sequentially executing the tasks recorded in the thread pool queue according to a set polling algorithm.
2. The method for processing the task according to claim 1, wherein The adding the system task to a corresponding task queue when the system task corresponding to the target data block is not recorded in the thread pool queue includes: when the system task corresponding to the target data block is not recorded in the thread pool queue, adding the system task to a corresponding task queue according to the correspondence between the data block and the task queue.
3. The method for processing a task according to claim 1, wherein The adding the system task to a corresponding task queue when the system task corresponding to the target data block is not recorded in the thread pool queue includes: when the system task corresponding to the target data block is not recorded in the thread pool queue, adding the system task to the currently polled task queue according to a task queue polling mechanism.
4. The method for processing a task according to claim 1, wherein The sequentially executing the tasks recorded in the thread pool queue according to a set polling algorithm includes: judging whether the number of tasks executed in the current task queue is greater than a preset threshold; when the number of tasks executed in the current task queue is greater than or equal to the preset threshold, jumping to the next task queue adjacent to the current task queue and executing the tasks recorded in the next task queue; when the number of tasks executed in the current task queue is less than the preset threshold, incrementing the number of tasks executed by one each time a task recorded in the current task queue is executed.
5. The method for processing a task according to claim 1, characterized in that, The adding the system task to a corresponding task queue when the system task corresponding to the target data block is not recorded in the thread pool queue includes: when the system task corresponding to the target data block is not recorded in the thread pool queue, adding a task pointer of the system task to a corresponding task queue.
6. The method for processing a task according to claim 1, characterized in that, Regarding the setting of the division granularity, the method includes: determining a division granularity based on the performance requirements of the current service scenario.
7. The method for processing a task according to any one of claims 1 to 6, characterized in that After dividing the data space into a plurality of data blocks according to the access disk address and the set division granularity, further including: setting respective multi-thread protection locks for each of the data blocks.
8. A processing device for a task, characterized in that, including a division unit, a judgment unit, a keeping unit, an adding unit, and a polling unit; the division unit is configured to divide a data space into a plurality of data blocks according to an access disk address and a set division granularity; The determination unit is configured to determine whether a system task corresponding to the target data block is recorded in the thread pool queue when the IO access task for the target data block is completed; wherein, the target data block is any one of all the data blocks; and the thread pool queue includes a plurality of task queues. The retention unit is configured to keep the system tasks recorded in the thread pool queue unchanged when the system tasks corresponding to the target data block are recorded in the thread pool queue. The addition unit is configured to add the system task to the corresponding task queue when the system task corresponding to the target data block is not recorded in the thread pool queue. The polling unit is configured to sequentially execute the tasks recorded in the thread pool queue according to a set polling algorithm.
9. An electronic device, characterized in that, Comprising: A memory for storing a computer program. A processor for executing the computer program to implement the steps of the processing method of the task according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by the processor, the steps of the processing method of the task according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
High-throughput risk control data processing method, device and equipment and storage medium
CN110852603A
Thread pool unified scheduling monitoring method and system
CN111984402A