Task distribution method and device, electronic equipment and storage medium

By determining the target tasks in the server and distributing them in batches to the target queue, the lock competition problem is solved, the task distribution efficiency and processing effect are improved, resource consumption is reduced, and priority processing of high-priority tasks is ensured.

CN120508375AActive Publication Date: 2025-08-19INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510998358.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-18
Publication Date
2025-08-19
Estimated Expiration
2045-07-18

AI Technical Summary

Technical Problem

In the prior art, the server has lock competition problems when distributing I/O request tasks to the task queue, resulting in inefficient distribution and increased resource consumption and processing delay.

Method used

By obtaining the task set, the target task is determined based on the number of tasks allowed to be received by the target queue and the priority of the task, and batch distribute it to the target queue. The atomic weak comparison and exchange method are used to reduce the risk of lock competition, and batch task distribution is achieved in combination with the Intel TSX hardware memory characteristics.

Benefits of technology

It improves task distribution efficiency, reduces resource consumption, and ensures priority processing of high-priority tasks, improving the processing effect of servers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120508375A_ABST
    Figure CN120508375A_ABST
Patent Text Reader

Abstract

The invention discloses a task distribution method and device, electronic equipment and a storage medium, and relates to the technical field of data processing, and the method comprises the steps that a server determines at least one target task in at least one to-be-processed task according to the number of to-be-processed tasks allowed to be received by a target queue and the respective priority of the at least one to-be-processed task, and then distributing the at least one target task to a target queue in batches. In the task distribution method, the at least one to-be-distributed target task is determined in the at least one to-be-processed task, and then the at least one target task is distributed to the target queue in batches, so that the lock competition risk when the to-be-processed task is distributed to the target queue is reduced, and the distribution efficiency of the at least one to-be-processed task is improved; and the resource consumption of the server in the task distribution process is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a task distribution method, device, electronic device and storage medium. Background Art

[0002] Input / Output (I / O) requests are the core mechanism used to coordinate data transfer between software and hardware in computer systems. In some scenarios, servers can handle I / O request tasks to process data on the server.

[0003] In the related art, after receiving an I / O request, the server can process the I / O request task based on the Storage Performance Development Kit (SPDK) technology. Specifically, the server divides and processes the I / O request task according to the preset shard size to obtain multiple tasks to be processed. Then, for each task to be processed, the task to be processed is distributed to a task queue, where each task queue corresponds to a central processing unit (CPU) core. For each CPU core, the CPU core executes the task to be processed in the task queue corresponding to the CPU core, thereby processing the data corresponding to the task to be processed in the server. However, the above-mentioned method of distributing the task to be processed to the task queue has the problem of lock contention, resulting in low efficiency in distributing the task to be processed to the task queue. Summary of the Invention

[0004] The present application provides a task distribution method, device, electronic device and storage medium to improve the efficiency of distributing pending tasks to a task queue.

[0005] This application provides a task distribution method, including:

[0006] Obtain a task set, where the task set includes at least one pending task, where the pending task is used to perform a read operation or a write operation on data;

[0007] Determining a target queue in at least one task queue that is allowed to receive the pending task;

[0008] Determining at least one target task from the at least one pending task based on the number of pending tasks allowed to be received by the target queue and the priority of each of the at least one pending task; wherein the number of the at least one target task is less than or equal to the number of pending tasks allowed to be received by the target queue;

[0009] Dispatches at least one target task to the target queue.

[0010] This application also provides a task distribution device, including:

[0011] An acquisition module is used to acquire a task set, wherein the task set includes at least one task to be processed, and the task to be processed is used to perform a read operation or a write operation on data;

[0012] A first determining module is used to determine a target queue that is allowed to receive tasks to be processed in at least one task queue;

[0013] a second determining module, configured to determine at least one target task from the at least one pending task based on the number of pending tasks allowed to be received by the target queue and the priority of the at least one pending task; wherein the number of the at least one target task is less than or equal to the number of pending tasks allowed to be received by the target queue;

[0014] The distribution module is used to distribute at least one target task to a target queue.

[0015] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned task distribution methods when executing the computer program.

[0016] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned task distribution methods are implemented.

[0017] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned task distribution methods when executed by a processor.

[0018] The task distribution method, device, electronic device and storage medium provided by the embodiment of the present application, the server determines at least one target task in at least one to-be-processed task according to the number of to-be-processed tasks allowed to be received by the target queue and the priority of at least one to-be-processed task, and then distributes the at least one target task in batches to the target queue. In the above-mentioned task distribution method, at least one target task to be distributed is determined in at least one to-be-processed task, and then the at least one target task is distributed in batches to the target queue, which reduces the risk of lock competition when distributing at least one to-be-processed task to the target queue, improves the distribution efficiency of at least one to-be-processed task, and saves resource consumption of the server in the task distribution process. In addition, the server determines at least one target task in at least one to-be-processed task according to the number of to-be-processed tasks allowed to be received by the target queue and the priority of at least one to-be-processed task, combines the task capacity of the target queue and the priority of the to-be-processed task, and ensures that the high-priority to-be-processed task is processed first within the carrying capacity of the to-be-processed task in the target queue, thereby improving the processing effect of the server on at least one to-be-processed task. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0020] Figure 1 Schematic diagram of application scenarios provided by embodiments of the present application;

[0021] Figure 2 A flowchart of a task distribution method provided in an embodiment of the present application;

[0022] Figure 3 A schematic diagram of a process for obtaining a task set provided in an embodiment of the present application;

[0023] Figure 4 A schematic diagram of a task distribution system provided in an embodiment of the present application;

[0024] Figure 5 A schematic diagram of calling a task to be processed provided in an embodiment of the present application;

[0025] Figure 6 A signaling diagram of a task distribution method provided in an embodiment of the present application;

[0026] Figure 7 A schematic diagram of the structure of a task distribution device provided in an embodiment of the present application;

[0027] Figure 8 This is a schematic diagram of the structure of the electronic device provided in this application. DETAILED DESCRIPTION

[0028] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0029] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.

[0030] First, the professional terms involved in this application are explained.

[0031] Kernel state: Kernel state is a privileged mode provided by the operating system. In a computer system, kernel state has the highest permissions and is responsible for implementing the operating system's core functions, such as process management, file system management, and device drivers. Kernel state also stores the computer system's key resources and protocols. When user state needs to access kernel state resources or protocols, it must apply to kernel state. Only after kernel state verification is the application program in user state allowed to access kernel state resources and protocols, thus ensuring the security and stability of the computer system.

[0032] User state: User state is an operating environment for applications provided by the operating system. In some embodiments, for data migration in user state, the source storage device runs in user state when executing the data migration task. To ensure the independence and security of each task, resource access in user state is restricted, that is, some key resources or protocols cannot be directly accessed in the user state of the data migration task. When the user state needs to access these key resources or protocols, it needs to send a request to the kernel state. After verifying the legitimacy of the request, the kernel state allows the user state of the data migration to access these key resources or protocols.

[0033] In traditional storage architectures, after receiving an I / O request, the server relies on kernel mode to process it. Specifically, the server switches the I / O request from user mode to kernel mode by calling protocols such as read() and write(). After receiving the I / O request, kernel mode stores it in a kernel-shared data structure. The server kernel then retrieves the I / O request from this structure and processes it.

[0034] However, a server includes multiple server cores. To ensure that only one server core accesses the kernel shared data structure at a time, a concurrency control mechanism can be implemented within the kernel shared data structure. For example, a mutex lock can be used as the concurrency control mechanism. For example, if the mutex lock is used as the concurrency control mechanism, multiple server cores will need to compete for access to the kernel shared data structure, resulting in lock contention. Since only one server core can access the kernel shared data structure at a time, this limits the server's linear scalability.

[0035] Furthermore, the switch between user mode and kernel mode increases the server's context switching overhead. Furthermore, during the switch between user mode and kernel mode, the server needs to copy the I / O request to the user mode buffer and then copy the I / O request from the user mode buffer to kernel mode, resulting in reduced server bandwidth utilization. Because kernel mode schedules I / O requests based on their priority, hardware interrupts can occur during data processing. Specifically, if the I / O request has a lower priority, the kernel mode will process other higher-priority tasks first, resulting in significant processing delays for the I / O request.

[0036] To address these issues, we propose SPDK technology, which improves server I / O request processing efficiency through user-mode drivers, kernel bypass, and hardware acceleration. Specifically, SPDK completely moves the I / O stack to user mode. This allows the server to process I / O requests in user mode, eliminating reliance on kernel mode for processing, and thus eliminating the overhead incurred by user-to-kernel context switches. SPDK also employs an active polling mechanism to avoid hardware interrupts, improving I / O request processing efficiency.

[0037] Furthermore, after receiving an I / O request, the server divides and processes it into multiple pending tasks, which are then distributed to task queues. Each task queue corresponds to a processor core. Each processor core executes the pending tasks in its corresponding task queue. This avoids the lock contention issues that exist in traditional storage architectures. Furthermore, SPDK integrates hardware offload capabilities such as Remote Direct Memory Access (RDMA) and the Data Plane Development Kit (DPDK). By replacing the processor's protocol processing and data transmission with hardware offloads such as RDMA and DPDK, SPDK avoids inefficient kernel bypasses and reduces processor overhead on non-core tasks, thereby improving the efficiency of I / O request processing.

[0038] However, since the task queue manages the queue's head pointer and tail pointer using atomic pointers, where the head pointer indicates the queue exit position of the pending task in the task queue, and the tail pointer indicates the queue entry position of the pending task in the task queue, in high-concurrency scenarios, when the server distributes pending tasks to the task queue, there may be multiple pending tasks competing to modify the same atomic pointer at the same time. Taking the comparison and swap (CAS) method to modify the atomic pointer as an example, when multiple pending tasks compete to modify the same atomic pointer at the same time, the pending task that fails in the competition needs to reread the pointer and try again, resulting in poor processing of I / O requests.

[0039] The present application provides a task distribution method in which a server determines at least one target task from at least one pending task based on the number of pending tasks allowed to be received by the target queue and the priority of the at least one pending task. In this way, the task distribution method first determines at least one target task to be distributed from the at least one pending task and then distributes the at least one target task in batches to the target queue, thereby reducing the risk of lock contention when distributing the at least one pending task to the target queue.

[0040] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0041] In conjunction with the specific application environment architecture or specific hardware architecture on which the execution of the task distribution method depends, the specific application environment architecture or specific hardware architecture is described here. Figure 1 , Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of the present application. Figure 1As shown, it includes a first device 11 and a server 12, wherein the first device 11 can be, for example, a client or other device; and the server 12 stores at least one data.

[0042] In actual application, the first device 11 and the server 12 can communicate with each other. For example, the first device 11 can send an initial task to the server 12. The initial task includes a data processing type and a data storage location, and the initial task is used to instruct the server 12 to process the pending data at the data storage location based on the data processing type. The data processing type includes a read type and a write type. The server 12 can send a data processing response to the first device 11. For example, if the data processing type is a read type, the data processing response may include the data read by the server 12 at the data storage location.

[0043] It should be noted that Figure 1 This is just an example to illustrate an application scenario, and is not intended to limit the application scenario.

[0044] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0045] Figure 2 A flowchart of a task distribution method provided in an embodiment of the present application is shown as follows: Figure 2 As shown, the embodiment of the present application provides a task distribution method, which is described in detail as follows:

[0046] S201: Acquire a task set, where the task set includes at least one task to be processed, and the task to be processed is used to perform a read operation or a write operation on data.

[0047] The execution subject of the present application may be a server, or a task distribution device provided in the server. The task distribution device may be implemented through software, or through a combination of software and hardware.

[0048] In some embodiments, for each pending task, the pending task may include a data processing type and a data storage address, wherein the data processing type may be a read operation or a write operation; the data storage address is used to indicate the storage address of the data corresponding to the pending task in the server. The pending task is used to instruct the server to process the data located at the data storage address in the server according to the data processing type. It should be noted that at least one pending task is independent, that is, for each pending task in the at least one pending task, the server's processing of the pending task does not depend on the processing results or intermediate states of other pending tasks.

[0049] For example, assuming that the task set includes pending task 1, where the data processing type included in pending task 1 is a read operation, and the data storage address included in pending task 1 is 0x01-0x04, then pending task 1 is used to instruct the server to read the data at the storage address 0x01-0x04.

[0050] S202: Determine a target queue in at least one task queue that is allowed to receive tasks to be processed.

[0051] The server includes at least one server core, which may be, for example, a CPU core of the server. The server can process pending tasks through the at least one server core, thereby implementing a read operation or a write operation on data.

[0052] In some embodiments, at least one server core corresponds to a task queue, wherein the task queue includes tasks to be processed. It should be noted that the maximum number of tasks to be processed included in each of the at least one task queues can be the same or different.

[0053] For each server core in the at least one server core, the server core may process the to-be-processed tasks in the task queue corresponding to the server core.

[0054] For example, for server core a and server core b, the task queue corresponding to server core a is task queue A, and the task queue corresponding to server core b is task queue B. Task queue A includes pending tasks 1 and 2, while task queue B includes pending tasks 3 and 4. Therefore, server core a can process pending tasks 1 and 2 in task queue A, while server core b can process pending tasks 3 and 4 in task queue B.

[0055] The number of pending tasks included in the target queue at the current moment is less than the maximum number of pending tasks that can be included. In some embodiments, the task queue with the smallest number of pending tasks included in the at least one task queue at the current moment can be determined as the target queue.

[0056] For example, assume that at least one task queue includes task queue A and task queue B, where task queue A can include a maximum number of tasks to be processed of 5, and task queue B can include a maximum number of tasks to be processed of 5; the number of tasks to be processed included in task queue A at the current moment is 3, and the number of tasks to be processed included in task queue B at the current moment is 1, then task queue B can be determined as the target queue.

[0057] In some embodiments, a task queue in which the number of tasks to be processed is 0 at the current moment among at least one task queue may be determined as a target queue.

[0058] For example, assuming that at least one task queue includes task queue A and task queue B, where the number of pending tasks included in task queue A at the current moment is 0, and the number of pending tasks included in task queue B at the current moment is 1, then task queue A can be determined as the target queue.

[0059] S203. Determine at least one target task from the at least one pending task based on the number of pending tasks that the target queue is allowed to receive and the priority of the at least one pending task; wherein the number of the at least one target task is less than or equal to the number of pending tasks that the target queue is allowed to receive.

[0060] The number of pending tasks that the target queue is allowed to receive may be the difference between the maximum number of pending tasks that the target queue can include and the number of pending tasks included in the target queue at the current moment.

[0061] In some embodiments, at least one pending task can be sorted according to the priority of each of the at least one pending task, wherein the higher the priority of the pending task, the higher the ranking of the pending task. Then, at least one target task is determined in the at least one pending task based on the number of pending tasks that the target queue is allowed to receive. Specifically, when the number of at least one pending task is less than or equal to the number of pending tasks that the target queue is allowed to receive, the at least one pending task is determined as the at least one target task; when the number of at least one pending task is greater than the number of pending tasks that the target queue is allowed to receive, at least one target task is determined in the at least one pending task based on the number of pending tasks that the target queue is allowed to receive and the ranking of the at least one pending task.

[0062] For example, assuming that at least one pending task includes pending task 1, pending task 2, and pending task 3, wherein the priority of pending task 1 is 4, the priority of pending task 2 is 1, and the priority of pending task 3 is 2, then the ranking of pending task 1 is 0, the ranking of pending task 2 is 2, and the ranking of pending task 3 is 1. The number of pending tasks allowed to be received by the target queue is 2, and then at least one target task is determined to include: pending task 1 and pending task 3 in the at least one pending task.

[0063] S204: Distribute at least one target task to a target queue.

[0064] In some embodiments, the at least one target task may be sequentially distributed to a target queue based on the priority of the at least one target task. After the at least one target task is distributed to the target queue, the target queue includes the at least one target task, and in the target queue, the at least one target task is sequentially arranged according to the priority of the at least one target task. A target task with a higher priority is arranged at an upper position in the target queue.

[0065] In some embodiments, at least one target task can be distributed to a target queue using an atomic weak compare-and-swap method. Specifically, the server obtains the tail pointer of the target queue, reads the next node after the current tail of the target queue, and checks whether the tail has been modified by other threads. If the tail has not been modified by other threads, the server inserts the at least one target task into the target queue and then updates the tail pointer.

[0066] It should be noted that the process of distributing at least one target task to the target queue is batch task distribution. In some embodiments, the batch distribution of at least one target task to the target queue can be achieved by using the hardware-implemented memory feature of Intel Transactional Synchronization Extensions (Intel TSX).

[0067] exist Figure 2In the illustrated embodiment, the server determines at least one target task from at least one pending task based on the number of pending tasks that the target queue is allowed to receive and the respective priorities of at least one pending task, and then distributes the at least one target task in batches to the target queue. In the above-mentioned task distribution method, at least one target task to be distributed is determined from at least one pending task, and then the at least one target task is distributed in batches to the target queue, which reduces the risk of lock contention when distributing at least one pending task to the target queue, improves the distribution efficiency of at least one pending task, and saves resource consumption of the server during the task distribution process. In addition, the server determines at least one target task from at least one pending task based on the number of pending tasks that the target queue is allowed to receive and the respective priorities of at least one pending task, and combines the task capacity of the target queue and the priority of the pending task to ensure that the high-priority pending task is processed first within the carrying capacity of the target queue, thereby improving the processing effect of the server on at least one pending task.

[0068] exist Figure 2 Based on the embodiment shown below, combined with Figure 3 The process of obtaining a task set in this application is described in detail.

[0069] Figure 3 A flowchart of obtaining a task set is provided in an embodiment of the present application. Figure 3 As shown, the process may include the following steps:

[0070] S301. Obtain the load value of the server at the current moment.

[0071] In some embodiments, the load of the server may be monitored in real time to determine the load value of the server at the current moment.

[0072] The load value can be the CPU load of the server. The server's current load value indicates the server's current task processing capacity. A larger server load value indicates a smaller server's current task processing capacity; a smaller server load value indicates a larger server's current task processing capacity.

[0073] S302: Obtain the size of the to-be-processed data corresponding to at least one initial task; wherein the initial task is used to perform a read operation or a write operation on the to-be-processed data corresponding to the initial task.

[0074] The initial task is a task received by the server, and the initial task may be, for example, an I / O request task.

[0075] In some embodiments, the initial task includes the operation type, data storage address, and data size of the data to be processed. The operation type can be a read operation or a write operation; the data storage address indicates the storage address of the data to be processed on the server; and the data size indicates the size of the data to be processed. The processing task instructs the server to process the data to be processed at the data storage address based on the operation type of the data to be processed.

[0076] S303 : Process at least one initial task according to the load value and the size of the to-be-processed data corresponding to each of the at least one initial task to obtain at least one to-be-processed task.

[0077] The method of processing at least one processing task to obtain at least one task to be processed can be as follows: determining a first data threshold based on a load value; wherein the first data threshold is negatively correlated with the load value; for each initial task in at least one initial task, processing the initial task based on the first data threshold and the size of the data to be processed corresponding to the initial task to obtain a task to be processed corresponding to the initial task; wherein, at least one task to be processed includes a task to be processed corresponding to each of the at least one initial tasks.

[0078] The first data threshold is used to indicate the upper limit of the amount of data that the server can process at a single time when processing an initial task. In some embodiments, the first data threshold can be determined based on the server's current task processing capacity. If the server's current task processing capacity is low, the first data threshold is determined to be low; if the server's current task processing capacity is high, the first data threshold is determined to be high.

[0079] Specifically, the mapping relationship between the load value, the load interval and the data threshold can be used. For example, assuming that the mapping relationship between the load interval and the data threshold is as shown in Table 1:

[0080] Table 1

[0081]

[0082] The load value of the server at the current moment is 2.5, so the first data threshold is determined to be 4 KB.

[0083] For each initial task in at least one initial task, the to-be-processed task corresponding to the initial task can be obtained in the following manner: when the size of the to-be-processed data corresponding to the initial task is less than or equal to a first data threshold, the initial task is determined as the to-be-processed task corresponding to the initial task; when the size of the to-be-processed data corresponding to the initial task is greater than the first data threshold, the initial task is divided according to the first data threshold to obtain the to-be-processed task corresponding to the initial task; wherein the size of the to-be-processed data corresponding to the to-be-processed task is less than or equal to the first data threshold.

[0084] When the size of the data to be processed corresponding to the initial task is less than or equal to the first data threshold, it indicates that the server can process the data to be processed corresponding to the initial task once, and therefore the initial task can be determined as a task to be processed.

[0085] If the size of the pending data corresponding to the initial task exceeds the first data threshold, it indicates that the server is unable to process the pending data in a single pass. In this case, the initial task can be divided. Specifically, the pending data corresponding to the initial task is divided according to the first data threshold to obtain the pending tasks corresponding to the initial task. It should be noted that in the process of dividing the initial task, the storage addresses of the pending data need to be divided sequentially.

[0086] For example, it is assumed that the size of the to-be-processed data corresponding to the initial task is 64KB, the storage address is 0X00-0X63, and the first data threshold is 16KB. Since the size of the to-be-processed data corresponding to the initial task is greater than the first data threshold, the initial task can be divided according to the first data threshold, and the to-be-processed tasks corresponding to the initial task include to-be-processed task 1, to-be-processed task 2, to-be-processed task 3, and to-be-processed task 4. Among them, the size of the to-be-processed data corresponding to to-be-processed task 1, to-be-processed task 2, to-be-processed task 3, and to-be-processed task 4 is 16KB, and the storage address of the to-be-processed data corresponding to to-be-processed task 1 can be 0X00-0X15, the storage address of the to-be-processed data corresponding to to-be-processed task 2 can be 0X16-0X31, the storage address of the to-be-processed data corresponding to to-be-processed task 3 can be 0X32-0X47, and the storage address of the to-be-processed data corresponding to to-be-processed task 4 can be 0X48-0X63.

[0087] In some embodiments, the method of obtaining at least one task to be processed can also be as follows: according to the load value, determine a first duration; wherein, the first duration and the load value are negatively correlated; according to the first duration, divide the first time period to obtain at least one second time period; wherein, the first time period is the time period from the start moment of receiving at least one initial task to the end moment of receiving at least one initial task; for each second time period, determine the initial task whose receiving moment is within the second time period in at least one initial task, and obtain the task to be processed corresponding to the second time period based on the initial task whose receiving moment is within the second time period; wherein, at least one task to be processed includes at least one task to be processed corresponding to the second time period.

[0088] The first duration is used to indicate the server's receiving window granularity for the initial task. By controlling the first duration, the amount of tasks processed by the server in each time period is matched with the server's task processing capacity at the current moment.

[0089] Specifically, the first duration can be determined based on the corresponding relationship between the load value, the load interval and the duration. For example, it is assumed that the corresponding relationship between the load interval and the duration is as shown in Table 2:

[0090] Table 2

[0091]

[0092] The load value of the server at the current moment is 2.5, so the first duration is determined to be 2ms.

[0093] In some embodiments, the duration of the second time period is the same as the first time period. For example, assuming that the first time period is a time period of 4 ms and the first time period is 2 ms, the first time period is divided according to the first time period, and the obtained second time period includes time period r and time period s, wherein the time period r and time period s are respectively 2 ms.

[0094] In some embodiments, if there is only one initial task whose reception time falls within the second time period in at least one initial task, the initial task whose reception time falls within the second time period is determined as the to-be-processed task corresponding to the second time period. If there are multiple initial tasks whose reception time falls within the second time period in at least one initial task, the multiple initial tasks whose reception time falls within the second time period are merged to obtain the to-be-processed task corresponding to the second time period.

[0095] For example, assuming that among at least one initial task, the number of initial tasks whose receiving time is within the second time period is 3, and the initial tasks whose receiving time is within the second time period include initial task 1, initial task 2 and initial task 3, then initial task 1, initial task 2 and initial task 3 are merged to obtain the tasks to be processed corresponding to the second time period.

[0096] exist Figure 3 In the illustrated embodiment, by obtaining the server's current load value, at least one initial task is processed based on the load value, so that the resulting pending task matches the server's current task processing capacity. For example, when the server load value is high, the pending data corresponding to the pending task is smaller; when the server load value is low, the pending data corresponding to the pending task is larger. In this way, the amount of pending tasks is reduced when the server is highly loaded, and increased when the server is lightly loaded, fully utilizing the server's idle resources and further improving the processing efficiency of pending tasks.

[0097] Based on the above embodiments, Figure 4 The task distribution method provided in the embodiment of the present application is further introduced.

[0098] Figure 4 This is a schematic diagram of a task distribution system provided in an embodiment of the present application. Figure 4 As shown, the task distribution system includes a receiving module, a task determination module, a task distribution module, a dynamic adjustment module, and a task processing module. The receiving module is used to receive at least one initial task. For each initial task in the at least one initial task, the task determination module is used to process the initial task to obtain at least one task to be processed corresponding to the initial task. This process can be seen in Figure 3 S303 in the illustrated embodiment will not be described in detail here.

[0099] The task dispatch module is used to determine at least one target queue in at least one task queue, determine at least one target task in at least one pending task, and dispatch the at least one target task to the target queue. Figure 2 S203 and S204 in the illustrated embodiment will not be described in detail here.

[0100] In some embodiments, the task distribution module needs to determine the priority of at least one pending task. Specifically, for each pending task in at least one pending task, the method of determining the priority of the pending task can be as follows: determining at least one first initial task to which the pending task belongs in at least one initial task, and the pending task is obtained based on the at least one first initial task; determining the receiving time of the pending task according to the receiving time of the at least one first initial task; determining the response index of the pending task according to the response index of the at least one first initial task; wherein the response index is used to indicate the urgency of the task; determining the priority of the pending task according to the receiving time of the pending task and the response index of the pending task.

[0101] In some embodiments, a pending task is obtained by processing at least one first initial task. Therefore, the reception time of the pending task can be determined based on the reception time of the at least one first initial task; and the response index of the pending task can be determined based on the response index of the at least one first initial task. The reception time of the at least one first initial task can be represented as a timestamp.

[0102] Specifically, when the number of at least one first initial task is one, the receiving time of the first initial task is determined as the receiving time of the task to be processed; and the response index of the first initial task is determined as the response index of the task to be processed. When the number of at least one first initial task is multiple, the earliest receiving time among the receiving times of the multiple first initial tasks can be determined as the receiving time of the task to be processed; or, the average of the receiving times of the multiple first initial tasks can be determined as the receiving time of the task to be processed. The smallest response index among the response indexes of the multiple first initial tasks can be determined as the response index of the task to be processed; or, the average of the response indexes of the multiple first processing tasks can be determined as the response index of the task to be processed.

[0103] It should be noted that the larger the response index is, the smaller the urgency of the task to be processed is; and the smaller the response index is, the greater the urgency of the task to be processed is.

[0104] In some embodiments, the priority of a pending task can be determined based on the time it was received, its response index, time weight, and response weight. Specifically, the time it was received and the time weight are multiplied to obtain a first initial priority for the pending task; the response index and the response weight are multiplied to obtain a second initial priority for the pending task; and the difference between the first and second initial priorities is then determined as the priority of the pending task.

[0105] In some embodiments, the server further includes at least one global queue. When there is no target queue in the at least one task queue, the task dispatch module is further configured to dispatch the at least one pending task to the at least one global queue, and the task dispatch module dispatches the pending tasks to the at least one global queue in a manner similar to the manner in which the task dispatch module dispatches the pending tasks to the target queue. Each global queue in the at least one global queue may be, for example, a hash bucket, and the priorities of the at least one global queue may be different.

[0106] In some embodiments, for each task queue in at least one task queue, if the task queue does not contain any pending tasks, a global queue may be detected to determine whether there are pending tasks. If there are pending tasks in the global queue, the pending tasks in the global queue may be migrated to the task queue based on the priority of the global queue. In some embodiments, a Read-Copy-Update (RCU) approach may be used to migrate the pending tasks to the task queue.

[0107] Can be combined Figure 5 To understand, Figure 5 This is a call diagram of a task to be processed provided in an embodiment of the present application. Figure 5 As shown, it includes 3 task queues and 3 global queues, among which the 3 task queues include task queue A corresponding to server core a, task queue B corresponding to server core b, and task queue C corresponding to server core c; the 3 global queues include global queue D, global queue E and global queue F.

[0108] The task distribution module first distributes pending tasks to task queue A, task queue B, and task queue C. When task queue A, task queue B, and task queue C are respectively full, that is, the number of pending tasks currently included in task queue A is equal to the maximum number of pending tasks that task queue A can include, the number of pending tasks currently included in task queue B is equal to the maximum number of pending tasks that task queue B can include, and the number of pending tasks currently included in task queue C is equal to the maximum number of pending tasks that task queue C can include, the task distribution module distributes pending tasks to global queue D, global queue E, and global queue F according to their respective priorities. Specifically, the task distribution module first distributes pending tasks to the global queues with higher priorities.

[0109] Assume that at the current moment, task queue A includes pending tasks 1, 2, and 3, task queue B includes pending tasks 4 and 5, and task queue C contains no pending tasks. At this point, since task queue C contains no pending tasks, it is detected that global queue D contains pending tasks 8, global queue E contains pending tasks 6 and 7, and global queue F contains no pending tasks. The priority of global queues D, E, and F, in descending order, is global queue F, E, and D. Therefore, pending tasks 6 and 7 in global queue E are migrated to task queue C.

[0110] The dynamic adjustment module is used to adjust pending tasks in a task queue based on a load value corresponding to the task queue. Specifically, for each task queue in at least one task queue, a quantity threshold and a second data threshold corresponding to the task queue can be determined based on the load value corresponding to the task queue; tasks to be removed from the task queue can be determined based on the quantity threshold and / or the second data threshold; and the tasks to be removed can be moved from the task queue to a task set.

[0111] The load value corresponding to the task queue is the load value of the server core corresponding to the task queue. In some embodiments, the load value of the server core is used to indicate the task processing capability of the server core. When the load value of the server core is large, it is determined that the task processing capability of the server core is large; when the load value of the server core is small, it is determined that the task processing capability of the server core is small. The load value of the server core can be determined through real-time detection.

[0112] The task queue's corresponding quantity threshold indicates the maximum number of pending tasks that the server core can handle. The task queue's second data threshold indicates the size of pending data that the server core can handle. If the server core has a high task processing capability, the task queue's corresponding quantity threshold and second data threshold will be larger; if the server core has a low task processing capability, the task queue's corresponding quantity threshold and second data threshold will be smaller.

[0113] When the number of pending tasks in the task queue is greater than the quantity threshold, and / or the size of the pending data corresponding to the pending tasks in the task queue is greater than the second data threshold, the pending tasks in the task queue whose order is greater than the quantity threshold, and / or the pending tasks whose pending data is greater than the second data threshold are determined as tasks to be removed.

[0114] In some embodiments, the task to be removed may be moved from the task queue to a task collection, or may be moved to a global queue or an idle task queue.

[0115] The task processing module is used to process the pending tasks in the task queue. Specifically, for each task queue in at least one task queue, the server core corresponding to the task queue processes the pending tasks in the task queue in sequence. For any pending task, the server core performs a read operation or a write operation on the pending data in the server's hard disk or other storage components according to the processing type of the pending task and the storage location of the pending data corresponding to the processing task. In some embodiments, the server core can call the Non-Volatile Memory Express (NVMe) host controller interface specification to complete the read operation or the write operation on the pending data, and after completing the read operation or the write operation on the pending task, generate an optimization strategy based on the current processing result, and send the optimization strategy to the dynamic adjustment module. The dynamic adjustment module can adjust the pending tasks in the task queue according to the optimization strategy.

[0116] exist Figure 4 In the illustrated embodiment, the priority of pending tasks is determined from multiple dimensions, combining the reception time and response indicators of pending tasks. This allows the priority of pending tasks to better meet actual needs, prioritizes pending tasks with earlier reception times and higher urgency, and improves the processing effect of pending tasks. During the processing of pending tasks, the load value corresponding to the task queue is detected in real time, and the pending tasks in the task queue are adjusted based on the load value, achieving real-time dynamic matching of load and task processing, optimizing resource utilization efficiency, and reducing the probability of resources being idle during low load or overloaded during high load.

[0117] In summary, see Figure 6 Further understand the task distribution method provided in the embodiments of the present application. Figure 6 A signaling diagram of a task distribution method provided in an embodiment of the present application, such as Figure 6 As shown, after receiving at least one initial task, the receiving module sends the at least one initial task to the task determination module. The task determination module processes the at least one initial task to obtain at least one task to be processed, and sends the at least one task to be processed to the task distribution module. The task distribution module distributes the at least one task to be processed to the target queue. Then, the task processing module processes the tasks to be processed in the at least one task queue. For each task queue in the at least one task queue, while the server core corresponding to the task queue processes the tasks to be processed in the task queue, the dynamic adjustment module can adjust the tasks to be processed in the task queue according to the load value corresponding to the task queue.

[0118] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.

[0119] Figure 7 This is a structural diagram of a task distribution device provided in an embodiment of the present application. Figure 7 As shown, an embodiment of the present application further provides a task distribution device 70, which includes an acquisition module 71, a first determination module 72, a second determination module 73 and a distribution module 74, wherein:

[0120] An acquisition module 71 is configured to acquire a task set, wherein the task set includes at least one task to be processed, and the task to be processed is configured to perform a read operation or a write operation on data;

[0121] A first determining module 72 is configured to determine a target queue in at least one task queue that is allowed to receive tasks to be processed;

[0122] A second determining module 73 is configured to determine at least one target task from the at least one pending task based on the number of pending tasks that the target queue is allowed to receive and the priority of the at least one pending task; wherein the number of the at least one target task is less than or equal to the number of pending tasks that the target queue is allowed to receive;

[0123] The distribution module 74 is configured to distribute at least one target task to a target queue.

[0124] In a possible implementation, the acquisition module 71 is specifically configured to:

[0125] Get the server's load value at the current moment;

[0126] Obtaining the size of the to-be-processed data corresponding to each of at least one initial task; wherein the initial task is used to perform a read operation or a write operation on the to-be-processed data corresponding to the initial task;

[0127] At least one initial task is processed according to the load value and the size of the to-be-processed data corresponding to each of the at least one initial task to obtain at least one to-be-processed task.

[0128] In a possible implementation, the acquisition module 71 is specifically configured to:

[0129] Determining a first data threshold according to the load value; wherein the first data threshold is negatively correlated with the load value;

[0130] For each of the at least one initial task, processing the initial task according to the first data threshold and the size of the to-be-processed data corresponding to the initial task to obtain a to-be-processed task corresponding to the initial task;

[0131] The at least one to-be-processed task includes at least one to-be-processed task corresponding to each of the initial tasks.

[0132] In a possible implementation, the acquisition module 71 is specifically configured to:

[0133] When the size of the to-be-processed data corresponding to the initial task is less than or equal to the first data threshold, determining the initial task as the to-be-processed task corresponding to the initial task;

[0134] When the size of the data to be processed corresponding to the initial task is greater than the first data threshold, the initial task is divided according to the first data threshold to obtain the tasks to be processed corresponding to the initial task; wherein the size of the data to be processed corresponding to the tasks to be processed is less than or equal to the first data threshold.

[0135] In a possible implementation, the acquisition module 71 is specifically configured to:

[0136] Determining a first duration according to the load value; wherein the first duration is negatively correlated with the load value;

[0137] Dividing the first time period according to the first duration to obtain at least one second time period; wherein the first time period is a time period from a start time of receiving the at least one initial task to an end time of receiving the at least one initial task;

[0138] For each second time period, determining an initial task whose receiving time is within the second time period from at least one initial task, and obtaining a to-be-processed task corresponding to the second time period based on the initial task whose receiving time is within the second time period;

[0139] The at least one task to be processed includes at least one task to be processed corresponding to the second time period.

[0140] In a possible implementation, for each of the at least one pending task, the task distribution device 70 further includes a processing module, the processing module being specifically configured to:

[0141] Determining at least one first initial task to which the task to be processed belongs from the at least one initial task, wherein the task to be processed is obtained based on the at least one first initial task;

[0142] Determining a receiving time of a task to be processed according to a receiving time of each of the at least one first initial tasks;

[0143] Determining a response index of a task to be processed based on the response index of at least one first initial task; wherein the response index is used to indicate the urgency of the task;

[0144] The priority of the pending tasks is determined based on the receiving time of the pending tasks and the response indicators of the pending tasks.

[0145] In a possible implementation, for each task queue in the at least one task queue, the task distribution device 70 further includes a migration module, and the migration module is specifically configured to:

[0146] Determine a quantity threshold and a second data threshold corresponding to the task queue according to a load value corresponding to the task queue;

[0147] Determining tasks to be removed from the task queue according to a quantity threshold and / or a second data threshold;

[0148] Move the task to be removed from the task queue to the task collection.

[0149] For the description of the features in the embodiment corresponding to the task distribution device 70, reference can be made to the relevant description of the embodiment corresponding to the task distribution method, which will not be repeated here.

[0150] Figure 8 This is a schematic diagram of the structure of the electronic device provided in this application. Figure 8 As shown, the electronic device 80 provided in this embodiment includes: at least one processor 801 and a memory 802. Optionally, the electronic device 80 further includes a communication component 803. The processor 801, the memory 802 and the communication component 803 are connected via a bus.

[0151] During the specific implementation process, at least one processor 801 executes the computer-executable instructions stored in the memory 802, so that the at least one processor 801 executes the above-mentioned task distribution method embodiment.

[0152] The specific implementation process of the processor 801 can be found in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here in this embodiment.

[0153] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the application may be directly executed by a hardware processor or by a combination of hardware and software modules within the processor.

[0154] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage.

[0155] A bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be categorized as address buses, data buses, and control buses. For ease of illustration, the buses in the drawings of this application are not limited to just one bus or just one type of bus.

[0156] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned task distribution method embodiments when running.

[0157] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0158] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above-mentioned task distribution method embodiments are implemented.

[0159] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned task distribution method embodiments are implemented.

[0160] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0161] The above is a detailed introduction to a task distribution method, device, electronic device and storage medium provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.

Claims

1. A task distribution method, characterized in that: Applicable to servers, including: Acquire a task set, wherein the task set includes at least one task to be processed, and the task to be processed is used to perform a read operation or a write operation on data; Determining a target queue in at least one task queue that is allowed to receive the pending task; Determining at least one target task from the at least one task to be processed according to the number of tasks to be processed that the target queue is allowed to receive and the priority of the at least one task to be processed; wherein the number of the at least one target task is less than or equal to the number of tasks to be processed that the target queue is allowed to receive; Distribute the at least one target task to the target queue.

2. The method according to claim 1, characterized in that The acquisition task set includes: Obtaining the load value of the server at the current moment; Obtaining the size of the to-be-processed data corresponding to each of at least one initial task; wherein the initial task is used to perform a read operation or a write operation on the to-be-processed data corresponding to the initial task; The at least one initial task is processed according to the load value and the size of the to-be-processed data corresponding to each of the at least one initial task to obtain the at least one to-be-processed task.

3. The method according to claim 2, characterized in that The processing of the at least one initial task according to the load value and the size of the to-be-processed data corresponding to each of the at least one initial task to obtain the at least one to-be-processed task includes: Determining a first data threshold according to the load value; wherein the first data threshold is negatively correlated with the load value; For each of the at least one initial task, processing the initial task according to the first data threshold and the size of the to-be-processed data corresponding to the initial task to obtain a to-be-processed task corresponding to the initial task; The at least one to-be-processed task includes each to-be-processed task corresponding to the at least one initial task.

4. The method according to claim 3, characterized in that The processing of the initial task according to the first data threshold and the size of the to-be-processed data corresponding to the initial task to obtain the to-be-processed task corresponding to the initial task includes: When the size of the to-be-processed data corresponding to the initial task is less than or equal to the first data threshold, determining the initial task as the to-be-processed task corresponding to the initial task; When the size of the data to be processed corresponding to the initial task is greater than the first data threshold, the initial task is divided according to the first data threshold to obtain the tasks to be processed corresponding to the initial task; wherein the size of the data to be processed corresponding to the tasks to be processed is less than or equal to the first data threshold.

5. The method according to claim 2, characterized in that The processing of the at least one initial task according to the load value and the size of the to-be-processed data corresponding to each of the at least one initial task to obtain the at least one to-be-processed task includes: Determining a first duration according to the load value; wherein the first duration is negatively correlated with the load value; Dividing the first time period according to the first duration to obtain at least one second time period; wherein the first time period is a time period from a start time of receiving the at least one initial task to an end time of receiving the at least one initial task; For each second time period, determining an initial task whose receiving time is within the second time period from the at least one initial task, and obtaining a to-be-processed task corresponding to the second time period based on the initial task whose receiving time is within the second time period; The at least one task to be processed includes the at least one task to be processed corresponding to the second time period.

6. The method according to any one of claims 2 to 5, characterized in that For each task to be processed in the at least one task to be processed, the method further includes: Determining at least one first initial task to which the task to be processed belongs from the at least one initial task, wherein the task to be processed is obtained based on the at least one first initial task; Determining a receiving time of the task to be processed according to a receiving time of each of the at least one first initial task; Determining a response index of the task to be processed based on the response index of each of the at least one first initial task; wherein the response index is used to indicate the urgency of the task; The priority of the task to be processed is determined according to the receiving time of the task to be processed and the response index of the task to be processed.

7. The method according to any one of claims 1 to 5, characterized in that For each task queue in the at least one task queue, the method further includes: Determining a quantity threshold and a second data threshold corresponding to the task queue according to a load value corresponding to the task queue; Determining tasks to be removed in the task queue according to the quantity threshold and / or the second data threshold; The to-be-removed task is moved from the task queue to the task set.

8. A task distribution device, characterized in that: include: An acquisition module is used to acquire a task set, wherein the task set includes at least one task to be processed, and the task to be processed is used to perform a read operation or a write operation on data; A first determining module is used to determine a target queue that is allowed to receive tasks to be processed in at least one task queue; a second determining module, configured to determine at least one target task from the at least one to-be-processed task based on the number of to-be-processed tasks that the target queue is allowed to receive and the priority of the at least one to-be-processed task; wherein the number of the at least one target task is less than or equal to the number of to-be-processed tasks that the target queue is allowed to receive; A distribution module is used to distribute the at least one target task to the target queue.

9. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the task distribution method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the task distribution method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Task scheduling method and device

    CN110096353A

  • Task scheduling method and device and storage medium

    CN118733210A

  • Dynamic CPU scheduling method, system and device based on CPU busy state and medium

    CN120276839A

  • Task processing method and apparatus, and related device

    WO2023124947A1