Task processing method and device

By selecting the vCPU with the highest resource usage to execute tasks in hardware virtualization scenarios, the problem of CPU computing resource loss caused by frequent idle vCPUs is solved, and lower physical CPU scheduling loss is achieved.

CN115168028BActive Publication Date: 2025-10-14ALIBABA (CHINA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210682601.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-16
Publication Date
2025-10-14
Estimated Expiration
2042-06-16

AI Technical Summary

Technical Problem

In hardware virtualization scenarios, idle vCPUs are frequently dumped to the host machine, resulting in high CPU computing resource consumption that is difficult to optimize.

Method used

By determining at least two vCPUs of the target virtual object in the task allocation request and selecting the vCPU with the highest current resource occupancy information as the target vCPU for task execution, frequent trapping of idle vCPUs is avoided and physical CPU scheduling loss is reduced.

Benefits of technology

This effectively reduces the CPU scheduling loss caused by the frequent outflow of idle vCPUs to the host machine, and further reduces the scheduling loss of the physical CPU.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115168028B_ABST
    Figure CN115168028B_ABST
Patent Text Reader

Abstract

Embodiments of the present specification provide a task processing method and device, wherein the task processing method comprises: receiving a task allocation request for a target virtual object, wherein the task allocation request carries a to-be-allocated task; determining at least two vCPUs corresponding to the target virtual object based on the task allocation request, and determining an initial vCPU from the at least two vCPUs, wherein the current resource occupation information of the initial vCPU is greater than that of other vCPUs; in the case where the current resource occupation information of the initial vCPU meets the task processing condition of the to-be-allocated task, determining the initial vCPU as a target vCPU; and allocating the to-be-allocated task to the target vCPU for task execution; thereby avoiding the problem of CPU scheduling loss caused by the frequent trapping of idle vCPUs to the host, and further reducing the physical CPU scheduling loss.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present specification relate to the technical field of computer technology, and particularly relate to a task processing method. BACKGROUND

[0002] With the development of virtualization technology, many Internet companies will use hardware virtualization capabilities to do security isolation. In the hardware virtualization scenario, a CPU overhead that is difficult to eliminate is that each idle vCPU frequently traps into the host and consumes a large amount of CPU computing resources to execute the scheduling process on the host for the vCPU, thereby causing high and difficult-to-optimize physical CPU scheduling loss. Therefore, there is an urgent need to provide a solution to reduce the physical CPU scheduling loss caused by the idle vCPU frequently trapping into the host. SUMMARY

[0003] Therefore, the embodiments of the present specification provide a task processing method. One or more embodiments of the present specification also relate to a task processing apparatus, a computing device, a computer-readable storage medium, and a computer program to solve the technical defects in the prior art.

[0004] According to a first aspect of the embodiments of the present specification, a task processing method is provided, including:

[0005] receiving a task allocation request for a target virtual object, wherein the task allocation request carries a to-be-allocated task;

[0006] determining at least two vCPUs corresponding to the target virtual object based on the task allocation request, and determining an initial vCPU from the at least two vCPUs, wherein the current resource occupation information of the initial vCPU is greater than that of other vCPUs;

[0007] determining the initial vCPU as a target vCPU in a case where the current resource occupation information of the initial vCPU meets a task processing condition of the to-be-allocated task;

[0008] allocating the to-be-allocated task to the target vCPU for task execution.

[0009] According to a second aspect of the embodiments of the present specification, a task processing apparatus is provided, including:

[0010] a receiving module configured to receive a task allocation request for a target virtual object, wherein the task allocation request carries a to-be-allocated task;

[0011] The first determining module is configured to determine at least two vCPUs corresponding to the target virtual object based on the task allocation request, and determine an initial vCPU from the at least two vCPUs, where current resource occupation information of the initial vCPU is greater than that of other vCPUs.

[0012] The second determining module is configured to determine the initial vCPU as a target vCPU in a case where the current resource occupation information of the initial vCPU meets a task processing condition of the task to be allocated.

[0013] The executing module is configured to allocate the task to be allocated to the target vCPU for task execution.

[0014] According to a third aspect of an embodiment of the present specification, a computing device is provided, comprising:

[0015] a memory and a processor;

[0016] The memory is configured to store computer executable instructions, and the processor is configured to execute the computer executable instructions, so as to implement the steps of the task processing method.

[0017] According to a fourth aspect of an embodiment of the present specification, a computer readable storage medium is provided, which stores computer executable instructions, and the computer executable instructions are executed by a processor to implement the steps of the task processing method.

[0018] According to a fifth aspect of an embodiment of the present specification, a computer program is provided, and when the computer program is executed in a computer, the computer program causes the computer to execute the steps of the task processing method.

[0019] The task processing method provided by the present specification comprises: receiving a task allocation request for a target virtual object, where the task allocation request carries a task to be allocated; determining at least two vCPUs corresponding to the target virtual object based on the task allocation request, and determining an initial vCPU from the at least two vCPUs, where current resource occupation information of the initial vCPU is greater than that of other vCPUs; determining the initial vCPU as a target vCPU in a case where the current resource occupation information of the initial vCPU meets a task processing condition of the task to be allocated; and allocating the task to be allocated to the target vCPU for task execution.

[0020] Specifically, the method can determine, from at least two vCPUs corresponding to the target virtual object, an initial vCPU whose current resource occupancy information is greater than that of other vCPUs in the at least two vCPUs; when the current resource occupancy information of the initial vCPU is determined to meet the task processing conditions of the task to be assigned, the initial vCPU is determined as the target vCPU, and the task to be assigned is executed through the target vCPU, thereby avoiding the problem of CPU scheduling loss caused by the frequent trapping of idle vCPUs to the host machine, and further reducing the physical CPU scheduling loss. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 This is a flowchart of a task scheduling provided by an embodiment of this specification;

[0022] Figure 2 This is a flowchart of an exit operation provided by an embodiment of this specification;

[0023] Figure 3 This is a schematic diagram of a task processing method provided by an embodiment of this specification in a specific application scenario;

[0024] Figure 4 This is a process flow chart of a task processing method provided by one embodiment of this specification;

[0025] Figure 5 This is a flowchart of a task processing method provided by one embodiment of this specification;

[0026] Figure 6 This is a structural diagram of a task processing device provided by one embodiment of this specification;

[0027] Figure 7 This is a structural block diagram of a computing device provided by one embodiment of this specification. DETAILED DESCRIPTION

[0028] The following description sets forth many specific details to facilitate a thorough understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.

[0029] The terminology used in this disclosure, one or more embodiments of the specification, is for the purpose of describing particular embodiments only and is not intended to be limiting of one or more embodiments of the specification. As used in this disclosure and the appended claims, the singular forms "a," "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "and / or," as used in this disclosure, refers to and encompasses any and all possible combinations of one or more of the associated listed items.

[0030] It will be understood that, although the terms first, second, etc. can be employed in this disclosure, one or more embodiments of the specification, to describe various information, these information should not be limited to these terms. These terms are only used to differentiate one piece of information from another piece of information. For example, without departing from the scope of one or more embodiments of the specification, first can also be referred to as second, and similarly, second can also be referred to as first. Depending on the context, the word "if' as used herein can be interpreted to mean "when" or "in response to determining" or "in response to ascertaining".

[0031] First, the noun terms related to one or more embodiments of the specification are explained.

[0032] Hardware virtualization: a technology that uses hardware instructions provided by physical CPUs to execute virtual machines.

[0033] vCPU: a CPU that a virtual machine can perceive, under hardware virtualization, a general vCPU implementation is a thread on the host machine, i.e. a vCPU thread.

[0034] Guest: i.e. a virtual machine.

[0035] Host: the host machine where the virtual machine runs.

[0036] Exit; under hardware virtualization, the CPU exits from a state of executing instructions / processes within a virtual machine (referred to as non-root mode) to a state of executing instructions / processes of the host (root mode).

[0037] Enter: opposite to exit, it is to enter non-root mode from root mode.

[0038] HLT: i.e. halt, when the CPU has nothing to do (no thread is waiting for scheduling), the HLT instruction of the CPU is executed, indicating that the CPU is idle. Under hardware virtualization, the vCPU within the guest executes the HLT instruction, which leads to exit to the host.

[0039] idle: in scheduling, idle indicates that there is no thread waiting to run on the CPU that can be scheduled, thus entering the idle state, i.e. the idle state, in which case Linux generally executes the HLT instruction.

[0040] Scheduling domain: due to the different memory access rates caused by the cache shared by CPUs at different levels and NUMA, the scheduler can be divided into different levels such as the same CPU core, the same CPU package, the same NUMA, all CPUs, and the CPUs in each level are called a scheduling domain, for example, the scheduler usually avoids scheduling threads to other NUMA different from the previous NUMA as much as possible.

[0041] NUMA (Non Uniform Memory Access): non-uniform memory access.

[0042] CPU core: the core of a CPU processor.

[0043] CPU package: refers to a whole piece of CPU in the physical world, and there can be multiple CPU cores in a CPU package.

[0044] With the development of virtualization technology, many virtual machines, cloud servers (ECS) or secure containers use hardware virtualization capabilities for security isolation, and under hardware virtualization, a difficult-to-eliminate CPU overhead source is that each vCPU thread will re-execute the scheduling process on the host after being trapped out to the host. The scheduling process is as follows: if there is no other task waiting to be scheduled on the vCPU, the scheduler determines that the vCPU is in an idle state, and there is no other host thread waiting to run on the host CPU where the vCPU is located, and then an idle balance process is performed. If there are other tasks waiting to run on the corresponding host CPU, although idle balance will not be performed, the vCPU runtime update will also be processed during the scheduling process, which is also time-consuming. The idle balance process attempts to pull the processes waiting to run from other vCPUs, which will occupy the running resources of the vCPU and further consume the computing resources of the physical CPU running the vCPU thread, and based on this, it will also bring higher and difficult-to-optimize virtualization CPU loss (i.e. scheduling loss).

[0045] For example, in the scenario of performing tcp ping-pong in a secure container or a virtual machine, the above-mentioned problem of causing CPU consumption is more obvious, because the vCPU corresponding to the secure container or the virtual machine needs to perform the operation of sending and receiving packets every few hundred microseconds or a few milliseconds, and a small amount of code is executed and falls out each time; and in each falling process, the vCPU has already executed the scheduling process in the virtual machine, and additionally executes the scheduling process on the host, so that the scheduling overhead of the vCPU becomes twice that of the physical machine.

[0046] One of the reasons for the above-mentioned problem is that the scheduler of the secure container or the virtual machine usually selects the most idle CPU in a certain scheduling domain when selecting a vCPU to execute a task, so as to achieve balanced scheduling. For related processes, please refer to Figure 1 , Figure 1 is a flowchart of task scheduling provided by one embodiment of the present specification, and specifically includes the following steps:

[0047] Step 102: There is a new thread that can run.

[0048] Step 104: Find a most idle vCPU in a certain scheduling domain.

[0049] Step 106: Schedule the thread to run on the most idle vCPU.

[0050] Based on the above steps, by taking the scheduler as an example to ensure load balancing, the new thread is allocated to the most idle vCPU, so that each vCPU has a task (i.e. thread) to execute; however, this also causes each vCPU to perform a small amount of time and then perform a trap operation, thereby causing more HLT trap processing overhead and scheduling overhead.

[0051] Specifically, the process of the vCPU performing the trap operation is shown in Figure 2 , Figure 2 is a flowchart of a trap operation provided by one embodiment of the present specification, and specifically includes the following steps:

[0052] Step 202: Idle state.

[0053] Specifically, the scheduler of the host determines the vCPU in the idle state from the plurality of vCPUs corresponding to the virtual machine.

[0054] Step 204: Enter the virtual machine.

[0055] Specifically, the scheduler of the host schedules the idle vCPU to the corresponding virtual machine, so that the virtual machine can perceive the vCPU.

[0056] Step 206: execute the instruction in the virtual machine.

[0057] Specifically, after the idle vCPU is scheduled to the corresponding virtual machine, when the virtual machine receives a new instruction, the vCPU can execute the instruction, for example, by executing a send / receive packet instruction, etc.

[0058] Step 208: virtual machine kernel scheduling flow.

[0059] Specifically, after the scheduler in the virtual machine kernel receives an instruction for the virtual machine, the scheduler starts the scheduling flow in the virtual machine kernel to schedule the instruction to the vCPU corresponding to the virtual machine for execution.

[0060] Step 210: no callable, HLT trap out.

[0061] Specifically, the scheduler in the virtual machine kernel can determine to perform an HLT trap out operation on the vCPU when it is determined that there is no execution that can be scheduled to the vCPU.

[0062] Step 212: execute HLT trap out processing.

[0063] Specifically, the scheduler in the virtual machine kernel performs HLT trap out processing on the vCPU that has no tasks (e.g., instructions, threads, etc.) to execute, and traps the vCPU to the host.

[0064] Step 214: execute host scheduling flow.

[0065] Specifically, after the vCPU is trapped to the host, the scheduler of the host can release the CPU computing resource corresponding to the vCPU; based on the released CPU computing resource corresponding to the vCPU, the other thread is allocated; wherein the other thread can be a thread that implements other vCPUs on the physical CPU, or a thread that executes the task of the host itself.

[0066] Step 216: no scheduling, enter idle state.

[0067] Specifically, after the scheduler in the virtual machine kernel performs HLT trap out processing on the vCPU that has no tasks to execute, the current state of the vCPU can be adjusted to an idle state.

[0068] It should be noted that in the case where the virtual machine corresponds to multiple vCPUs, each vCPU will execute the steps of steps 202-216 described above, for example, the virtual machine corresponds to vCPU1 and vCPU2, then vCPU1 and vCPU2 will execute the steps of steps 202-216 described above.

[0069] Based on the above steps, in the case of frequent execution of trap-out operation of vCPU, more HLT trap-out processing overhead and scheduling overhead will be caused.

[0070] To solve the above problems, the present specification provides four solutions, wherein:

[0071] The first solution to solve the trap-out overhead is that the guest does not perform the trap-out operation when performing HLT, so that the scheduling process on the host does not need to be performed every time the guest changes from work to idle.

[0072] However, this solution is usually applicable to the case that the physical CPU on the host can be exclusively executed by the vCPU, if multiple vCPUs run on one physical CPU, other vCPUs will interrupt the vCPU in the guest HLT, so that the HLT in the guest is interrupted, and the trap-out operation is still performed, therefore, this solution cannot achieve the expected effect in the case that the vCPU cannot exclusively use the physical CPU.

[0073] The second solution is to optimize the scheduling process of the guest or the host to reduce the CPU overhead required by the scheduling process. However, due to the complexity of the Linux (an operating system) scheduling process, it is proved by practice that this optimization operation is difficult to implement, therefore, there is no better optimization for the Linux scheduling process in the industry.

[0074] The third solution is to make a dedicated scheduler for vCPU. However, this solution does not solve the problem of large trap-out overhead. Because even if the dedicated scheduler is used to schedule the vCPU, the scheduling and selection of other vCPUs to be executed, or the idle scheduling (pulling other vCPUs waiting to be executed on the CPU) process is still inevitable after the vCPU traps out, that is, this solution still has large scheduling overhead.

[0075] The fourth solution is to close the idle balance in the scheduler to reduce the CPU scheduling overhead, but this solution has weak effect of reducing the CPU scheduling overhead because it does not try to accumulate as many running tasks as possible on a few CPUs.

[0076] Based on this, the task processing method provided in the specification, after receiving a task allocation request for a target virtual object and carrying a task to be allocated, first, based on the task allocation request, at least two vCPUs corresponding to the target virtual object are determined, and an initial vCPU is determined from the at least two vCPUs, wherein the current resource occupation information of the initial vCPU is greater than that of other vCPUs in the at least two vCPUs except the initial vCPU.

[0077] Then, in the case where the current resource occupation information of the initial vCPU meets the task processing condition of the task to be allocated, the initial vCPU is determined as the target vCPU, and the task to be allocated is allocated to the target vCPU for task execution; thereby avoiding the problem of CPU scheduling loss caused by frequent trapping of idle vCPUs to the host, and further reducing the physical CPU scheduling loss.

[0078] Specifically, in the specification, a task processing method is provided, and the specification also relates to a task processing device, a computing device, a computer readable storage medium and a computer program, which are described in detail one by one in the following embodiments.

[0079] Figure 3 A flowchart of a task processing method provided according to an embodiment of the specification in a specific application scenario is shown, which specifically includes: a scheduler in a virtual machine kernel, in the case of receiving a new thread A, it is determined that a new thread A needs to be allocated to a vCPU for running execution. Based on this, the scheduler determines a scheduling domain B corresponding to the thread A from a plurality of scheduling domains; then the scheduler finds a busiest vCPU1 in the scheduling domain B, which can be understood as the vCPU with the highest occupancy rate in the scheduling domain B. Wherein, the scheduling domain B includes vCPU1, vCPU2 and vCPU3.

[0080] After that, if it is determined that the vCPU1 is too busy, then a less busy vCPU2 is found in the scheduling domain B; wherein the less busy vCPU2 can be understood as the vCPU with the highest occupancy rate in the scheduling domain B except the vCPU1; that is, the vCPU with the second highest occupancy rate in the scheduling domain B.

[0081] In addition, the vCPU1 being too busy can be understood as the occupancy rate of the vCPU1 reaching more than a preset occupancy rate threshold (for example, 70%), then it is determined that the vCPU1 is too busy; that is, the vCPU1 being too busy can mean that the vCPU1 is in a load state and cannot process new threads.

[0082] Finally, the scheduler in the virtual machine kernel schedules the new thread A to the selected vCPU for running execution.

[0083] Based on the above, in an embodiment provided by the present specification, the scheduling content provided by the task processing method includes the following steps A1 to A4.

[0084] Step A1: there is a new thread that can run.

[0085] Step A2: find a busiest vCPU in a certain scheduling domain.

[0086] Step A3: if the vCPU is too busy, for example, the vCPU utilization rate is above a threshold (70%), then select a less busy vCPU.

[0087] Step A4: schedule the thread to run on the selected vCPU.

[0088] Based on the above scheduling related content for Figure 3 , the scheduling idea of the task processing method provided by the present specification is to concentrate as many threads waiting for execution as possible on a few CPUs to reduce HLT overhead. When a new task (thread) is available, the scheduler of the virtual machine kernel selects the busiest CPU in a scheduling domain. If this CPU is too busy, exceeding a threshold (for example, CPU utilization rate exceeds 70%), then a less busy CPU is selected, and then the executable task is scheduled to execute on the selected CPU. Thus, the threads waiting for execution are concentrated on a few CPUs to reduce HLT overhead, avoiding the problem of CPU scheduling loss caused by frequent trapping of idle vCPU to the host, further reducing physical CPU scheduling loss.

[0089] Based on the above scheduling method, the scheduling strategy provided by the task processing method in the present specification can concentrate as many threads waiting for execution as possible on a few CPUs, and keep other vCPUs in an idle state, thereby reducing CPU scheduling loss.

[0090] When the virtual machine corresponds to multiple vCPUs, the above scheduling strategy is executed on a few CPUs, and other vCPUs execute the same steps as in Figure 2 . For example, the virtual machine corresponds to vCPU1 and vCPU2, then the above scheduling strategy is executed on vCPU1, so that vCPU1 selects more tasks and executes in guest, and thus vCPU1 is relatively busy and less idle. Therefore, it leads to less HLT trapping of vCPU1 and scheduling process on the host. Specifically, under the scheduling strategy provided by the task processing method provided by the present specification, the HLT trapping and scheduling process of vCPU1 are as shown in Figure 4 . Figure 4is a process flow diagram of a task processing method provided by an embodiment of the present specification, and specifically includes the following steps.

[0091] Specifically, the flow of the vCPU performing the trap operation is described as follows:

[0092] Step 402: idle state.

[0093] Specifically, the scheduler of the host machine determines the vCPU in the idle state from the plurality of vCPUs corresponding to the virtual machine.

[0094] Step 404: enter the virtual machine.

[0095] Specifically, the scheduler of the host machine schedules the idle vCPU into the corresponding virtual machine, so that the virtual machine can perceive the vCPU.

[0096] Step 406: execute the thread in the virtual machine.

[0097] Specifically, after scheduling the idle vCPU into the corresponding virtual machine, when the virtual machine receives a new thread, the vCPU can execute the thread, such as a thread for receiving and transmitting packets, etc.

[0098] Step 408: virtual machine kernel scheduling flow.

[0099] Specifically, after receiving the thread for the virtual machine, the scheduler in the virtual machine kernel starts the scheduling flow in the virtual machine kernel, and schedules the thread to the vCPU corresponding to the virtual machine for execution.

[0100] The scheduling flow can be: when a new task (thread) is executable, the scheduler of the virtual machine kernel selects the most busy CPU in a scheduling domain. If this CPU is too busy, exceeding a threshold (for example, CPU occupancy rate exceeds 70%), a less busy CPU is selected, and then the executable task is scheduled to the selected CPU for execution.

[0101] Step 410: thread yields CPU and calls other waiting threads for execution.

[0102] Specifically, through the above scheduling flow, the waiting threads for execution can be concentrated on a few CPUs as much as possible, so that the vCPU corresponds to a plurality of waiting threads for execution.

[0103] When the vCPU executes a thread, the thread yields the vCPU; and the vCPU calls other waiting threads for execution.

[0104] Step 412: execute other waiting threads.

[0105] Specifically, after the vCPU calls other threads waiting to be executed, it executes the called threads and other threads waiting to be executed.

[0106] Moreover, while the vCPU is executing other waiting threads, the scheduler in the virtual machine kernel will continue to execute the scheduling process in the virtual machine kernel after receiving the thread for the virtual machine, and schedule the thread to the vCPU corresponding to the virtual machine for execution.

[0107] Step 414: There is nothing to schedule, and the system enters the idle state.

[0108] Specifically, the scheduler in the virtual machine kernel can determine to perform an HLT trap operation on the vCPU when determining that no execution can be scheduled to the vCPU.

[0109] Step 416: Execute HTL trap processing.

[0110] Specifically, the scheduler in the virtual machine kernel performs HLT trapping processing on the vCPU that has no tasks (eg, threads, etc.) to be executed, and traps the vCPU to the host machine.

[0111] Subsequently, after the vCPU is trapped in the host machine, the host machine's scheduler can release the CPU computing resources corresponding to the vCPU; allocate the other threads based on the released CPU computing resources corresponding to the vCPU; wherein, the other threads can be threads that implement other vCPUs on the physical CPU, or threads that execute the host machine's own tasks.

[0112] Also, see Figure 4 It can be seen that the task processing method provided in this specification allows vCPU1 to execute the above steps 402 to 416, so that vCPU1 selects and executes more tasks in the guest; at the same time, it also allows vCPU2 to execute the same tasks. Figure 2 The same steps in

[15] mean that when vCPU2 has fewer tasks to execute, it will not periodically enter and exit the guest, but will spend more time on the host. This reduces the HLT exit of idle vCPU2 and the resulting scheduling overhead on the host. This further reduces the CPU overhead (part of the virtualization overhead) of each virtual machine.

[0113] Based on the above steps, we can see that the task processing method provided in this manual is different from the general scheduling strategy in that:

[0114] The main purpose of the general scheduling strategy is to make the load of each CPU as balanced as possible, and the benefit is that the overall performance of the application is higher, but in the virtualization case, each vCPU will frequently switch between work and idle, resulting in frequent HLT traps, which in turn causes the scheduling process of each vCPU on the host to be as high as several thousand times per second and the CPU overhead it brings.

[0115] Based on this, the task processing method provided by the present specification changes the strategy of the traditional scheduler to try to balance the tasks of each CPU / vCPU, and by accumulating tasks within a certain threshold on individual or a small number of CPUs, the effect of reducing HLT traps under virtualization and the resulting scheduling overhead (CPU overhead) on the host is achieved, which is suitable for scenarios with high-frequency traps and each execution is very short, such as network ping-pong type packet reception and transmission, or function computing (function compute) scenarios.

[0116] At the same time, for the fourth scheme described above, the task processing method provided by the present specification does not close the HLT trap of the vCPU, so there is no restriction that the vCPU needs to exclusively occupy the CPU to be effective. Since the idle balance processing flow of the scheduler is not modified, there is no need to optimize the idle balance overhead. Since a special scheduler for vCPU is not implemented, there is no need to implement a new scheduling strategy for vCPU. Since the above-mentioned scheme cannot accumulate running tasks on a small number of CPUs, the effect of reducing CPU scheduling overhead is not as good as the task processing method provided by the present specification.

[0117] Based on this, the task processing method provided by the present specification makes small changes to the existing scheduling strategy in terms of CPU selection strategy, achieves the effect of reducing CPU scheduling overhead under virtualization, and is particularly effective in some high-frequency wake-up scenarios, such as TCP ping-pong packet reception and transmission scenarios, and has no obvious impact on performance in these scenarios.

[0118] Figure 5 A flowchart of a task processing method according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0119] Step 502: receiving a task allocation request for a target virtual object, wherein the task allocation request carries a task to be allocated.

[0120] In practical applications, the task processing method provided in the specification can be applied to a scheduling module in a target virtual object. The scheduling module can be understood as a module deployed in the target virtual object for allocating a vCPU for a to-be-assigned task. For example, the scheduling module can be a scheduler.

[0121] The virtual unit can be understood as a virtual machine unit generated by a hardware virtualization technology for executing a to-be-assigned task. For example, the virtual unit can be a virtual machine, a secure container, a cloud server, etc., which are not limited in the specification. In the embodiments provided in the specification, the task processing method is described by taking the target virtual object as a virtual machine.

[0122] The task allocation request can be understood as a request for instructing the scheduler to allocate a vCPU for a to-be-assigned task for task execution.

[0123] The to-be-assigned task can be understood as a task that needs to be executed by a vCPU. For example, the to-be-assigned task includes but is not limited to a to-be-executed instruction and a to-be-executed thread. The to-be-executed instruction and the to-be-executed thread can be set according to actual application scenarios, which are not limited in the specification. For example, the to-be-executed thread includes but is not limited to a thread for implementing a ping-pong packet transmission operation. The to-be-executed instruction can be an instruction needed in the process of implementing the ping-pong packet transmission operation.

[0124] Specifically, the scheduler in the target virtual object can receive a task allocation request for the target virtual object. The task allocation request for the target virtual object can be understood as a task allocation request that needs to be executed by the target virtual object.

[0125] The task processing method is described below by taking the application of the task processing method in the specification in the scenario of assigning a packet transmission thread to a vCPU. In this scenario, the target virtual object is a target virtual machine, the to-be-assigned task is a packet transmission thread, the task allocation request is a request for assigning a vCPU corresponding to a packet transmission thread assignment operation, and the packet transmission thread can be a thread for implementing a ping-pong packet transmission operation.

[0126] Based on this, the scheduler of the target virtual machine can receive a task allocation request for assigning a packet transmission thread to a vCPU for execution. The task allocation request carries the packet transmission thread.

[0127] Step 504: Based on the task allocation request, at least two vCPUs corresponding to the target virtual object are determined, and an initial vCPU is determined from the at least two vCPUs, where the current resource occupation information of the initial vCPU is greater than that of other vCPUs.

[0128] The current resource occupation information can be understood as information representing the current occupation of the computing resource of the vCPU. For example, the current resource occupation information can be the occupation rate of the vCPU. The initial vCPU can be understood as a vCPU with the highest resource occupation rate among the at least two vCPUs. The other vCPU can be understood as a vCPU other than the initial vCPU among the at least two vCPUs.

[0129] Specifically, after receiving the task allocation request, the scheduler can determine, based on the task allocation request, the at least two vCPUs corresponding to the target virtual object. Then, the scheduler determines, from the at least two vCPUs, an initial vCPU with a current resource occupation information greater than that of the other vCPUs.

[0130] In the above example, after receiving the request of allocating the transceiving packet thread to the vCPU for running and executing, the scheduler can determine, based on the request, the at least two vCPUs corresponding to the virtual machine, such as vCPU1, vCPU2, and vCPU3.

[0131] Then, the scheduler determines the occupation rate of each vCPU and determines, from the vCPU1, vCPU2, and vCPU3, a vCPU with the highest occupation rate. For example, the occupation rate of vCPU1 is 65%, the occupation rate of vCPU2 is 50%, and the occupation rate of vCPU3 is 0%. The scheduler selects vCPU1 with the highest occupation rate from the vCPU1, vCPU2, and vCPU3.

[0132] In the embodiments provided in the present specification, the scheduler can determine the initial vCPU from the at least two vCPUs in a sorted manner, so that the vCPU with the highest current resource occupation information can be used to process the to-be-allocated task subsequently, thereby avoiding the problem of CPU scheduling loss caused by the frequent trapping of the idle vCPU to the host, and further reducing the physical CPU scheduling loss. Specifically, the determination of the initial vCPU from the at least two vCPUs includes:

[0133] determining the current resource occupation information of each vCPU;

[0134] performing descending order sorting on each vCPU based on the current resource occupation information to obtain a descending order sorting result of each vCPU;

[0135] determining, as the initial vCPU, a vCPU at a first position in the descending order sorting result.

[0136] Continuing with the above example, the scheduler determines the occupancy of each vCPU, such as the occupancy of vCPU1 being 75%, the occupancy of vCPU2 being 50%, and the occupancy of vCPU3 being 0%; and sorts vCPU1, vCPU2, and vCPU3 in descending order based on the occupancy, to obtain a descending order result corresponding to the vCPUs, such as vCPU1→vCPU2→vCPU3.

[0137] Then, the scheduler selects vCPU1 arranged at the first position from the descending order result, as the vCPU with the highest occupancy.

[0138] In an embodiment provided in the specification, in order to save scheduling overhead, the task processing method provided in the specification selects one of the most busy vCPUs from all vCPUs, and subsequently executes tasks based on the selected vCPUs. Meanwhile, due to the different memory access rates caused by the Cache shared by vCPUs at different levels and NUMA, the scheduler can be divided into different levels such as the same CPU core, the same CPU package, the same NUMA, and all CPUs, and the CPUs in each level are called a scheduling domain. Based on this, the task processing method provided in the specification can also consider the running performance of the task, and select the most busy CPU from the CPUs in the same NUMA through a scheduling domain selection strategy; and try to avoid scheduling threads to other NUMAs different from the NUMA where the threads were previously located, but schedule the threads to the NUMA where the threads were previously located, so as to ensure the execution efficiency of the threads. The scheduling domain selection strategy can be any strategy that can select the most busy CPU from a group of CPUs, and the selection of specific CPUs, that is, the scheduling domain selection strategy does not affect the present solution, and the specification does not make specific limitations thereon. One of the scheduling domain selection strategies provided in the embodiment is as follows.

[0139] The determining of the initial vCPU from the at least two vCPUs includes:

[0140] Determining a vCPU set corresponding to each vCPU, wherein the vCPU set contains vCPUs of the same type;

[0141] Based on historical task execution information, determining a target vCPU set corresponding to the task type of the to-be-assigned task;

[0142] Determining an initial vCPU from the target vCPU set, wherein the current resource occupancy information of the initial vCPU is greater than that of other vCPUs in the target vCPU set.

[0143] The vCPU set can be understood as a scheduling domain, and the vCPUs of the same type can be understood as vCPUs sharing the same cache and NUMA.

[0144] The historical task execution information can be understood as data generated by the at least two vCPUs in the process of executing the historical tasks. The historical task execution information includes a task type corresponding to a historical execution task of each vCPU.

[0145] The task type can be understood as information representing the type of a to-be-assigned task. For example, in the case of a to-be-assigned task being a packet sending and receiving thread, the task type can be a packet sending and receiving type.

[0146] Specifically, the scheduler determines a vCPU set corresponding to each vCPU, and determines historical task execution information generated by each vCPU in the process of executing historical tasks; based on the historical task execution information, determines a target vCPU set corresponding to a task type of a to-be-assigned task; and determines an initial vCPU from the target vCPU set, where a current resource occupation information of the initial vCPU is greater than that of other vCPUs in the target vCPU set. It should be noted that the explanation of determining the initial vCPU in the embodiments of the present specification can be referred to the corresponding or corresponding contents in the above embodiments, and the present embodiment will not be described in detail here.

[0147] In the above example, the scheduler determines a scheduling domain to which each vCPU belongs, and determines historical execution records generated in the process of historical execution threads of each vCPU; based on the historical execution records, determines a vCPU that has executed a packet sending and receiving thread and a scheduling domain A to which the vCPU belongs; and selects a vCPU with the highest occupation rate from the scheduling domain A, that is, selects the busiest vCPU from the scheduling domain A.

[0148] Step 506: In a case where the current resource occupation information of the initial vCPU meets a task processing condition of the to-be-assigned task, determining the initial vCPU as a target vCPU.

[0149] The target vCPU can be understood as a vCPU to which the to-be-assigned task is assigned and which can perform task processing on the to-be-assigned task.

[0150] The task processing condition of the to-be-assigned task can be set according to actual application scenarios, and the present specification does not make specific limitations thereon. For example, the task processing condition of the to-be-assigned task can be that the initial vCPU needs to be an unloaded vCPU, the occupation rate of the initial vCPU needs to be less than a preset threshold (for example, 70%), and the like.

[0151] Specifically, in an embodiment provided in the specification, the initial vCPU is determined as the target vCPU in a case where the current resource occupation information of the initial vCPU meets the task processing condition of the to-be-allocated task.

[0152] The initial vCPU is determined as the target vCPU in a case where the current resource occupation information of the initial vCPU meets a preset load condition.

[0153] The preset load condition can be understood as that the occupation rate of the initial vCPU is less than a preset occupation rate threshold.

[0154] In the above example, after determining the vCPU with the highest occupation rate from the plurality of vCPUs of the virtual machine, the scheduler determines whether the vCPU with the highest occupation rate is in a load condition in order to ensure smooth execution of the packet sending and receiving thread. Specifically, the scheduler determines whether the occupation rate of the vCPU with the highest occupation rate is less than a preset occupation rate threshold (70%) after determining the vCPU with the highest occupation rate. If yes, it is determined that the vCPU is not loaded and can smoothly execute the packet sending and receiving thread. Based on this, the vCPU with the highest occupation rate is determined as the vCPU for executing the packet sending and receiving thread. The preset occupation rate threshold can be set according to an actual application scenario, which is not limited in the specification.

[0155] Further, in an embodiment provided in the specification, if the occupation rate of the vCPU with the highest occupation rate is greater than or equal to the preset occupation rate threshold, it is determined that the vCPU is in a load state and cannot smoothly execute the packet sending and receiving thread. Then, a new vCPU is determined again, and it is continuously determined whether the occupation rate of the new vCPU is less than the preset occupation rate threshold until a vCPU with an occupation rate less than the preset occupation rate threshold and a relatively high occupation rate is found. In this way, the problem of CPU scheduling loss caused by frequent trapping of an idle vCPU to a host machine can be avoided while ensuring smooth execution of a to-be-processed task, and physical CPU scheduling loss is further reduced. Specifically, after determining the initial vCPU, the method further includes:

[0156] In a case where the current resource occupation information of the initial vCPU does not meet the preset load condition, a candidate vCPU is determined from the other vCPUs, where the current resource occupation information of the candidate vCPU meets the preset load condition.

[0157] A target vCPU is determined from the candidate vCPUs, where the current resource occupation information of the target vCPU is greater than that of the other candidate vCPUs except the target vCPU.

[0158] The candidate vCPU may be understood as a vCPU whose occupancy rate among other vCPUs is less than a preset occupancy rate threshold.

[0159] Continuing with the above example, the scheduler determines that vCPU1 currently has the highest occupancy rate, and that the occupancy rate of vCPU1 (75%) is greater than or equal to the preset occupancy rate threshold (70%). Under load conditions, the scheduler can identify a vCPU from vCPU2 and vCPU3 whose occupancy rate is less than the preset occupancy rate threshold. Since the occupancy rate of vCPU2 is 50% and the occupancy rate of vCPU3 is 0%, the scheduler can select vCPU2 and vCPU3 and determine the vCPU with the highest occupancy rate from vCPU2 and vCPU3, that is, vCPU2. The scheduler then uses vCPU2 as the vCPU to execute the packet sending and receiving thread.

[0160] In the embodiment provided in this specification, to ensure smooth execution of the task to be assigned, the scheduler, after determining from at least two vCPUs that the current resource occupancy information of the initial vCPU is greater than that of the other vCPUs, further needs to determine whether the remaining computing resources of the initial vCPU can successfully run the task to be assigned, thereby ensuring smooth execution of the task to be assigned. Specifically, when determining that the current resource occupancy information of the initial vCPU meets the task processing condition of the task to be assigned, determining the initial vCPU as the target vCPU includes:

[0161] Determining resource occupancy information of the task to be assigned;

[0162] Determine the remaining resource information corresponding to the initial vCPU based on the current resource occupancy information of the initial vCPU;

[0163] When the remaining resource information is greater than or equal to the resource occupancy information, the initial vCPU is determined as the target vCPU.

[0164] The resource occupancy information of the task to be assigned can be understood as the computing resources required by the vCPU to execute the task to be assigned. For example, in the case of a packet receiving thread of the task to be assigned, the resource occupancy information can be understood as the occupancy rate required by the vCPU to execute the packet receiving thread.

[0165] The remaining resource information corresponding to the initial vCPU can be understood as information that represents the computing resources currently remaining in the initial vCPU that can execute the task to be assigned. For example, the remaining resource information can be the remaining resource occupancy rate. When the occupancy rate corresponding to the initial vCPU is 55%, the remaining resource occupancy rate of the initial vCPU can be 45%.

[0166] Specifically, after determining the initial vCPU from the at least two vCPUs, the scheduler can determine the resource occupation information required for processing the to-be-assigned task, and determine the remaining resource information corresponding to the initial vCPU based on the current resource occupation information of the initial vCPU.

[0167] In a case where the remaining resource information is greater than or equal to the resource occupation information, it is determined that the initial vCPU can successfully execute the to-be-assigned task, and therefore the initial vCPU is determined as the target vCPU.

[0168] In the above example, after determining the vCPU with the highest occupation rate, the scheduler can determine that the resource occupation rate required for executing the packet sending and receiving thread is 30%, and determine that the remaining computing resource remaining rate of the vCPU is 50% based on the current occupation rate of the vCPU. In a case where the computing resource remaining rate 35% is greater than or equal to the resource occupation rate 15%, the scheduler determines the vCPU with the highest current occupation rate as the vCPU for processing the packet sending and receiving thread.

[0169] Further, in the embodiments provided in the present specification, in a case where the computing resource remaining rate of a vCPU is less than the resource occupation rate of the to-be-assigned task, in order to ensure the smooth execution of the to-be-assigned task, a vCPU will be reselected, and the comparison between the computing resource remaining rate and the resource occupation rate will be continued until a vCPU with a computing resource remaining rate greater than or equal to the resource occupation rate is found. Specifically, after determining the remaining resource information corresponding to the initial vCPU based on the current resource occupation information of the initial vCPU, the method further comprises:

[0170] In a case where the remaining resource information is less than the resource occupation information, the step of determining the initial vCPU from the at least two vCPUs is continued until the remaining resource information is greater than or equal to the resource occupation information.

[0171] For the explanation of the step of determining the initial vCPU from the at least two vCPUs in the present embodiment, reference can be made to the corresponding or corresponding content in the above embodiments, and the present specification will not make too much repetition.

[0172] In the above example, the remaining rate of the computing resource of the vCPU 1 is 25%, and the resource occupation rate of the transceiving packet thread is 30%. Based on this, the scheduler compares the remaining rate of the computing resource of the vCPU 1 with the resource occupation rate required for executing the transceiving packet thread, and determines that the remaining rate 25% of the computing resource is less than the resource occupation rate 30%. Then, the scheduler determines the vCPU with the highest occupation rate from the vCPU 2 and the vCPU 3, that is, the vCPU 2. Then, the scheduler determines that the remaining rate of the computing resource of the vCPU 2 is 50%, compares the remaining rate 50% of the computing resource with the resource occupation rate 30% required for executing the transceiving packet thread, and determines that the remaining rate 50% of the computing resource is greater than the resource occupation rate 30%. Thus, the vCPU 2 is determined as the vCPU for executing the transceiving packet thread.

[0173] Step 508: allocating the to-be-allocated task to the target vCPU for task execution.

[0174] In the above example, the executable transceiving packet thread is scheduled to the selected vCPU 2 for execution.

[0175] In the embodiments provided in the specification, the allocating the to-be-allocated task to the target vCPU for task execution comprises:

[0176] allocating the to-be-allocated task to a to-be-executed task queue corresponding to the target vCPU, and performing task execution in the to-be-executed task queue.

[0177] The to-be-executed task queue can be understood as a queue for storing to-be-allocated tasks to be executed by the target vCPU.

[0178] In the above example, the vCPU in the virtual machine has a task queue corresponding thereto, and the to-be-executed task queue stores to-be-executed tasks to be executed by the vCPU. Based on this, after the scheduler determines the vCPU for executing the transceiving packet thread, the scheduler can send the transceiving packet thread to the task queue corresponding to the vCPU, and the vCPU executes the transceiving packet thread in the task queue.

[0179] In the embodiments provided in the specification, when the scheduler in the virtual machine determines that there is no other task waiting for scheduling and running on the vCPU, it is determined that the vCPU is in an idle state, and the vCPU is subjected to a trap-out operation, so as to avoid waste of the computing resource of the physical CPU by the vCPU without task execution. Specifically, after the allocating the to-be-allocated task to the target vCPU for task execution, the method further comprises:

[0180] In a case where it is determined that the task queue to be executed corresponding to the target vCPU is empty, the current running state of the target vCPU is adjusted to an idle state, and the physical computing resource corresponding to the target vCPU is released.

[0181] The physical computing resource includes, but is not limited to, a physical vCPU computing resource corresponding to the target vCPU, a physical storage resource corresponding to the target vCPU, and the like.

[0182] Specifically, the scheduler adjusts the current running state of the target vCPU to an idle state in a case where it is determined that there is no task to be allocated waiting for execution in the task queue to be executed. In actual application, each task scheduling passes through the scheduler, and therefore, the scheduler can determine that the target vCPU currently has a task waiting for execution by performing a judgment once when the task passes through the scheduler for scheduling.

[0183] Then, the scheduler releases the physical computing resource corresponding to the target vCPU. It can be understood that the release of the physical computing resource corresponding to the target vCPU is a trap-out operation performed on the target vCPU. The explanation of the trap-out operation performed on the vCPU can be referred to the corresponding or corresponding content in the above-mentioned embodiments, or can refer to any kind of implementation of the trap-out operation performed on the vCPU. The present embodiment does not make too much elaboration on this.

[0184] Further, in an embodiment provided in the present specification, the scheduling idea of the task processing method provided in the present specification is to make the threads waiting for execution concentrate on a few CPUs as much as possible, so that the other vCPUs except the few CPUs execute less tasks, and the other vCPUs are in an idle state, so as to further achieve the purpose of scheduling overhead. However, in a case where the current task allocation request of the target virtual object is large, in order to ensure that the task allocation request is processed smoothly, and to avoid the problem that the target virtual object is loaded, the scheduler adjusts the vCPU in the idle state to a running state, and executes the task to be allocated carried in the task allocation request by the vCPU, so as to avoid the problem that the target virtual object is loaded. Specifically, after the task allocation request of the target virtual object is received, the following steps are further included:

[0185] In a case where it is determined that the attribute information of the task allocation request meets the vCPU state adjustment condition, at least two vCPUs corresponding to the target virtual object are determined.

[0186] The vCPU in the at least two vCPUs and in the idle state is determined as a target vCPU.

[0187] adjust the current running state of the target vCPU to the running state, and assign the to-be-assigned task to the target vCPU for task execution.

[0188] The attribute information of the task allocation request can be understood as quantity information of the task allocation request. Correspondingly, the attribute information satisfying the vCPU state adjustment condition can be understood as the quantity information of the task allocation request being greater than a preset quantity threshold. The preset quantity threshold can be set according to actual application scenarios, for example, 1000, 10000, and the like.

[0189] The adjustment of the current running state of the target vCPU to the running state can be understood as performing a trap operation on the target vCPU. The explanation of performing the trap operation on the vCPU can be referred to the corresponding or corresponding content in the above embodiments, or can refer to any one of the ways of performing the trap operation on the vCPU, and the present specification will not make too much repetition.

[0190] Specifically, the scheduler can determine the attribute information of the task allocation request, and in a case where the attribute information of the task allocation request satisfies the vCPU state adjustment condition, the scheduler can determine at least two vCPUs corresponding to the target virtual object; and determine a vCPU in an idle state as the target vCPU from the at least two vCPUs; then adjust the current running state of the target vCPU to the running state, and assign the to-be-assigned task to the target vCPU for task execution.

[0191] In the above example, the scheduler can determine the quantity of the currently received task allocation request. In actual application, each task scheduling will pass through the scheduler, so when the task passes through the scheduler for scheduling, the scheduler can determine the quantity of the received task allocation request. Based on this, in a case where the quantity is greater than a preset quantity threshold, in order to avoid the problem of load of the virtual machine, the scheduler determines a plurality of vCPUs corresponding to the virtual machine, and determines a vCPU in an idle state from the plurality of vCPUs; determines the vCPU as a vCPU for processing a transceiving packet thread carried in the request, and performs a trap operation on the vCPU, so that the vCPU can run the transceiving packet thread.

[0192] The task processing method provided in the specification can determine an initial vCPU whose current resource occupation information is greater than that of other vCPUs from at least two vCPUs corresponding to a target virtual object, determine the initial vCPU as a target vCPU in a case where the current resource occupation information of the initial vCPU meets a task processing condition of a to-be-assigned task, and execute the to-be-assigned task through the target vCPU, thereby avoiding the problem of CPU scheduling loss caused by frequent trapping of an idle vCPU to a host, and further reducing physical CPU scheduling loss.

[0193] Further, in the task processing method provided in the specification, the scheduler on the Host can also select the scheduling strategy provided in the task processing method, and the scheduler on the Host can also achieve the effect of reducing CPU scheduling overhead based on the scheduling strategy. However, because the scheduler on the Host does not involve two-layer scheduling of the guest and the host and trapping caused by virtualization, the effect of reducing CPU scheduling overhead is not as obvious as that under virtualization.

[0194] Corresponding to the method embodiments, the specification also provides task processing device embodiments, Figure 6 A structure schematic diagram of a task processing device provided in an embodiment of the specification is shown. As shown in the figure, Figure 6 The device includes:

[0195] The receiving module 602 is configured to receive a task assignment request for a target virtual object, wherein the task assignment request carries a to-be-assigned task.

[0196] The first determining module 604 is configured to determine at least two vCPUs corresponding to the target virtual object based on the task assignment request, and determine an initial vCPU from the at least two vCPUs, wherein current resource occupation information of the initial vCPU is greater than that of other vCPUs.

[0197] The second determining module 606 is configured to determine the initial vCPU as a target vCPU in a case where the current resource occupation information of the initial vCPU meets a task processing condition of the to-be-assigned task.

[0198] The executing module 608 is configured to assign the to-be-assigned task to the target vCPU for task execution.

[0199] Optionally, the second determining module 606 is further configured to:

[0200] determine the initial vCPU as the target vCPU in a case where the current resource occupation information of the initial vCPU meets a preset load condition.

[0201] Optionally, the task processing device further includes a third determining module configured to:

[0202] When it is determined that the current resource occupancy information of the initial vCPU does not meet the preset load condition, determining a candidate vCPU from the other vCPUs, wherein the current resource occupancy information of the candidate vCPU meets the preset load condition;

[0203] A target vCPU is determined from the candidate vCPUs, wherein current resource occupancy information of the target vCPU is greater than that of other candidate vCPUs except the target vCPU among the candidate vCPUs.

[0204] Optionally, the first determining module 604 is further configured to:

[0205] Determine a vCPU set corresponding to each vCPU, wherein the vCPU set includes vCPUs of the same type; and determine a target vCPU set corresponding to the task type of the task to be assigned based on historical task execution information;

[0206] An initial vCPU is determined from the target vCPU set, wherein current resource occupancy information of the initial vCPU is greater than that of other vCPUs in the target vCPU set.

[0207] Optionally, the first determining module 604 is further configured to:

[0208] Determine the current resource usage of each vCPU;

[0209] Sort each vCPU in descending order based on the current resource occupancy information to obtain a descending sort result for each vCPU;

[0210] The vCPU at the first position in the descending sort result is determined as the initial vCPU.

[0211] Optionally, the second determining module 606 is further configured to:

[0212] Determining resource occupancy information of the task to be assigned;

[0213] Determine the remaining resource information corresponding to the initial vCPU based on the current resource occupancy information of the initial vCPU;

[0214] When the remaining resource information is greater than or equal to the resource occupancy information, the initial vCPU is determined as the target vCPU.

[0215] Optionally, the task processing apparatus further comprises a fourth determination module configured to:

[0216] In a case where the remaining resource information is less than the resource occupation information, the step of determining the initial vCPU from the at least two vCPUs is continuously performed until the remaining resource information is greater than or equal to the resource occupation information.

[0217] Optionally, the execution module 608 is further configured to:

[0218] allocate the to-be-allocated task to a to-be-executed task queue corresponding to the target vCPU, and perform task execution in the to-be-executed task queue.

[0219] Optionally, the task processing apparatus further comprises a first state adjustment module configured to:

[0220] In a case where it is determined that the to-be-executed task queue corresponding to the target vCPU is empty, the current running state of the target vCPU is adjusted to an idle state, and the physical computing resource corresponding to the target vCPU is released.

[0221] Optionally, the task processing apparatus further comprises a second state adjustment module configured to:

[0222] In a case where it is determined that the attribute information of the task allocation request satisfies a vCPU state adjustment condition, at least two vCPUs corresponding to the target virtual object are determined.

[0223] A vCPU, of the at least two vCPUs, whose current running state is an idle state is determined as a target vCPU.

[0224] The current running state of the target vCPU is adjusted to a running state, and the to-be-allocated task is allocated to the target vCPU for task execution.

[0225] The task processing apparatus provided in the specification can determine, from at least two vCPUs corresponding to a target virtual object, an initial vCPU whose current resource occupation information is greater than that of other vCPUs of the at least two vCPUs; in a case where it is determined that the current resource occupation information of the initial vCPU satisfies a task processing condition of a to-be-allocated task, the initial vCPU is determined as a target vCPU, and the to-be-allocated task is executed through the target vCPU, thereby avoiding the problem of CPU scheduling loss caused by frequent trapping of an idle vCPU to a host, and further reducing physical CPU scheduling loss.

[0226] The above is a schematic solution of the task processing device of the embodiment. It should be noted that the technical solution of the task processing device and the technical solution of the task processing method described above belong to the same concept, and the details of the technical solution of the task processing device that are not described in detail can be referred to the description of the technical solution of the task processing method.

[0227] Figure 7 A structural block diagram of a computing device 700 according to one embodiment of the present specification is shown. The components of the computing device 700 include, but are not limited to, a memory 710 and a processor 720. The processor 720 is connected to the memory 710 through a bus 730, and a database 750 is used to save data.

[0228] The computing device 700 also includes an access device 740, which enables the computing device 700 to communicate via one or more networks 760. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 740 can include one or more of any type of network interface (e.g., a network interface card (NIC)), wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0229] In one embodiment of the present specification, the above-mentioned components of the computing device 700 and other components not shown in the Figure 7 may be connected to each other, for example, through a bus. It should be understood that Figure 7 The structural block diagram of the computing device shown is only for the purpose of example, and is not a limitation on the scope of the present specification. Those skilled in the art can add or replace other components as needed.

[0230] The computing device 700 can be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smartphone), a wearable computing device (e.g., a smartwatch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a PC. The computing device 700 can also be a mobile or stationary server.

[0231] The processor 720 is configured to execute computer-executable instructions, which, when executed by the processor 720, implement the steps of the task processing method described above.

[0232] The above is a schematic solution of the computing device of the embodiment. It should be noted that the technical solution of the computing device and the technical solution of the task processing method described above belong to the same concept, and the details of the technical solution of the computing device that are not described in detail can be referred to the description of the technical solution of the task processing method.

[0233] An embodiment of the present specification further provides a computer readable storage medium, which stores computer executable instructions, and the computer executable instructions are executed by a processor to implement the steps of the task processing method.

[0234] The above is a schematic solution of the computer readable storage medium of the embodiment. It should be noted that the technical solution of the storage medium and the technical solution of the task processing method described above belong to the same concept, and the details of the technical solution of the storage medium that are not described in detail can be referred to the description of the technical solution of the task processing method.

[0235] An embodiment of the present specification further provides a computer program, which causes a computer to execute the steps of the task processing method when the computer program is executed in the computer.

[0236] The above is a schematic solution of the computer program of the embodiment. It should be noted that the technical solution of the computer program and the technical solution of the task processing method described above belong to the same concept, and the details of the technical solution of the computer program that are not described in detail can be referred to the description of the technical solution of the task processing method.

[0237] The above describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the acts or steps in a claim can be performed in an order different than the order in which the acts or steps are recited, and still accomplish the desired results. Also, the process depicted in the accompanying figures does not necessarily require the particular order shown, or sequential order to achieve the desired results. In certain implementations, multitasking and parallel processing can be advantageous.

[0238] The computer readable medium can include any entity or apparatus capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, software distribution medium, etc. It should be noted that the computer readable medium can include appropriate additions or subtractions according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.

[0239] It should be noted that for the foregoing method embodiments, the descriptions are expressed as a combination of a series of actions for the sake of simplicity, but those skilled in the art should know that the embodiments of the present specification are not limited by the order of the described actions, because according to the embodiments of the present specification, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments of the present specification.

[0240] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0241] The preferred embodiments of the present specification disclosed above are only used to help explain the present specification. The alternative embodiments do not describe all the details and limit the invention to the specific embodiments described. Obviously, according to the content of the embodiments of the present specification, many modifications and changes can be made. The present specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of the present specification, so that those skilled in the art can well understand and use the present specification. The present specification is limited by the claims and their entire scope and equivalents.

Claims

1. A task processing method, comprising: receiving a task assignment request for a target virtual object, wherein the task assignment request carries a task to be assigned; Determining, based on the task allocation request, at least two vCPUs corresponding to the target virtual object, and determining an initial vCPU from the at least two vCPUs, wherein current resource occupancy information of the initial vCPU is greater than that of other vCPUs; Determining the current resource occupancy information of the initial vCPU as the target vCPU when the task processing condition of the task to be assigned is met; Allocate the task to be assigned to the target vCPU for task execution.

2. The task processing method according to claim 1, wherein, when determining the current resource occupancy information of the initial vCPU and the task processing condition of the task to be assigned is met, determining the initial vCPU as the target vCPU comprises: When the current resource occupancy information of the initial vCPU is determined to meet a preset load condition, the initial vCPU is determined as the target vCPU.

3. The task processing method according to claim 1, further comprising: after determining an initial vCPU from the at least two vCPUs; When it is determined that the current resource occupancy information of the initial vCPU does not meet the preset load condition, determining a candidate vCPU from the other vCPUs, wherein the current resource occupancy information of the candidate vCPU meets the preset load condition; A target vCPU is determined from the candidate vCPUs, wherein current resource occupancy information of the target vCPU is greater than that of other candidate vCPUs except the target vCPU among the candidate vCPUs.

4. The task processing method according to claim 1, wherein determining the initial vCPU from the at least two vCPUs comprises: Determine a vCPU set corresponding to each vCPU, wherein the vCPU set includes vCPUs of the same type; Determine a target vCPU set corresponding to the task type of the task to be assigned based on historical task execution information; An initial vCPU is determined from the target vCPU set, wherein current resource occupancy information of the initial vCPU is greater than that of other vCPUs in the target vCPU set.

5. The task processing method according to claim 1, wherein determining the initial vCPU from the at least two vCPUs comprises: Determine the current resource usage of each vCPU; Sort each vCPU in descending order based on the current resource occupancy information to obtain a descending sort result for each vCPU; The vCPU at the first position in the descending sort result is determined as the initial vCPU.

6. The task processing method according to claim 1, wherein, when determining the current resource occupancy information of the initial vCPU and the task processing condition of the task to be assigned is met, determining the initial vCPU as the target vCPU comprises: Determining resource occupancy information of the task to be assigned; Determine the remaining resource information corresponding to the initial vCPU based on the current resource occupancy information of the initial vCPU; When the remaining resource information is greater than or equal to the resource occupancy information, the initial vCPU is determined as the target vCPU.

7. The task processing method according to claim 6, after determining the remaining resource information corresponding to the initial vCPU based on the current resource occupancy information of the initial vCPU, further comprising: When the remaining resource information is less than the resource occupation information, re-determining an initial vCPU from vCPUs other than the initial vCPU; Based on the current resource occupancy information of the re-determined initial vCPU, the corresponding remaining resource information is determined, and the step of re-determining the initial vCPU from vCPUs other than the initial vCPU when the remaining resource information is less than the resource occupancy information is returned to, until the remaining resource information is greater than or equal to the resource occupancy information.

8. The task processing method according to claim 1, wherein allocating the to-be-assigned task to the target vCPU for task execution comprises: The to-be-assigned task is assigned to a to-be-executed task queue corresponding to the target vCPU, and the task is executed in the to-be-executed task queue.

9. The task processing method according to claim 7, after allocating the to-be-allocated task to the target vCPU for task execution, further comprising: When it is determined that the queue of to-be-executed tasks corresponding to the target vCPU is empty, the current running state of the target vCPU is adjusted to an idle state, and the physical computing resources corresponding to the target vCPU are released.

10. The task processing method according to claim 1, after receiving the task assignment request for the target virtual object, further comprising: If it is determined that the attribute information of the task allocation request meets the vCPU state adjustment condition, determining at least two vCPUs corresponding to the target virtual object; Determine the vCPU of the at least two vCPUs that is currently in an idle state as the target vCPU; The current running state of the target vCPU is adjusted to the running state, and the to-be-assigned task is assigned to the target vCPU for task execution.

11. A task processing device comprising: A receiving module is configured to receive a task assignment request for a target virtual object, wherein the task assignment request carries a task to be assigned; A first determining module is configured to determine, based on the task allocation request, at least two vCPUs corresponding to the target virtual object, and determine an initial vCPU from the at least two vCPUs, wherein current resource occupancy information of the initial vCPU is greater than that of other vCPUs; A second determining module is configured to determine that the initial vCPU is a target vCPU when determining that the current resource occupancy information of the initial vCPU meets the task processing condition of the task to be assigned; The execution module is configured to assign the task to be assigned to the target vCPU for task execution.

12. A computing device comprising: memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the task processing method according to any one of claims 1 to 10 are implemented.

13. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, implement the steps of the task processing method according to any one of claims 1 to 10.

14. A computer program product comprising computer instructions, which, when executed by a processor, implement the steps of the task processing method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Resources scheduling method and device

    CN111949398A

  • Resource scheduling implementation method based on energy consumption and QoS collaborative optimization

    CN113515351A