Resource scheduling method and device, storage medium and electronic equipment
By seizing resources between queues of large business production lines and using idle resources to process pending tasks, the problem of low resource utilization is solved, and timely task processing and efficient resource allocation are achieved.
Patent Information
- Application Number
- CN202310820857.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-06
- Publication Date
- 2025-01-07
AI Technical Summary
The resource utilization rate in large business production lines is low, resulting in the problems of queue tasks accumulation and resource idleness.
By seizing resources between queues, using idle resources to process pending tasks, ensuring timely processing of tasks and improving overall resource utilization. The specific method includes determining whether there is a preemption task in the queue, determining the preemption target queue based on resource occupancy rate and historical task processing, and releasing the preemption resource when necessary to prioritize the processing of its own queue tasks.
It effectively avoids task accumulation, improves the overall resource utilization rate of all queues, and ensures timely processing of tasks and efficient allocation of resources.
Smart Images

Figure CN119271360A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a resource scheduling method, device, storage medium and electronic device. Background Art
[0002] A large business production line often requires a large amount of computing resources to complete calculations, and a business production line includes multiple business nodes, each of which needs to handle different types of tasks, such as data collection, data cleaning, format conversion, etc. In related technologies, a resource cluster of a business production line usually uses queues to handle tasks of different business nodes. For example, a queue is first created for each business node, and rated resources are pre-allocated to each queue. When a new task from a business node is received, the new task can be divided into the corresponding queue for processing. However, this isolation method may cause the problem of tasks piling up in one queue and the long-term idleness of another queue, resulting in low resource utilization of the entire business production line. Summary of the invention
[0003] The present application provides a resource scheduling method, device, storage medium and electronic device, which can solve the problem of low resource utilization of the entire business production line.
[0004] The specific technical solutions are as follows:
[0005] In a first aspect, an embodiment of the present application provides a resource scheduling method, the method comprising:
[0006] Get the current pending tasks in the first queue;
[0007] In a case where there are idle resources in the first queue and the number of the idle resources can satisfy the current task to be processed, using the idle resources in the first queue to process the current task to be processed;
[0008] In the case where the idle resources exist in the first queue and the quantity of the idle resources cannot satisfy the current task to be processed, or in the case where the idle resources do not exist in the first queue, the current task to be processed is used as a preempted task to occupy the idle resources in the second queue, and the occupied idle resources are used to process the current task to be processed, wherein the preempted task is a task in its own queue that occupies resources in other queues, and the second queue is other queues with sufficient idle resources to process the current task to be processed.
[0009] It can be seen from the above scheme that in the embodiment of the present application, when there are idle resources in the first queue and the number of idle resources can meet the current tasks to be processed, the idle resources in the first queue are used to process the current tasks to be processed. When there are idle resources in the first queue and the number of idle resources cannot meet the current tasks to be processed, or when there are no idle resources in the first queue, instead of waiting for the idle resources in the first queue, the current tasks to be processed are used as preempted tasks to occupy the idle resources in the second queue, and the occupied idle resources are used to process the current tasks to be processed. In this way, the current tasks to be processed in the first queue can be processed in a timely manner without affecting the progress of task processing in the second queue, thereby avoiding task accumulation and improving the overall resource utilization of all queues.
[0010] In a first possible implementation manner of the first aspect, before taking the current to-be-processed task as a preempted task to occupy the idle resources in the second queue, the method further includes:
[0011] Determine whether the preempted task exists in the first queue;
[0012] The step of using the current task to be processed as a preempted task to occupy the idle resources in the second queue includes:
[0013] In the case that the preempted task does not exist in the first queue, the current task to be processed is used as the preempted task to occupy the idle resources in the second queue.
[0014] It can be seen from the above scheme that the embodiment of the present application first determines whether there is a preempting task in the first queue. Only when there is no preempting task in the first queue, it is determined that the first queue is indeed filled with tasks in its own queue, and the current task to be processed is used as a preempting task to occupy the idle resources in the second queue, thereby avoiding preempting other queues when the resources of the first queue are not filled with tasks in its own queue, thereby reducing the risk of being eliminated by other queues due to preempting tasks.
[0015] In a second possible implementation manner of the first aspect, the method further includes:
[0016] In the case that the preempted task exists in the first queue, the occupation of resources by the preempted task in the first queue is released according to the amount of resources required by the current task to be processed, and the released resources are used to process the current task to be processed.
[0017] It can be seen from the above scheme that when the embodiment of the present application determines that there is a preempting task in the first queue, it can be determined that the first queue is not fully occupied by tasks in its own queue. In order to reduce the risk of the current pending task in the first queue preempting the resources of the second queue and being eliminated, the occupation of resources by the preempting task in the first queue can be released according to the number of resources required by the current pending task, and the released resources can be used to process the current pending task, thereby ensuring priority processing of tasks in its own queue.
[0018] In a third possible implementation manner of the first aspect, before taking the current to-be-processed task as a preempted task to occupy the idle resources in the second queue, the method further includes:
[0019] The second queue is determined from queues other than the first queue based on the resource occupancy rates of queues other than the first queue and / or the processing status of historical tasks corresponding to the currently processed task, wherein the processing status includes processing time and / or resource occupancy status.
[0020] It can be seen from the above scheme that the embodiment of the present application determines the second queue from queues other than the first queue based on the resource occupancy rate of other queues other than the first queue and / or the processing status of historical tasks corresponding to the current task to be processed, thereby avoiding the risk of being quickly eliminated after preempting the resources of the second queue.
[0021] In a fourth possible implementation manner of the first aspect, the method further includes:
[0022] When the second queue does not exist in the other queues, directly wait in the first queue for sufficient idle resources; or,
[0023] In the case that the second queue does not exist in the other queues, determine whether the preempting task exists in the first queue; in the case that the preempting task exists in the first queue, release the occupation of resources by the preempting task in the first queue according to the number of resources required for the current task to be processed, and use the released resources to process the current task to be processed; in the case that the preempting task does not exist in the first queue, wait for sufficient free resources in the first queue.
[0024] It can be known from the above scheme that in the embodiment of the present application, when there are not enough idle resources in the first queue to process the current pending task, and there is no second queue that can provide enough idle resources for the current pending task to preempt, the first queue can be directly waited for sufficient idle resources, or it can continue to determine whether there is a preempting task in the first queue. When there is a preempting task in the first queue, the preempting task can be removed from the first queue for use by the current pending task, otherwise the first queue will be waited for sufficient idle resources. Since the second method is to choose to remove the preempting tasks of its own queue on the basis of excluding the fact that other queues do not have enough resources, rather than directly removing the preempting tasks of its own queue, the risk of the preempting tasks in its own queue being quickly removed is reduced on the basis of maximizing the processing efficiency of the current pending task, thereby improving the overall resource utilization of all queues.
[0025] In a fifth possible implementation manner of the first aspect, the resource types in the first queue, the second queue, and the other queues are the same, the resource types include a graphics processor GPU type and a central processing unit CPU type, the tasks in the resource scheduling include first-type tasks and second-type tasks, the resources required for the first-type tasks include GPU resources and CPU resources, and the resources required for the second-type tasks include CPU resources, and the method further includes:
[0026] When there are idle CPU resources allocated to the first type of tasks, the second type of tasks are processed using idle CPU resources allocated to the first type of tasks.
[0027] It can be seen from the above scheme that in the embodiment of the present application, when there is idle CPU resources pre-allocated to the first type of task that needs to call GPU resources and CPU resources at the same time, the idle resources can be temporarily allocated to the second type of task for use, thereby realizing resource mixing and improving resource utilization.
[0028] In a sixth possible implementation manner of the first aspect, the method further includes:
[0029] In the process of not receiving the first type of task and evenly distributing the CPU resources allocated to the first type of task to multiple second type of tasks for use, if the first type of task is received, then according to the number of CPUs required for the first type of task, the second type of task occupying the CPU resources is migrated from one computer device to another computer device, so that the idle CPU resources in a certain computer device are sufficient to process the first type of task, wherein the computer devices to which the CPU resources allocated to the first type of task belong include at least one, and each of the computer devices includes at least one CPU.
[0030] It can be seen from the above scheme that in the embodiment of the present application, when no first type of task is received and the CPU resources allocated to the first type of task are evenly distributed to multiple second type of tasks for use, if the first type of task is received again, the idle computer equipment can be freed up for the first type of task by migrating the second type of task, thereby ensuring that both types of tasks are processed in a timely manner.
[0031] In a second aspect, an embodiment of the present application provides a resource scheduling device, the device comprising:
[0032] An acquisition unit, used for acquiring the current pending tasks in the first queue;
[0033] A first processing unit, configured to process the current task to be processed by using the idle resources in the first queue when there are idle resources in the first queue and the number of the idle resources can satisfy the current task to be processed;
[0034] An occupying unit, configured to, when the idle resources exist in the first queue and the number of the idle resources cannot satisfy the current task to be processed, or when the idle resources do not exist in the first queue, use the current task to be processed as a preempting task to occupy the idle resources in the second queue, wherein the preempting task is a task in its own queue that occupies resources in other queues, and the second queue is another queue with sufficient idle resources to process the current task to be processed;
[0035] The first processing unit is further configured to utilize the occupied idle resources to process the current task to be processed.
[0036] In a first possible implementation manner of the second aspect, the apparatus further includes:
[0037] A judging unit, configured to judge whether there is the preempting task in the first queue before taking the current task to be processed as the preempting task to occupy the idle resources in the second queue;
[0038] The occupying unit is used to occupy the idle resources in the second queue by using the current task to be processed as the preempting task when the preempting task does not exist in the first queue.
[0039] In a second possible implementation manner of the second aspect, the device further includes:
[0040] a releasing unit, configured to release the occupation of resources by the preempting task in the first queue according to the number of resources required by the current task to be processed, when the preempting task exists in the first queue;
[0041] The first processing unit is further configured to process the current task to be processed using the released resources.
[0042] In a third possible implementation manner of the second aspect, the device further includes:
[0043] A determination unit is used to determine the second queue from other queues except the first queue before using the current task to be processed as a preempted task to occupy the idle resources in the second queue, according to the resource occupancy rates of other queues except the first queue and / or the processing status of historical tasks corresponding to the current task to be processed, wherein the processing status includes processing time and / or resource occupancy status.
[0044] In a fourth possible implementation manner of the second aspect, the device further includes:
[0045] The second processing unit is configured to directly wait for sufficient idle resources in the first queue when the second queue does not exist in the other queues; or
[0046] In the case that the second queue does not exist in the other queues, determine whether the preempting task exists in the first queue; in the case that the preempting task exists in the first queue, release the occupation of resources by the preempting task in the first queue according to the number of resources required for the current task to be processed, and use the released resources to process the current task to be processed; in the case that the preempting task does not exist in the first queue, wait for sufficient free resources in the first queue.
[0047] In a fifth possible implementation manner of the second aspect, the resource types in the first queue, the second queue, and the other queues are the same, the resource types include a graphics processor GPU type and a central processing unit CPU type, the tasks in the resource scheduling include first-type tasks and second-type tasks, the resources required for the first-type tasks include GPU resources and CPU resources, and the resources required for the second-type tasks include CPU resources, and the device further includes:
[0048] The third processing unit is configured to process the second type of task by utilizing idle resources in the CPU resources allocated to the first type of task when idle resources are available in the CPU resources allocated to the first type of task.
[0049] In a sixth possible implementation manner of the second aspect, the apparatus further includes:
[0050] A migration unit is used for, in the process of not receiving the first type of task and uniformly distributing the CPU resources allocated to the first type of task to multiple second type of tasks for use, if the first type of task is received, migrating the second type of task occupying the CPU resources from one computer device to another computer device according to the number of CPUs required by the first type of task, so that the idle CPU resources in a certain computer device are sufficient to process the first type of task, wherein the computer devices to which the CPU resources allocated to the first type of task belong include at least one, and each of the computer devices includes at least one CPU.
[0051] It can be seen from the above scheme that in the embodiment of the present application, when there are idle resources in the first queue and the number of idle resources can meet the current tasks to be processed, the idle resources in the first queue are used to process the current tasks to be processed. When there are idle resources in the first queue and the number of idle resources cannot meet the current tasks to be processed, or when there are no idle resources in the first queue, instead of waiting for the idle resources in the first queue, the current tasks to be processed are used as preempted tasks to occupy the idle resources in the second queue, and the occupied idle resources are used to process the current tasks to be processed. In this way, the current tasks to be processed in the first queue can be processed in a timely manner without affecting the progress of task processing in the second queue, thereby avoiding task accumulation and improving the overall resource utilization of all queues.
[0052] In a third aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any possible implementation manner of the first aspect.
[0053] In a fourth aspect, an embodiment of the present application provides an electronic device, the electronic device comprising:
[0054] one or more processors;
[0055] The processor is coupled to a storage device, and the storage device is used to store one or more programs;
[0056] When one or more programs are executed by one or more processors, the electronic device implements the method described in any possible implementation manner of the first aspect.
[0057] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes instructions. When the instructions are executed on a computer or a processor, the computer or the processor executes the method described in any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art description are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative work.
[0059] Figure 1 A schematic diagram of a resource scheduling method provided in an embodiment of the present application;
[0060] Figure 2 An example diagram of resource preemption provided in an embodiment of the present application;
[0061] Figure 3 A flowchart of another resource scheduling method provided in an embodiment of the present application;
[0062] Figure 4 A flowchart of another resource scheduling method provided in an embodiment of the present application;
[0063] Figure 5 An example diagram of resource migration provided in an embodiment of the present application;
[0064] Figure 6 A block diagram of a resource scheduling device provided in an embodiment of the present application;
[0065] Figure 7 A schematic diagram of the structure of an electronic device or computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0066] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0067] It should be noted that, in the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The terms "including" and "having" in the embodiments of the present application and the accompanying drawings and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.
[0068] Figure 1The flowchart of a resource scheduling method is shown in FIG. 1 , which can be applied to electronic equipment or computer equipment, and can be applied to a terminal or a server. Specifically, the method can include the following steps:
[0069] S110: Obtain the current pending tasks in the first queue.
[0070] In actual applications, different tasks can be divided into different queues according to different task requirements, and rated computing resources, such as CPU (Central Processing Unit) resources, GPU (Graphics Processing Unit) resources, etc., can be pre-allocated to each queue before task processing. Different queues can be different nodes in a project, or they can process different projects separately. The resource types in each queue are the same, including GPU type and CPU type, that is, resources of the same resource type can be divided into multiple queues for processing.
[0071] When the embodiment of the present application is applied to a terminal, the terminal can receive a task processing request, which includes the current task to be processed; when the embodiment of the present application is applied to a server, after receiving the task processing request, the terminal can upload the task processing request to the server, and the server obtains the current task to be processed from the task processing request.
[0072] S120: When there are idle resources in the first queue and the number of idle resources can satisfy the current task to be processed, the current task to be processed is processed using the idle resources in the first queue.
[0073] After obtaining the current pending task in the first queue, it is necessary to allocate resources for the current pending task so that the allocated resources are used to process the current pending task. The embodiment of the present application can first determine whether there are enough idle resources in its own queue (i.e., the first queue) to process the current pending task. For example, if the current pending task requires 2 CPUs, and the number of idle CPUs present in the first queue is ≧2, then it can be determined that there are idle resources in the first queue and the number of idle resources can meet the current pending task, but if the number of idle CPUs present in the first queue is only 1, then it can be determined that there are idle resources in the first queue and the number of idle resources cannot meet the current pending task.
[0074] S130: When there are idle resources in the first queue and the number of idle resources cannot meet the needs of the current task to be processed, or when there are no idle resources in the first queue, the current task to be processed is used as a preempted task to occupy the idle resources in the second queue, and the occupied idle resources are used to process the current task to be processed.
[0075] In the case where there are idle resources in the first queue and the number of idle resources cannot meet the current pending tasks, or in the case where there are no idle resources in the first queue, in order to improve resource utilization, other queues except the first queue can be judged one by one to determine whether there is a second queue with sufficient idle resources to process the current pending tasks. If there is a second queue, the current pending tasks can be used as preemptive tasks to occupy the idle resources in the second queue, and the occupied idle resources can be used to process the current pending tasks. Among them, the preemptive tasks are tasks in their own queues that occupy resources in other queues, and the second queues are other queues with sufficient idle resources to process the current pending tasks.
[0076] like Figure 2 As shown, there are 8 CPUs in the first queue, and all of them are occupied. There are 10 CPUs in the second queue, and 4 of them are idle. When a new task is received in the first queue, the new task can be used as a preemptive task to occupy the idle resources in the second queue, and the occupied idle resources can be used to process the new task.
[0077] The method for determining the second queue from other queues except the first queue includes: determining the second queue from other queues except the first queue based on the resource occupancy rate of other queues except the first queue and / or the processing status of historical tasks corresponding to the current task to be processed, wherein the processing status includes processing time and / or resource occupancy status.
[0078] The historical tasks corresponding to the current pending task include the same tasks processed before the current pending task and / or the historical tasks at the same relative processing time point as the current pending task in a processing cycle. For example, when the processing cycle is one day, and the relative processing time point of the current pending task is 10 a.m., then the task that needs to be processed at 10 a.m. in the historical time is the historical task corresponding to the current pending task. Resource occupancy includes the amount of computing resource occupancy.
[0079] When the resource occupancy rate of a queue is less than or equal to the resource occupancy rate threshold, and the processing time of the historical task corresponding to the current pending task is less than or equal to the processing time threshold, and the resource occupancy of the historical task corresponding to the current pending task is less than or equal to N computing resources, the queue can be determined as the second queue. Among them, the total number of computing resources of the second queue * (1-resource occupancy rate threshold) ≧ the resource occupancy of the historical task corresponding to the current pending task. The specific values of the resource occupancy rate threshold, the processing time threshold and N can be determined based on actual experience.
[0080] When the second queue does not exist, wait for sufficient idle resources in the first queue, and when sufficient idle resources are available, use the idle resources in the first queue to process the current pending task.
[0081] The resource scheduling method provided in the embodiment of the present application utilizes the idle resources in the first queue to process the current tasks to be processed when there are idle resources in the first queue and the number of idle resources can satisfy the current tasks to be processed; and when there are idle resources in the first queue and the number of idle resources cannot satisfy the current tasks to be processed, or when there are no idle resources in the first queue, instead of waiting for the idle resources in the first queue, the current tasks to be processed are used as preempted tasks to occupy the idle resources in the second queue, and the occupied idle resources are used to process the current tasks to be processed. In this way, the current tasks to be processed in the first queue can be processed in a timely manner without affecting the progress of task processing in the second queue, thereby avoiding task accumulation and improving the overall resource utilization of all queues.
[0082] Based on the above method embodiment, another embodiment of the present application further provides a resource scheduling method, such as Figure 3 As shown, the method includes:
[0083] S210: Obtain the current pending task in the first queue.
[0084] S220: When there are idle resources in the first queue and the number of idle resources can satisfy the current task to be processed, the current task to be processed is processed using the idle resources in the first queue.
[0085] S230: When there are idle resources in the first queue and the number of idle resources cannot meet the current tasks to be processed, or when there are no idle resources in the first queue, determine whether there is a preempting task in the first queue. If there is a preempting task, execute step S240; if there is no preempting task, execute step S250.
[0086] In one implementation, in order to identify the queue to which each task belongs, a queue identifier can be added to each task. In this case, it can be directly determined whether the tasks being processed in the first queue contain queue identifiers of other queues. If there are queue identifiers of other queues, it can be determined that there are preempted tasks in the first queue. When there are only two queues, the ratio of the number of resources occupied by all tasks in the other queue to the rated number of resources can be determined. If the ratio is less than or equal to 1, it is determined that the other queue has not preempted the first queue. If the ratio is greater than 1, it is determined that the other queue has preempted the first queue.
[0087] S240: according to the number of resources required by the current task to be processed, release the occupation of resources by the preempted tasks in the first queue, and use the released resources to process the current task to be processed.
[0088] When there are preempted tasks in the first queue, in order to ensure that the task itself is processed first, the occupation of resources by the preempted tasks in the first queue can be released according to the number of resources required by the current pending task, and the released resources can be used to process the current pending task. For example, if the number of preempted resources in the first queue is 3 GPUs and the number of resources required by the current pending task is 1 GPU, one of the GPUs can be released and the released GPU can be used to process the current pending task first.
[0089] S250: Taking the currently-to-be-processed task as a preempted task to occupy idle resources in the second queue.
[0090] When there is no preempting task in the first queue, in order to improve the resource utilization of all queues, the current pending task is used as a preempting task to occupy the idle resources in the second queue. When there is no second queue, wait for sufficient idle resources in the first queue.
[0091] The resource scheduling method provided by the embodiment of the present application first determines whether there is a preempting task in the first queue. Only when there is no preempting task in the first queue, it is determined that the first queue is indeed full of tasks in its own queue, and the current task to be processed is used as a preempting task to occupy the idle resources in the second queue, thereby avoiding the situation where the resources of the first queue are not fully occupied by tasks in its own queue, such as preempting other queues, thereby reducing the risk of preempting tasks being eliminated by other queues. In the case of determining that there is a preempting task in the first queue, it can be determined that the first queue is not fully occupied by tasks in its own queue. In order to reduce the risk of the current task to be processed in the first queue being eliminated due to preempting the resources of the second queue, the occupation of resources by the preempting task in the first queue can be released according to the number of resources required by the current task to be processed, and the current task to be processed is processed using the released resources, thereby ensuring the priority processing of the tasks in its own queue.
[0092] Based on the above method embodiment, another embodiment of the present application further provides a resource scheduling method, such as Figure 4 As shown, the method includes:
[0093] S310: Obtain the current pending task in the first queue.
[0094] S320: When there are idle resources in the first queue and the number of idle resources can satisfy the current task to be processed, the idle resources in the first queue are used to process the current task to be processed.
[0095] S330: When there are idle resources in the first queue and the number of idle resources cannot meet the current tasks to be processed, or when there are no idle resources in the first queue, determine whether there is a second queue. If there is a second queue, execute step S340; if there is no second queue, execute step S350.
[0096] The second queue is another queue with sufficient idle resources to process the current pending task. It can be determined whether there is a second queue in the other queues except the first queue based on the resource occupancy rate of the other queues except the first queue and / or the processing status of the historical tasks corresponding to the current pending task, wherein the processing status includes the processing time and / or the resource occupancy status.
[0097] For example, when a queue among the other queues except the first queue satisfies at least one of the following conditions, it is determined that the second queue exists; otherwise, the second queue does not exist:
[0098] The resource usage of a queue is less than or equal to the resource usage threshold.
[0099] The processing time of the historical task corresponding to the current task to be processed is less than or equal to the processing time threshold;
[0100] The resource usage of the historical tasks corresponding to the current pending tasks is less than or equal to N computing resources.
[0101] In addition, when there is no second queue in other queues, it is also possible to directly wait for sufficient idle resources in the first queue.
[0102] S340: Taking the current task to be processed as a preempted task to occupy idle resources in the second queue, and using the occupied idle resources to process the current task to be processed.
[0103] When the second queue exists, the current task to be processed can be used as a preempted task to occupy idle resources in the second queue, and the occupied idle resources can be used to process the current task to be processed, thereby improving the resource utilization of the second queue.
[0104] S350: Determine whether there is a preempting task in the first queue; if there is a preempting task, execute step S360; if there is no preempting task, execute step S370.
[0105] When there is no second queue, in order to ensure that the current pending tasks in the first queue can be processed in time, it is possible to continue to determine whether there are preempting tasks in the first queue. If there are preempting tasks, the current pending tasks can be processed based on the resources occupied by the preempting tasks. If there are no preempting tasks, the only thing left is to wait in the first queue for sufficient idle resources.
[0106] S360: according to the number of resources required by the current task to be processed, release the occupation of resources by the preempted tasks in the first queue, and use the released resources to process the current task to be processed.
[0107] When there is a preempting task in the first queue, the number of resources required for the current task to be processed can be used to determine whether the number of resources occupied by the preempted task in the first queue can meet the current task to be processed; if the current task to be processed is met, the occupation of resources by the preempting task in the first queue can be released according to the number of resources required for the current task to be processed, and the released resources can be used to process the current task to be processed; if the current task to be processed is not met, step 370 is executed.
[0108] S370: Waiting for sufficient idle resources in the first queue.
[0109] When there is no preempted task in the first queue or the number of resources preempted by the preempted task in the first queue does not meet the current pending tasks, you can wait for sufficient idle resources in the first queue. When there are sufficient idle resources, use the idle resources in the first queue to process the current pending tasks.
[0110] The resource scheduling method provided by the embodiment of the present application can directly wait for sufficient idle resources in the first queue when there are not enough idle resources in the first queue to process the current pending task, and there is no second queue that can provide sufficient idle resources for the current pending task to preempt. Alternatively, it can continue to determine whether there is a preempting task in the first queue. When there is a preempting task in the first queue, the preempting task can be removed from the first queue for use by the current pending task, otherwise the first queue will wait for sufficient idle resources. Since the second method is to select the preempting task of its own queue to be removed on the basis of excluding the fact that other queues do not have sufficient resources, rather than directly removing the preempting task of its own queue, the risk of the preempting task in its own queue being quickly removed is reduced on the basis of maximizing the processing efficiency of the current pending task, thereby improving the overall resource utilization of all queues.
[0111] In one embodiment, the resource types in the first queue, the second queue, and other queues are the same, and the resource types include GPU type and CPU type. The tasks in resource scheduling include first type tasks and second type tasks. The resources required for the first type tasks include GPU resources and CPU resources, and the resources required for the second type tasks include CPU resources. For example, when collecting the training set required for the autonomous driving model, it is necessary to parse the original collected data, clean the data, convert the format, and other operations. This part of the data processing process can only use the CPU for calculation, but when the autonomous driving model needs to be trained, it is necessary to call the GPU and CPU for processing at the same time.
[0112] In this case, when there is idle CPU resource allocated to the first type of task, the second type of task is processed by using the idle CPU resource allocated to the first type of task.
[0113] In order to avoid affecting the processing efficiency of the first type of tasks, multiple second type tasks can be distributed to the idle resources in the CPU resources allocated to the first type of tasks for processing to achieve load balancing. Among them, the computer device to which the CPU resources allocated to the first type of tasks belong includes at least one, and each computer device includes at least one CPU. For example, each second type task requires a CPU for processing, then according to the number of second type tasks, multiple second type tasks can be evenly distributed to multiple computer devices so that the resource occupancy rate of each computer device is the same or substantially the same.
[0114] It can be seen from the above scheme that in the embodiment of the present application, when there is idle CPU resources pre-allocated to the first type of task that needs to call GPU resources and CPU resources at the same time, the idle resources can be temporarily allocated to the second type of task for use, thereby realizing resource mixing and improving resource utilization.
[0115] In one embodiment, when no first type task is received and the CPU resources allocated to the first type task are evenly distributed to multiple second type tasks for use, if a first type task is received, the second type task occupying the CPU resources is migrated from one computer device to another computer device based on the number of CPUs required for the first type task, so that the idle CPU resources in a computer device are sufficient to process the first type task.
[0116] Among them, the computer device to which the CPU resources allocated for the first type of tasks belong includes at least one, and each computer device includes at least one CPU. Evenly distributing the CPU resources allocated for the first type of tasks to multiple second type of tasks includes: when the computer devices to which the CPU resources allocated for the first type of tasks belong include multiple, the multiple second type of tasks can be evenly distributed on the multiple computing devices, so that the number of second type tasks that each computer device needs to process is the same or substantially the same. When migrating the second type of tasks that occupy the CPU resources, it is also possible to try to ensure that after the migration is completed, the number of second type tasks allocated to the multiple computer devices that process the second type of tasks is the same or substantially the same.
[0117] like Figure 5As shown, the computer devices to which the CPU resources allocated for the first type of tasks belong include 3, and each computer device includes 6 CPUs. When the first type of tasks are not received, there are multiple second type of tasks waiting. In order to improve resource utilization, the CPU resources allocated for the first type of tasks can be temporarily used by multiple second type of tasks. For example, each second type of task requires the use of a CPU, and there are 11 second type of tasks waiting to be processed. The 11 second type of tasks can be evenly distributed on multiple computing devices, so that the second type of tasks that each computer device needs to process are basically the same. Specifically, as shown in the left part of the figure, each small rectangle represents a CPU, white represents idle, and other different colors represent different tasks. When the first type of task is received, if it is determined that the first type of task requires 1 computer, the second type of tasks occupying CPU resources in the computer device with more idle resources can be moved forward to other computer devices. In the figure, the three second type of tasks occupying CPU resources in the third computer device are moved forward to the second computer device and the first computer device respectively, so that the third computer device is idle as a whole and can be used by the first type of tasks.
[0118] It can be seen from the above scheme that in the embodiment of the present application, when no first type of task is received and the CPU resources allocated to the first type of task are evenly distributed to multiple second type of tasks for use, if the first type of task is received again, the idle computer equipment can be freed up for the first type of task by migrating the second type of task, thereby ensuring that both types of tasks are processed in a timely manner.
[0119] Corresponding to the above method embodiment, another embodiment of the present application provides a resource scheduling device, such as Figure 6 As shown, the device comprises:
[0120] An acquisition unit 410 is used to acquire the current to-be-processed task in the first queue;
[0121] A first processing unit 420 is configured to process the current task to be processed by using the idle resources in the first queue when there are idle resources in the first queue and the number of the idle resources can satisfy the current task to be processed;
[0122] The occupying unit 430 is used to, when the idle resources exist in the first queue and the number of the idle resources cannot satisfy the current task to be processed, or when the idle resources do not exist in the first queue, use the current task to be processed as a preempting task to occupy the idle resources in the second queue, wherein the preempting task is a task in its own queue that occupies resources in other queues, and the second queue is another queue with sufficient idle resources to process the current task to be processed;
[0123] The first processing unit 420 is further configured to process the current task to be processed by utilizing the occupied idle resources.
[0124] In a possible implementation manner, the device further includes:
[0125] A judging unit, configured to judge whether there is the preempting task in the first queue before taking the current task to be processed as the preempting task to occupy the idle resources in the second queue;
[0126] The occupying unit 430 is configured to occupy the idle resources in the second queue by using the current task to be processed as the preempting task when there is no preempting task in the first queue.
[0127] In a possible implementation manner, the device further includes:
[0128] a releasing unit, configured to release the occupation of resources by the preempting task in the first queue according to the number of resources required by the current task to be processed, when the preempting task exists in the first queue;
[0129] The first processing unit 420 is further configured to process the current task to be processed using the released resources.
[0130] In a possible implementation manner, the device further includes:
[0131] A determination unit is used to determine the second queue from other queues except the first queue before using the current task to be processed as a preempted task to occupy the idle resources in the second queue, according to the resource occupancy rates of other queues except the first queue and / or the processing status of historical tasks corresponding to the current task to be processed, wherein the processing status includes processing time and / or resource occupancy status.
[0132] In a possible implementation manner, the device further includes:
[0133] The second processing unit is configured to directly wait for sufficient idle resources in the first queue when the second queue does not exist in the other queues; or
[0134] In the case that the second queue does not exist in the other queues, determine whether the preempting task exists in the first queue; in the case that the preempting task exists in the first queue, release the occupation of resources by the preempting task in the first queue according to the number of resources required for the current task to be processed, and use the released resources to process the current task to be processed; in the case that the preempting task does not exist in the first queue, wait for sufficient free resources in the first queue.
[0135] In a possible implementation, the resource types in the first queue, the second queue, and the other queues are the same, the resource types include a graphics processor GPU type and a central processing unit CPU type, the tasks in the resource scheduling include a first type of tasks and a second type of tasks, the resources required for the first type of tasks include GPU resources and CPU resources, and the resources required for the second type of tasks include CPU resources, and the device further includes:
[0136] The third processing unit is configured to process the second type of task by utilizing idle resources in the CPU resources allocated to the first type of task when idle resources are available in the CPU resources allocated to the first type of task.
[0137] In a possible implementation manner, the device further includes:
[0138] A migration unit is used for, in the process of not receiving the first type of task and uniformly distributing the CPU resources allocated to the first type of task to multiple second type of tasks for use, if the first type of task is received, migrating the second type of task occupying the CPU resources from one computer device to another computer device according to the number of CPUs required by the first type of task, so that the idle CPU resources in a certain computer device are sufficient to process the first type of task, wherein the computer devices to which the CPU resources allocated to the first type of task belong include at least one, and each of the computer devices includes at least one CPU.
[0139] The resource scheduling device provided in the embodiment of the present application uses the idle resources in the first queue to process the current pending tasks when there are idle resources in the first queue and the number of idle resources can meet the current pending tasks. When there are idle resources in the first queue and the number of idle resources cannot meet the current pending tasks, or when there are no idle resources in the first queue, instead of waiting for the idle resources in the first queue, the current pending tasks are used as preempted tasks to occupy the idle resources in the second queue, and the occupied idle resources are used to process the current pending tasks. In this way, the current pending tasks in the first queue can be processed in time without affecting the task processing progress in the second queue, thereby avoiding task accumulation and improving the overall resource utilization of all queues.
[0140] Based on the above method embodiments, another embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described in any of the above embodiments is implemented.
[0141] Based on the above method embodiment, another embodiment of the present application provides an electronic device or a computer device, such as Figure 7 As shown, including:
[0142] one or more processors 510;
[0143] The processor 510 is coupled to a storage device 520, and the storage device 520 is used to store one or more programs;
[0144] When the one or more programs are executed by the one or more processors 510, the electronic device or computer device implements the method described in any of the above embodiments.
[0145] Based on the above embodiments, another embodiment of the present application provides a computer program product, which includes instructions. When the instructions are executed on a computer or a processor, the computer or the processor executes the method described in any of the above embodiments.
[0146] The above device embodiment corresponds to the method embodiment and has the same technical effect as the method embodiment. For specific description, please refer to the method embodiment. The device embodiment is obtained based on the method embodiment. For specific description, please refer to the method embodiment part, which will not be repeated here. It can be understood by those skilled in the art that the accompanying drawings are only schematic diagrams of one embodiment, and the modules or processes in the accompanying drawings are not necessarily required to implement the present application.
[0147] Those skilled in the art can understand that the modules in the device in the embodiment can be distributed in the device in the embodiment according to the description of the embodiment, or can be changed accordingly and located in one or more devices different from the embodiment. The modules in the above embodiment can be combined into one module, or can be further divided into multiple sub-modules.
[0148] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A resource scheduling method, characterized in that: The method comprises: Get the current pending tasks in the first queue; In a case where there are idle resources in the first queue and the number of the idle resources can satisfy the current task to be processed, using the idle resources in the first queue to process the current task to be processed; In the case where the idle resources exist in the first queue and the quantity of the idle resources cannot satisfy the current task to be processed, or in the case where the idle resources do not exist in the first queue, the current task to be processed is used as a preempted task to occupy the idle resources in the second queue, and the occupied idle resources are used to process the current task to be processed, wherein the preempted task is a task in its own queue that occupies resources in other queues, and the second queue is other queues with sufficient idle resources to process the current task to be processed.
2. The method according to claim 1, characterized in that Before taking the current to-be-processed task as a preempted task to occupy the idle resources in the second queue, the method further includes: Determine whether the preempted task exists in the first queue; The step of using the current task to be processed as a preempted task to occupy the idle resources in the second queue includes: In the case that the preempted task does not exist in the first queue, the current task to be processed is used as the preempted task to occupy the idle resources in the second queue.
3. The method according to claim 2, characterized in that The method further comprises: In the case that the preempted task exists in the first queue, the occupation of resources by the preempted task in the first queue is released according to the amount of resources required by the current task to be processed, and the released resources are used to process the current task to be processed.
4. The method according to claim 1, characterized in that: Before taking the current to-be-processed task as a preempted task to occupy the idle resources in the second queue, the method further includes: The second queue is determined from queues other than the first queue based on the resource occupancy rates of queues other than the first queue and / or the processing status of historical tasks corresponding to the currently processed task, wherein the processing status includes processing time and / or resource occupancy status.
5. The method according to claim 1, characterized in that The method further comprises: When the second queue does not exist in the other queues, directly wait in the first queue for sufficient idle resources; or, In the case that the second queue does not exist in the other queues, determine whether the preempting task exists in the first queue; in the case that the preempting task exists in the first queue, release the occupation of resources by the preempting task in the first queue according to the number of resources required for the current task to be processed, and use the released resources to process the current task to be processed; in the case that the preempting task does not exist in the first queue, wait for sufficient free resources in the first queue.
6. The method according to any one of claims 1 to 5, characterized in that The resource types in the first queue, the second queue and the other queues are the same, the resource types include a graphics processor GPU type and a central processing unit CPU type, the tasks in the resource scheduling include a first type of task and a second type of task, the resources required for the first type of task include GPU resources and CPU resources, and the resources required for the second type of task include CPU resources, and the method further includes: When there are idle CPU resources allocated to the first type of tasks, the second type of tasks are processed using idle CPU resources allocated to the first type of tasks.
7. The method according to claim 6, characterized in that The method further comprises: In the process of not receiving the first type of task and evenly distributing the CPU resources allocated to the first type of task to multiple second type of tasks for use, if the first type of task is received, then according to the number of CPUs required for the first type of task, the second type of task occupying the CPU resources is migrated from one computer device to another computer device, so that the idle CPU resources in a certain computer device are sufficient to process the first type of task, wherein the computer devices to which the CPU resources allocated to the first type of task belong include at least one, and each of the computer devices includes at least one CPU.
8. A resource scheduling device, characterized in that: The device comprises: An acquisition unit, used for acquiring the current pending tasks in the first queue; A first processing unit, configured to process the current task to be processed by using the idle resources in the first queue when there are idle resources in the first queue and the number of the idle resources can satisfy the current task to be processed; An occupying unit, configured to, when the idle resources exist in the first queue and the number of the idle resources cannot satisfy the current task to be processed, or when the idle resources do not exist in the first queue, use the current task to be processed as a preempting task to occupy the idle resources in the second queue, wherein the preempting task is a task in its own queue that occupies resources in other queues, and the second queue is another queue with sufficient idle resources to process the current task to be processed; The first processing unit is further configured to utilize the occupied idle resources to process the current task to be processed.
9. The device according to claim 8, characterized in that The device also includes: A judging unit, configured to judge whether there is the preempting task in the first queue before taking the current task to be processed as the preempting task to occupy the idle resources in the second queue; The occupying unit is used to occupy the idle resources in the second queue by using the current task to be processed as the preempting task when the preempting task does not exist in the first queue.
10. The device according to claim 9, characterized in that The device also includes: a releasing unit, configured to release the occupation of resources by the preempting task in the first queue according to the number of resources required by the current task to be processed, when the preempting task exists in the first queue; The first processing unit is further configured to process the current task to be processed using the released resources.
11. The device according to claim 8, characterized in that The device also includes: A determination unit is used to determine the second queue from other queues except the first queue before using the current task to be processed as a preempted task to occupy the idle resources in the second queue, according to the resource occupancy rates of other queues except the first queue and / or the processing status of historical tasks corresponding to the current task to be processed, wherein the processing status includes processing time and / or resource occupancy status.
12. The device according to claim 8, characterized in that The device also includes: The second processing unit is configured to directly wait for sufficient idle resources in the first queue when the second queue does not exist in the other queues; or In the case that the second queue does not exist in the other queues, determine whether the preempting task exists in the first queue; in the case that the preempting task exists in the first queue, release the occupation of resources by the preempting task in the first queue according to the number of resources required for the current task to be processed, and use the released resources to process the current task to be processed; in the case that the preempting task does not exist in the first queue, wait for sufficient free resources in the first queue.
13. The device according to any one of claims 8 to 12, characterized in that The resource types in the first queue, the second queue and the other queues are the same, the resource types include a graphics processor GPU type and a central processing unit CPU type, the tasks in the resource scheduling include a first type of tasks and a second type of tasks, the resources required for the first type of tasks include GPU resources and CPU resources, and the resources required for the second type of tasks include CPU resources, and the device further includes: The third processing unit is configured to process the second type of task by utilizing idle resources in the CPU resources allocated to the first type of task when idle resources are available in the CPU resources allocated to the first type of task.
14. The device according to claim 13, characterized in that The device also includes: A migration unit is used for, in the process of not receiving the first type of task and uniformly distributing the CPU resources allocated to the first type of task to multiple second type of tasks for use, if the first type of task is received, migrating the second type of task occupying the CPU resources from one computer device to another computer device according to the number of CPUs required by the first type of task, so that the idle CPU resources in a certain computer device are sufficient to process the first type of task, wherein the computer devices to which the CPU resources allocated to the first type of task belong include at least one, and each of the computer devices includes at least one CPU.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
16. An electronic device, characterized in that: The electronic device comprises: one or more processors; The processor is coupled to a storage device, and the storage device is used to store one or more programs; When the one or more programs are executed by the one or more processors, the electronic device implements the method according to any one of claims 1 to 7.