[go: up one dir, main page]

CN115168028A - Task processing method and device - Google Patents

Task processing method and device Download PDF

Info

Publication number
CN115168028A
CN115168028A CN202210682601.XA CN202210682601A CN115168028A CN 115168028 A CN115168028 A CN 115168028A CN 202210682601 A CN202210682601 A CN 202210682601A CN 115168028 A CN115168028 A CN 115168028A
Authority
CN
China
Prior art keywords
vcpu
task
initial
vcpus
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210682601.XA
Other languages
Chinese (zh)
Inventor
何容光
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba China Co Ltd
Original Assignee
Alibaba China Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba China Co Ltd filed Critical Alibaba China Co Ltd
Priority to CN202210682601.XA priority Critical patent/CN115168028A/en
Publication of CN115168028A publication Critical patent/CN115168028A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5044Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering hardware capabilities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5012Processor sets
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5015Service provider selection

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the specification provides a task processing method and a task processing device, wherein the task processing method comprises the following steps: receiving a task allocation request aiming at a target virtual object, wherein 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, wherein the current resource occupation information of the initial vCPU is greater than that of other vCPUs; determining the initial vCPU as a target vCPU under the condition that the current resource occupation information of the initial vCPU is determined to meet the task processing condition of the task to be distributed; distributing the task to be distributed to the target vCPU for task execution; therefore, the problem of CPU scheduling loss caused by frequent subsidence of the idle vCPU to the host is avoided, and the physical CPU scheduling loss is further reduced.

Description

任务处理方法及装置Task processing method and device

技术领域technical field

本说明书实施例涉及计算机技术领域,特别涉及一种任务处理方法。The embodiments of this specification relate to the field of computer technologies, and in particular, to a task processing method.

背景技术Background technique

随着虚拟化技术的发展,许多互联网企业会采用硬件虚拟化能力来做安全隔离,在硬件虚拟化场景下,一种很难消除的CPU开销来源是,每个空闲vCPU会频繁的陷出到宿主机中,并大量消耗CPU的计算资源为该vCPU执行宿主机上的调度流程,从而造成较高且难优化的物理CPU调度损耗,因此,亟需提供一种降低由于空闲vCPU频繁陷出到宿主机,所导致的物理CPU调度损耗的问题。With the development of virtualization technology, many Internet companies will use hardware virtualization capabilities for security isolation. In hardware virtualization scenarios, a source of CPU overhead that is difficult to eliminate is that each idle vCPU will frequently fall out of In the host, a large amount of CPU computing resources are consumed to execute the scheduling process on the host for the vCPU, resulting in high and difficult-to-optimize physical CPU scheduling losses. The host machine, the problem of physical CPU scheduling loss caused.

发明内容SUMMARY OF THE INVENTION

有鉴于此,本说明书实施例提供了一种任务处理方法。本说明书一个或者多个实施例同时涉及一种任务处理装置,一种计算设备,一种计算机可读存储介质,一种计算机程序,以解决现有技术中存在的技术缺陷。In view of this, the embodiments of this specification provide a task processing method. One or more embodiments of this specification also relate to a task processing apparatus, a computing device, a computer-readable storage medium, and a computer program, so as to solve the technical defects existing in the prior art.

根据本说明书实施例的第一方面,提供了一种任务处理方法,包括:According to a first aspect of the embodiments of the present specification, a task processing method is provided, including:

接收针对目标虚拟对象的任务分配请求,其中,所述任务分配请求中携带有待分配任务;receiving a task assignment request for the target virtual object, wherein the task assignment request carries a task to be assigned;

基于所述任务分配请求,确定所述目标虚拟对象对应的至少两个vCPU,并从所述至少两个vCPU中确定初始vCPU,其中,所述初始vCPU的当前资源占用信息大于其他vCPU;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 occupancy information of the initial vCPU is greater than that of other vCPUs;

在确定所述初始vCPU的当前资源占用信息,满足所述待分配任务的任务处理条件的情况下,确定所述初始vCPU为目标vCPU;In the case of determining the current resource occupancy information of the initial vCPU and satisfying the task processing conditions of the to-be-allocated task, determining the initial vCPU as the target vCPU;

将所述待分配任务分配至所述目标vCPU进行任务执行。Allocate the to-be-allocated task to the target vCPU for task execution.

根据本说明书实施例的第二方面,提供了一种任务处理装置,包括:According to a second aspect of the embodiments of the present specification, a task processing apparatus is provided, including:

接收模块,被配置为接收针对目标虚拟对象的任务分配请求,其中,所述任务分配请求中携带有待分配任务;a receiving module, configured to receive a task assignment request for the target virtual object, wherein the task assignment request carries a task to be assigned;

第一确定模块,被配置为基于所述任务分配请求,确定所述目标虚拟对象对应的至少两个vCPU,并从所述至少两个vCPU中确定初始vCPU,其中,所述初始vCPU的当前资源占用信息大于其他vCPU;a first determining module, 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, wherein the current resources of the initial vCPU The occupancy information is larger than other vCPUs;

第二确定模块,被配置为在确定所述初始vCPU的当前资源占用信息,满足所述待分配任务的任务处理条件的情况下,确定所述初始vCPU为目标vCPU;a second determining module, configured to determine the initial vCPU as the target vCPU under the condition that the current resource occupation information of the initial vCPU is determined and the task processing condition of the to-be-allocated task is satisfied;

执行模块,被配置为将所述待分配任务分配至所述目标vCPU进行任务执行。The execution module is configured to allocate the to-be-allocated task to the target vCPU for task execution.

根据本说明书实施例的第三方面,提供了一种计算设备,包括:According to a third aspect of the embodiments of the present specification, a computing device is provided, including:

存储器和处理器;memory and processor;

所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令,该计算机可执行指令被处理器执行时实现所述任务处理方法的步骤。The memory is used for storing computer-executable instructions, the processor is used for executing the computer-executable instructions, and when the computer-executable instructions are executed by the processor, the steps of the task processing method are implemented.

根据本说明书实施例的第四方面,提供了一种计算机可读存储介质,其存储有计算机可执行指令,该计算机可执行指令被处理器执行时实现所述任务处理方法的步骤。According to a fourth aspect of the embodiments of the present specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, implements the steps of the task processing method.

根据本说明书实施例的第五方面,提供了一种计算机程序,其中,当所述计算机程序在计算机中执行时,令计算机执行所述任务处理方法的步骤。According to a fifth aspect of the embodiments of the present specification, a computer program is provided, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the task processing method.

本说明书提供的任务处理方法,包括:接收针对目标虚拟对象的任务分配请求,其中,所述任务分配请求中携带有待分配任务;基于所述任务分配请求,确定所述目标虚拟对象对应的至少两个vCPU,并从所述至少两个vCPU中确定初始vCPU,其中,所述初始vCPU的当前资源占用信息大于其他vCPU;在确定所述初始vCPU的当前资源占用信息,满足所述待分配任务的任务处理条件的情况下,确定所述初始vCPU为目标vCPU;将所述待分配任务分配至所述目标vCPU进行任务执行。The task processing method provided in this specification includes: receiving a task allocation request for a target virtual object, wherein the task allocation request carries a task to be allocated; and determining at least two tasks 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 occupancy information of the initial vCPU is larger than that of other vCPUs; after determining the current resource occupancy information of the initial vCPU, it satisfies the requirement of the task to be allocated. In the case of task processing conditions, the initial vCPU is determined as the target vCPU; the to-be-allocated task is allocated to the target vCPU for task execution.

具体地,该方法能够从目标虚拟对象对应的至少两个vCPU中,确定当前资源占用信息大于该至少两个vCPU中其他vCPU的初始vCPU;在确定该初始vCPU的当前资源占用信息,满足待分配任务的任务处理条件的情况下,将该初始vCPU确定为目标vCPU,并通过该目标vCPU执行该待分配任务,从而避免了由于空闲vCPU频繁陷出到宿主机,所导致的CPU调度损耗的问题,进一步降低了物理CPU调度损耗。Specifically, the method can determine, from at least two vCPUs corresponding to the target virtual object, that the current resource occupancy information is greater than the initial vCPUs of other vCPUs in the at least two vCPUs; In the case of the task processing conditions of the task, the initial vCPU is determined as the target vCPU, and the to-be-allocated task 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. , which further reduces the physical CPU scheduling loss.

附图说明Description of drawings

图1是本说明书一个实施例提供的一种任务调度的流程图;1 is a flowchart of a task scheduling provided by an embodiment of the present specification;

图2是本说明书一个实施例提供的一种陷出操作的流程示意图;2 is a schematic flowchart of a trapping operation provided by an embodiment of the present specification;

图3是本说明书一个实施例提供的一种任务处理方法在具体应用场景的示意图;3 is a schematic diagram of a specific application scenario of a task processing method provided by an embodiment of this specification;

图4是本说明书一个实施例提供的一种任务处理方法的处理过程流程图;FIG. 4 is a process flow chart of a task processing method provided by an embodiment of the present specification;

图5是本说明书一个实施例提供的一种任务处理方法的流程图;5 is a flowchart of a task processing method provided by an embodiment of the present specification;

图6是本说明书一个实施例提供的一种任务处理装置的结构示意图;6 is a schematic structural diagram of a task processing apparatus provided by an embodiment of the present specification;

图7是本说明书一个实施例提供的一种计算设备的结构框图。FIG. 7 is a structural block diagram of a computing device provided by an embodiment of the present specification.

具体实施方式Detailed ways

在下面的描述中阐述了很多具体细节以便于充分理解本说明书。但是本说明书能够以很多不同于在此描述的其它方式来实施,本领域技术人员可以在不违背本说明书内涵的情况下做类似推广,因此本说明书不受下面公开的具体实施的限制。In the following description, numerous specific details are set forth in order to provide a thorough understanding of this specification. However, this specification can be implemented in many other ways different from those described herein, and those skilled in the art can make similar promotions without departing from the connotation of this specification. Therefore, this specification is not limited by the specific implementation disclosed below.

在本说明书一个或多个实施例中使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本说明书一个或多个实施例。在本说明书一个或多个实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本说明书一个或多个实施例中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。The terminology used in one or more embodiments of this specification is for the purpose of describing a particular embodiment only and is not intended to limit the one or more embodiments of this specification. As used in the specification or embodiments and the appended claims, the singular forms "a," "the," and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise. It will also be understood that the term "and/or" as used in this specification in one or more embodiments refers to and includes any and all possible combinations of one or more of the associated listed items.

应当理解,尽管在本说明书一个或多个实施例中可能采用术语第一、第二等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本说明书一个或多个实施例范围的情况下,第一也可以被称为第二,类似地,第二也可以被称为第一。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It will be understood that although the terms first, second, etc. may be used in one or more embodiments of this specification to describe various information, such information should not be limited by these terms. These terms are only used to distinguish the same type of information from each other. For example, a first could be termed a second, and similarly, a second could be termed a first, without departing from the scope of one or more embodiments of this specification. Depending on the context, the word "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determining."

首先,对本说明书一个或多个实施例涉及的名词术语进行解释。First, the terminology involved in one or more embodiments of the present specification is explained.

硬件虚拟化:一种使用物理CPU提供的硬件指令来执行虚拟机的技术。Hardware Virtualization: A technique that uses hardware instructions provided by a physical CPU to execute a virtual machine.

vCPU:虚拟机能够感知到的CPU,在硬件虚拟化下,一般的vCPU实现是宿主机上的一个线程,即vCPU线程。vCPU: The CPU that the virtual machine can perceive. Under hardware virtualization, the general vCPU implementation is a thread on the host, that is, the vCPU thread.

Guest:即虚拟机。Guest: The virtual machine.

Host:虚拟机运行所在的宿主机。Host: The host where the virtual machine is running.

陷出;硬件虚拟化下,CPU从执行虚拟机内的指令/流程(称为非根模式)的状态,退出到执行宿主机的指令/流程(根模式)的状态。Trap; under hardware virtualization, the CPU exits from the state of executing the instructions/processes in the virtual machine (called non-root mode) to the state of executing the instructions/processes of the host machine (root mode).

陷入:与陷出相反,是从根模式进入非根模式。Trap: In contrast to trap, it is from root mode into non-root mode.

HLT:即halt,在CPU无事可干时(没有线程等着调度),执行CPU的HLT指令,表示CPU空闲。在硬件虚拟化下,guest内的vCPU执行HLT指令会导致陷出到host。HLT: that is, halt, when the CPU has nothing to do (no threads waiting to be scheduled), execute the HLT instruction of the CPU, indicating that the CPU is idle. Under hardware virtualization, the execution of HLT instructions by the vCPU in the guest will cause a trap to the host.

idle:调度里的idle指CPU上没有等待运行的线程可以调度,因此进入空闲状态,也就是idle状态,这种情况下Linux一般会执行HLT指令。idle: The idle in scheduling means that there are no threads waiting to run on the CPU that can be scheduled, so it enters an idle state, that is, the idle state. In this case, Linux generally executes the HLT instruction.

调度域:由于CPU在不同层级共享的Cache以及NUMA导致的内存访问速率不同,调度器可能分为相同CPU core、相同CPU package、相同NUMA、所有CPU等不同层级,每个层级里的CPU就称为一个调度域,例如,通常调度器尽可能避免把线程调度到与以前所在NUMA不同的其他NUMA上去。Scheduling domain: Due to the different memory access rates caused by the Cache and NUMA shared by CPUs at different levels, the scheduler may be divided into different levels such as the same CPU core, the same CPU package, the same NUMA, and all CPUs. The CPUs in each level are called For a scheduling domain, for example, the scheduler generally tries to avoid scheduling threads to a different NUMA than the NUMA it was in before.

NUMA(Non Uniform Memory Access):非统一内存访问。NUMA (Non Uniform Memory Access): Non-uniform memory access.

CPU core:CPU处理器的核心。CPU core: The core of the CPU processor.

CPU package:指物理上的一整块CPU,一个CPU package里面可能有多个CPU核心。CPU package: Refers to a physical entire CPU, and a CPU package may have multiple CPU cores.

随着虚拟化技术的发展,许多虚拟机、云服务器(ECS)或安全容器会使用硬件虚拟化能力来做安全隔离,而在硬件虚拟化下,一种很难消除的CPU开销来源是:每个vCPU线程在陷出到宿主机后,会重新执行一遍宿主机上的调度流程,该调度流程也就是:调度器判断如果该vCPU上没有别的任务等待调度运行,那么在确定该vCPU处于空闲状态,且该vCPU所在的宿主机CPU上,没有其他等待运行的宿主机上的线程的情况下,会执行一次idlebalance流程。如果对应宿主机CPU上有其他等待运行的任务,虽然不会执行idle balance,但在调度过程中也会处理vCPU的runtime更新等,也比较耗时。而该idle balance流程,会尝试从别的vCPU拉取等待运行的进程,这会占用较明显的vCPU的运行资源,并进一步的消耗运行该vCPU线程的物理CPU的计算资源,基于此,也就带来较高且难优化的虚拟化CPU损耗(即调度损耗)。With the development of virtualization technology, many virtual machines, cloud servers (ECS) or secure containers will use hardware virtualization capabilities for security isolation, and under hardware virtualization, a source of CPU overhead that is difficult to eliminate is: After each vCPU thread is trapped in the host, it will re-execute the scheduling process on the host. The scheduling process is: the scheduler judges that if there are no other tasks waiting to be scheduled on the vCPU, then it determines that the vCPU is idle. state, and the host CPU where the vCPU is located has no other threads waiting to run on the host, an idlebalance process will be executed. If there are other tasks waiting to be run on the corresponding host CPU, although the idle balance will not be executed, the runtime update of the vCPU will also be processed during the scheduling process, which is also time-consuming. The idle balance process will try to pull the processes waiting to run from other vCPUs, which will occupy more obvious vCPU running resources and further consume the computing resources of the physical CPU running the vCPU thread. Brings high and hard-to-optimize virtualized CPU costs (ie, scheduling costs).

例如,在安全容器或虚拟机内执行tcp ping-pong收发包的场景下,上述造成CPU损耗的问题表现的较为明显,因为,安全容器或虚拟机对应的vCPU,每隔几百微秒或几毫秒就要执行一次收发包的操作,且每次执行很少量的代码又陷出;而每次陷出的过程中,在vCPU已经执行了一遍虚拟机内的调度流程的情况下,还要额外执行一遍宿主机上的调度流程,导致vCPU的调度开销变成了物理机情况下的两倍。For example, in the scenario where tcp ping-pong is executed in a secure container or virtual machine to send and receive packets, the above-mentioned problem of causing CPU consumption is more obvious, because the vCPU corresponding to the secure container or virtual machine, every few hundred microseconds or a few In milliseconds, the operation of sending and receiving packets is performed once, and a small amount of code is executed each time and it is trapped; and in the process of each trapping, in the case where the vCPU has already executed the scheduling process in the virtual machine, it is necessary to An additional execution of the scheduling process on the host causes the scheduling overhead of the vCPU to become twice that of the physical machine.

而造成上述问题的一个原因在于,通常安全容器或虚拟机的调度器,在选择执行任务的vCPU时,会选择某个调度域内最空闲的CPU,以做到均衡调度,相关流程参见图1,图1是本说明书一个实施例提供的一种任务调度的流程图,具体包括下述步骤:One of the reasons for the above problem is that the scheduler of a security container or 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. See Figure 1 for the relevant process. 1 is a flowchart of a task scheduling provided by an embodiment of this specification, which specifically includes the following steps:

步骤102:存在一个新的线程可运行。Step 102: There is a new thread to run.

步骤104:在某个调度域内找一个最空闲的vCPU。Step 104: Find the most idle vCPU in a certain scheduling domain.

步骤106:调度该线程到该最空闲的vCPU上运行执行。Step 106: Schedule the thread to run and execute on the most idle vCPU.

基于上述步骤可知,通过调度器为例保证负载均衡,会将新的线程分配给最空闲的vCPU,从而使得每个vCPU都有需要执行的任务(即线程);但是,这也导致了每个vCPU都会执行一小段时间就执行陷出操作,从而导致较多的HLT陷出处理开销和调度开销。Based on the above steps, it can be seen that using the scheduler as an example to ensure load balancing, new threads will be allocated to the most idle vCPU, so that each vCPU has tasks (that is, threads) that need to be executed; however, this also leads to each The vCPU will perform the trapping operation after a short period of time, which will result in more HLT trapping processing overhead and scheduling overhead.

具体地vCPU执行陷出操作的流程参见图2,图2是本说明书一个实施例提供的一种陷出操作的流程示意图,具体包括下述步骤:Specifically, refer to FIG. 2 for a flow chart of a trapping operation performed by a vCPU. FIG. 2 is a schematic flowchart of a trapping operation provided by an embodiment of this specification, which specifically includes the following steps:

步骤202:空闲状态。Step 202: idle state.

具体地,宿主机的调度器,从虚拟机对应的多个vCPU中,确定处于当前状态处于空闲状态为vCPU。Specifically, the scheduler of the host machine determines from the multiple vCPUs corresponding to the virtual machine that the current state and the idle state are the vCPUs.

步骤204:进入虚拟机。Step 204: Enter the virtual machine.

具体地,宿主机的调度器,将该空闲vCPU调度至对应的虚拟机中,使得该虚拟机能够感知到该vCPU。Specifically, the scheduler of the host machine schedules the idle vCPU to the corresponding virtual machine, so that the virtual machine can perceive the vCPU.

步骤206:执行虚拟机内指令。Step 206: Execute the instruction in the virtual machine.

具体地,将该空闲vCPU调度至对应的虚拟机之后,当虚拟机接收到新的指令时,能够通过该vCPU能够执行指令,例如,通过该vCPU执行收发包指令等。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, the vCPU can execute the instruction of sending and receiving packets.

步骤208:虚拟机内核调度流程。Step 208: the virtual machine kernel scheduling process.

具体的,该虚拟机内核中的调度器,在接收到针对该虚拟机的指令之后,启动虚拟机内核中的调度流程,将该指令调度至该虚拟机对应的vCPU上进行执行。Specifically, after receiving the instruction for the virtual machine, the scheduler in the virtual machine kernel starts the scheduling process in the virtual machine kernel, and schedules the instruction to the vCPU corresponding to the virtual machine for execution.

步骤210:没有可调用的,HLT陷出。Step 210: No callable, HLT traps.

具体地,该虚拟机内核中的调度器,在确定没有执行可以调度至该vCPU的情况下,能够确定对该vCPU执行HLT陷出操作。Specifically, the scheduler in the virtual machine kernel can determine to perform the HLT trap operation on the vCPU when it is determined that no execution can be scheduled to the vCPU.

步骤212:执行HLT陷出处理。Step 212: Execute HLT trapping processing.

具体地,该虚拟机内核中的调度器,对没有任务(例如,指令、线程等)需要执行的vCPU执行HLT陷出处理,将该vCPU陷出至宿主机。Specifically, the scheduler in the virtual machine kernel performs HLT trapping processing on the vCPU that has no task (eg, instruction, thread, etc.) to be executed, and traps the vCPU to the host machine.

步骤214:执行host调度流程。Step 214: Execute the host scheduling process.

具体地,在vCPU陷出至宿主机之后,宿主机的调度器能够释放该vCPU对应的CPU计算资源;基于释放的、该vCPU对应的CPU计算资源分配该其他线程;其中,该其他线程可以是该物理CPU上实现其他vCPU的线程,或者执行宿主机自身任务的线程。Specifically, after the vCPU is trapped in the host, the scheduler of the host can release the CPU computing resources corresponding to the vCPU; allocate the other thread based on the released CPU computing resources corresponding to the vCPU; wherein the other thread may be The physical CPU implements threads of other vCPUs, or threads that perform tasks of the host itself.

步骤216:没有调度的,进入空闲状态。Step 216: If there is no scheduling, enter the idle state.

具体地,虚拟机内核中的调度器,在对没有任务执行的vCPU执行HLT陷出处理之后,能够将该vCPU的当前状态,调整为空闲状态。Specifically, the scheduler in the virtual machine kernel can adjust the current state of the vCPU to an idle state after performing the HLT trapping process on the vCPU that has no task execution.

需要说明的是,该虚拟机对应有多个vCPU的情况下,每个vCPU均会执行上述步骤202-步骤216的步骤,例如虚拟机对应有vCPU1、vCPU2,那么vCPU1、vCPU2均会执行上述步骤202-步骤216的步骤。It should be noted that when the virtual machine corresponds to multiple vCPUs, each vCPU will perform the steps from step 202 to step 216 above. For example, if the virtual machine corresponds to vCPU1 and vCPU2, then both vCPU1 and vCPU2 will perform the above steps. 202 - the steps of step 216.

基于上述步骤可知,在vCPU频繁的执行陷出操作的情况下,会造成较多的HLT陷出处理开销和调度开销。Based on the above steps, it can be known that in the case that the vCPU frequently performs the trapping operation, more HLT trapping processing overhead and scheduling overhead will be caused.

针对上述问题,本说明书提供了四种解决方案,其中:For the above problems, this manual provides four solutions, among which:

第一种解决这种陷出开销的方案为:让guest在执行HLT时不执行陷出操作,这样就不会在每次guest从工作变为idle时,都需要执行一遍host上的调度流程。The first solution to this trapping overhead is to make the guest not perform the trapping operation when executing the HLT, so that the scheduling process on the host does not need to be executed every time the guest changes from work to idle.

但是,该方案通常适用于宿主机上的物理CPU可以被vCPU独占执行的情况,如果一个物理CPU上运行多个vCPU,则其他vCPU要执行时也会打断在guest内HLT的vCPU,从而导致在guest内的HLT被打断,还是会执行陷出的操作,因此,该方案在vCPU不能独占使用物理CPU的情况下效果达不到预期。However, this solution is usually applicable to the situation where the physical CPU on the host can be exclusively executed by the vCPU. If multiple vCPUs run on one physical CPU, other vCPUs will also interrupt the vCPU of the HLT in the guest when they want to execute, resulting in If the HLT in the guest is interrupted, the trapping operation will still be performed. Therefore, the effect of this scheme cannot achieve the expected effect when the vCPU cannot exclusively use the physical CPU.

第二种解决方案为:优化guest或host上的调度流程,减少这些调度流程所需的CPU开销。但是,由于Linux(一种操作系统)调度流程较为复杂,通过实践证明了解到,这种优化操作实现起来较为困难,因此,目前业界还没有较好的、针对Linux调度流程的优化出现。The second solution is to optimize the scheduling process on the guest or host and reduce the CPU overhead required by these scheduling processes. However, since the scheduling process of Linux (an operating system) is relatively complex, it has been 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 at present.

第三种解决方案为:针对vCPU来做一个专用的调度器。但是,该方案对于上述陷出开销较大问题并没有较好地解决。因为,即使通过专用的调度器针对vCPU进行调度,但是,在vCPU陷出后还是免不了要进行调度和选择其他要执行的vCPU,或是空闲调度(拉取其他CPU上等待执行的vCPU)流程,也即是说,该方案还是存在较大的调度开销。The third solution is to make a dedicated scheduler for the vCPU. However, this solution does not solve the problem of the above-mentioned large trapping overhead. Because, even if the vCPU is scheduled through a dedicated scheduler, after the vCPU is trapped, it is inevitable to schedule and select other vCPUs to be executed, or idle scheduling (pulling vCPUs waiting to be executed on other CPUs) process, That is to say, this solution still has a large scheduling overhead.

第四种解决方案为:关闭调度器里的idle balance也能达到减少CPU调度开销的效果,但该方案由于没有尽可能在少数几个CPU上堆积运行的任务,因此减少CPU调度开销的效果较弱。The fourth solution is: closing the idle balance in the scheduler can also reduce the CPU scheduling overhead, but this solution does not accumulate tasks running on a few CPUs as much as possible, so the effect of reducing the CPU scheduling overhead is relatively low. weak.

基于此,本说明书提供的任务处理方法,在接收针对目标虚拟对象的、且携带有待分配任务的任务分配请求之后,首先,基于任务分配请求确定目标虚拟对象对应的至少两个vCPU,并从至少两个vCPU中确定初始vCPU,其中,该初始vCPU的当前资源占用信息,大于至少两个vCPU中出该初始vCPU之外的其他vCPU。Based on this, in the task processing method provided in this specification, after receiving a task allocation request for a target virtual object and carrying a task to be allocated, firstly, based on the task allocation request, at least two vCPUs corresponding to the target virtual object are determined, and from at least two vCPUs corresponding to the target virtual object are determined. An initial vCPU is determined from the two vCPUs, wherein the current resource occupation information of the initial vCPU is greater than other vCPUs other than the initial vCPU among the at least two vCPUs.

然后,在确定初始vCPU的当前资源占用信息,满足待分配任务的任务处理条件的情况下,确定初始vCPU为目标vCPU,并将待分配任务分配至目标vCPU进行任务执行;从而避免了由于空闲vCPU频繁陷出到宿主机,所导致的CPU调度损耗的问题,进一步降低了物理CPU调度损耗。Then, when the current resource occupancy information of the initial vCPU is determined and the task processing conditions of the to-be-allocated task are satisfied, the initial vCPU is determined as the target vCPU, and the to-be-allocated task is allocated to the target vCPU for task execution. The problem of CPU scheduling loss caused by frequent traps to the host machine further reduces the physical CPU scheduling loss.

具体地,在本说明书中,提供了一种任务处理方法,本说明书同时涉及一种任务处理装置,一种计算设备,一种计算机可读存储介质以及一种计算机程序,在下面的实施例中逐一进行详细说明。Specifically, in this specification, a task processing method is provided, and this specification also relates to a task processing apparatus, a computing device, a computer-readable storage medium, and a computer program. In the following embodiments They are explained in detail one by one.

图3示出了根据本说明书一个实施例提供的一种任务处理方法在具体应用场景的流程图,具体包括:虚拟机内核中的调度器,在接收到一个新的线程A的情况下,确定有一个新的线程A需要分配至vCPU上运行执行。基于此,该调度器从多个调度域中,确定该线程A所对应的调度域B;然后调度器从该调度域B内找一个最忙的vCPU1,该最忙的vCPU1可以理解为调度域B中占用率最高的vCPU。其中,该调度域B包括vCPU1、vCPU2、vCPU3。Fig. 3 shows a flowchart of a task processing method provided in an embodiment of the present specification in a specific application scenario, which specifically includes: a scheduler in the virtual machine kernel, when receiving a new thread A, determines There is a new thread A that needs to be allocated to the vCPU to run and execute. Based on this, the scheduler determines the scheduling domain B corresponding to the thread A from multiple scheduling domains; then the scheduler finds the busiest vCPU1 from the scheduling domain B, and the busiest vCPU1 can be understood as the scheduling domain The highest occupied vCPU in B. The scheduling domain B includes vCPU1, vCPU2, and vCPU3.

之后,如果确定该vCPU1过于繁忙,那么则从该调度域B内找一个次忙的vCPU2;其中,次忙的vCPU2可以理解为,调度域B中除了vCPU1之外占用率最高的vCPU;也即是,该调度域B中占用率第二高的vCPU。After that, if it is determined that the vCPU1 is too busy, find a second busy vCPU2 from the scheduling domain B; the second busy vCPU2 can be understood as the vCPU with the highest occupancy rate in the scheduling domain B except for vCPU1; that is, Yes, the vCPU with the second highest occupancy in this scheduling domain B.

此外,vCPU1过于繁忙可以理解为,该vCPU1的占用率达到预设占用率阈值(例如70%)以上,则确定该vCPU1过于繁忙;也即是,该vCPU1过于繁忙可以为该vCPU1处于负载状态,无法处理新的线程。In addition, it can be understood that the vCPU1 is too busy, and the occupancy rate of the vCPU1 reaches a preset occupancy rate threshold (for example, 70%) or more, then it is determined that the vCPU1 is too busy; that is, the vCPU1 is too busy. Unable to process new threads.

最后,该虚拟机内核中的调度器,将新的线程A调度至所选择的vCPU上运行执行。Finally, the scheduler in the virtual machine kernel schedules the new thread A to run and execute on the selected vCPU.

基于上述内容可知,本说明书提供的一实施例中,该任务处理方法所提供的调度内容包括下述步骤A1至步骤A4。Based on the above content, in an embodiment provided in this specification, the scheduling content provided by the task processing method includes the following steps A1 to A4.

步骤A1:存在一个新的线程可运行。Step A1: There is a new thread to run.

步骤A2:在某个调度域内找一个最忙的vCPU。Step A2: Find the busiest vCPU in a certain scheduling domain.

步骤A3:如果该vCPU过于繁忙,例如vCPU占用率达到阈值(70%)以上,则选择一个次忙的vCPU。Step A3: If the vCPU is too busy, for example, the vCPU occupancy rate reaches above the threshold (70%), select a less busy vCPU.

步骤A4:调度该线程到所选择的vCPU上运行执行。Step A4: Schedule the thread to be executed on the selected vCPU.

基于上述针对图3的调度相关内容可知,本说明书提供的任务处理方法的调度思路是,尽可能让等待执行的线程集中在少数几个CPU上运行,以减小HLT开销。当有一个新的任务(线程)可运行时,虚拟机内核的调度器选择在一个调度域内最为繁忙的CPU。如果这个CPU过于繁忙,超过一个阈值(例如CPU占用率超过70%),则重新选择一个次繁忙的CPU,之后将这个可执行的任务调度到选定的CPU上去执行。从而实现让等待执行的线程集中在少数几个CPU上运行,以到达减小HLT开销,避免由于空闲vCPU频繁陷出到宿主机,所导致的CPU调度损耗的问题,进一步降低了物理CPU调度损耗。Based on the above scheduling related content for FIG. 3 , the scheduling idea of the task processing method provided in this specification is to make the threads waiting for execution run on a few CPUs as much as possible to reduce HLT overhead. When there is a new task (thread) available to run, the scheduler of the virtual machine kernel selects the busiest CPU in a scheduling domain. If the CPU is too busy and exceeds a threshold (for example, the CPU usage exceeds 70%), a less busy CPU is reselected, and then the executable task is scheduled to be executed on the selected CPU. In this way, the threads waiting to be executed are concentrated to run on a few CPUs, so as to reduce the HLT overhead, avoid the problem of CPU scheduling loss caused by the frequent trapping of idle vCPUs to the host, and further reduce the physical CPU scheduling loss. .

基于上述调度方法,本说明书中的任务处理方法所提供的调度策略,可以尽可能让等待执行的线程集中在少数几个CPU上运行,并让其他vCPU一直处于空闲状态,从而降低CPU调度损耗的调度方案。Based on the above scheduling method, the scheduling strategy provided by the task processing method in this specification can make the threads waiting for execution run on a few CPUs as much as possible, and keep other vCPUs in an idle state, thereby reducing CPU scheduling loss. scheduling plan.

而当该虚拟机对应有多个vCPU的情况下,会在少数几个CPU上执行上述调度策略,而其他vCPU执行与图2中相同的步骤。例如,虚拟机对应有vCPU1、vCPU2,那么会在vCPU1执行上述调度策略,从而让vCPU1较多地在guest内选择任务和执行,因此vCPU1比较繁忙,较少空闲;因此,导致vCPU1较少的HLT陷出(idle)和host上的调度流程;具体地,在本说明书提供的任务处理方法所提供的调度策略下,针对vCPU1的HLT陷出和调度流程如图4所示,图4是本说明书一个实施例提供的一种任务处理方法的处理过程流程图,具体包括以下步骤。When the virtual machine corresponds to multiple vCPUs, the above scheduling policy will be executed on a few CPUs, while other vCPUs will execute the same steps as shown in Figure 2. For example, if the virtual machine corresponds to vCPU1 and vCPU2, the above scheduling policy will be executed on vCPU1, so that vCPU1 can select and execute more tasks in the guest, so vCPU1 is busy and less idle; therefore, resulting in less HLT for vCPU1 The scheduling process on the trap (idle) and the host; specifically, under the scheduling strategy provided by the task processing method provided in this specification, the HLT trapping and scheduling process for vCPU1 is shown in Figure 4, which is a diagram of this specification. A processing flow chart of a task processing method provided by an embodiment specifically includes the following steps.

具体地vCPU执行陷出操作的流程参见下述步骤:For the specific process of vCPU performing the trapping operation, please refer to the following steps:

步骤402:空闲状态。Step 402: idle state.

具体地,宿主机的调度器,从虚拟机对应的多个vCPU中,确定处于当前状态处于空闲状态为vCPU。Specifically, the scheduler of the host machine determines from the multiple vCPUs corresponding to the virtual machine that the current state and the idle state are the vCPUs.

步骤404:进入虚拟机。Step 404: Enter the virtual machine.

具体地,宿主机的调度器,将该空闲vCPU调度至对应的虚拟机中,使得该虚拟机能够感知到该vCPU。Specifically, the scheduler of the host machine schedules the idle vCPU to the corresponding virtual machine, so that the virtual machine can perceive the vCPU.

步骤406:执行虚拟机内线程。Step 406: Execute the thread in the virtual machine.

具体地,将该空闲vCPU调度至对应的虚拟机之后,当虚拟机接收到新的线程时,能够通过该vCPU执行线程,例如,通过该vCPU执行收发包操作的线程等。Specifically, after the idle vCPU is scheduled to the corresponding virtual machine, when the virtual machine receives a new thread, the virtual machine can execute the thread through the vCPU, for example, execute the thread for sending and receiving packets through the vCPU.

步骤408:虚拟机内核调度流程。Step 408: the virtual machine kernel scheduling process.

具体的,该虚拟机内核中的调度器,在接收到针对该虚拟机的线程之后,启动虚拟机内核中的调度流程,将该线程调度至该虚拟机对应的vCPU上进行执行。Specifically, after receiving the thread for the virtual machine, the scheduler in the virtual machine kernel starts the scheduling process in the virtual machine kernel, and schedules the thread to the vCPU corresponding to the virtual machine for execution.

其中,该调度流程可以为:当有一个新的任务(线程)可运行时,虚拟机内核的调度器选择在一个调度域内最为繁忙的CPU。如果这个CPU过于繁忙,超过一个阈值(例如CPU占用率超过70%),则重新选择一个次繁忙的CPU,之后将这个可执行的任务调度到选定的CPU上去执行。The scheduling process may be: when a new task (thread) can be run, the scheduler of the virtual machine kernel selects the most busy CPU in a scheduling domain. If the CPU is too busy and exceeds a threshold (for example, the CPU usage exceeds 70%), a less busy CPU is reselected, and then the executable task is scheduled to be executed on the selected CPU.

步骤410:线程让出CPU,调用其他等待执行的线程。Step 410: The thread yields the CPU and calls other threads waiting for execution.

具体地,通过上述调度流程,能够尽可能让等待执行的线程集中在少数几个CPU上运行,因此,该vCPU对应的多个等待执行的线程。Specifically, through the above scheduling process, the threads waiting to be executed can be concentrated to run on a few CPUs as much as possible, so there are multiple threads waiting to be executed corresponding to the vCPU.

当vCPU执行完成一个线程之后,该线程让出该vCPU;而该vCPU会调用其他等待执行的线程。When the vCPU finishes executing a thread, the thread yields the vCPU; and the vCPU calls other threads waiting for execution.

步骤412:执行其他等待的线程。Step 412: Execute other waiting threads.

具体地,该vCPU调用其他等待执行的线程之后,会执行调用的、其他等待执行的线程。Specifically, after the vCPU calls other threads waiting for execution, it will execute the other threads waiting for execution.

并且,在vCPU执行其他等待的线程过程中,该虚拟机内核中的调度器,会在接收到针对该虚拟机的线程之后,继续执行启动虚拟机内核中的调度流程,将该线程调度至该虚拟机对应的vCPU上进行执行的步骤。In addition, when the vCPU executes 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 virtual machine kernel. Steps performed on the vCPU corresponding to the virtual machine.

步骤414:没有可调度的,进入空闲状态。Step 414: If there is no schedulable, enter the idle state.

具体地,该虚拟机内核中的调度器,在确定没有执行可以调度至该vCPU的情况下,能够确定对该vCPU执行HLT陷出操作。Specifically, the scheduler in the virtual machine kernel can determine to perform the HLT trap operation on the vCPU when it is determined that no execution can be scheduled to the vCPU.

步骤416:执行HTL陷出处理。Step 416: Execute HTL trapping processing.

具体地,该虚拟机内核中的调度器,对没有任务(例如,线程、线程等)需要执行的vCPU执行HLT陷出处理,将该vCPU陷出至宿主机。Specifically, the scheduler in the virtual machine kernel performs HLT trapping processing on the vCPU that has no task (eg, thread, thread, etc.) to be executed, and traps the vCPU to the host machine.

后续在vCPU陷出至宿主机之后,宿主机的调度器能够释放该vCPU对应的CPU计算资源;基于释放的、该vCPU对应的CPU计算资源分配该其他线程;其中,该其他线程可以是该物理CPU上实现其他vCPU的线程,或者执行宿主机自身任务的线程。After the vCPU is trapped in the host, the scheduler of the host can release the CPU computing resources corresponding to the vCPU; allocate the other thread based on the released CPU computing resources corresponding to the vCPU; wherein, the other thread may be the physical Threads that implement other vCPUs on the CPU, or threads that execute the host's own tasks.

并且,参见图4可知,本说明书提供的任务处理方法,让vCPU1执行上述步骤402至步骤416,从而使得vCPU1较多地在guest内选择任务和执行;同时,也会让vCPU2执行与图2中相同的步骤,使得在vCPU2较少有任务要执行的情况下,不会定时地进入guest和陷出guest,而是更多时间待在host上,所以使得空闲的vCPU2的HLT陷出以及由此导致的host上的调度开销也较少。进一步使得每个虚拟机的CPU开销(虚拟化开销中的一部分)都会很少。Moreover, referring to FIG. 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; The same steps, so that when vCPU2 has fewer tasks to execute, it will not enter the guest and trap the guest regularly, but spend more time on the host, so the HLT of the idle vCPU2 is trapped and thus The resulting scheduling overhead on the host is also less. Further, the CPU overhead (part of the virtualization overhead) of each virtual machine will be very small.

基于上述步骤可知,本说明书提供的任务处理方法,与一般的调度策略的一个主要区别在于:Based on the above steps, it can be seen that the main difference between the task processing method provided in this specification and the general scheduling strategy is:

一般的调度策略的主要目的是让各个CPU的负载尽可能均衡,达到的好处是应用的整体性能较高,但在虚拟化情况下,每个vCPU都会经常在工作和idle间切换,导致经常的HLT陷出,进而导致host上每个vCPU每秒高达几千次的调度流程以及带来的CPU开销。The main purpose of the general scheduling strategy is to balance the load of each CPU as much as possible, and the benefit is that the overall performance of the application is higher, but in the case of virtualization, each vCPU will often switch between work and idle, resulting in frequent HLT is trapped, which in turn leads to thousands of scheduling processes per second per vCPU on the host and CPU overhead.

基于此,本说明书提供的任务处理方法,一改传统调度器尽量使得各CPU/vCPU任务均衡的策略,通过将任务在一定阈值内堆积在个别或少数CPU上,以达到降低虚拟化下的HLT陷出,进而由此带来的host上调度开销(CPU开销)的效果,适合高频陷出,且每次执行又很短暂的场景,例如网络ping-pong式收发包,或函数计算(function compute)等场景。Based on this, the task processing method provided in this specification changes the traditional scheduler's strategy of balancing the tasks of each CPU/vCPU as much as possible, and reduces the HLT under virtualization by stacking tasks on individual or few CPUs within a certain threshold. trapping, and the resulting scheduling overhead (CPU overhead) effect on the host is suitable for high-frequency trapping and short-lived scenarios, such as network ping-pong sending and receiving packets, or function computing (function compute) and other scenarios.

同时,针对上述第四种方案,本说明书提供的任务处理方法,由于没有关闭vCPU的HLT陷出,因此没有vCPU需要独占CPU才有效果的限制。由于没有对调度器的idle balance处理流程进行修改,因此不涉及需要优化idle balance开销这个难点。由于没有专门实现一个针对vCPU的调度器,因此不涉及需要专门实现一个新的针对vCPU调度策略的难点。由于上述方案无法在少数几个CPU上堆积运行的任务,因此减少CPU调度开销得效果,并没有本说明书提供的任务处理方法所达到效果好。At the same time, for the fourth solution above, in the task processing method provided in this specification, since the HLT trapping of the vCPU is not turned off, there is no restriction that the vCPU needs to monopolize the CPU to be effective. Since the idle balance processing flow of the scheduler is not modified, the difficulty of optimizing the idle balance overhead is not involved. Since a scheduler for vCPUs is not specifically implemented, the difficulty of implementing a new scheduling policy for vCPUs is not involved. Since the above solution cannot accumulate running tasks on a few CPUs, the effect of reducing the CPU scheduling overhead is not as good as that achieved by the task processing method provided in this specification.

基于此,本说明书提供的任务处理方法,通过对现有的调度策略进行小的选择CPU策略上的改动,达到了降低虚拟化下CPU调度开销的效果,在一些高频唤醒的场景效果尤其明显,例如TCP ping-pong收发包的场景,且在这些场景对性能没有明显影响。Based on this, the task processing method provided in this specification achieves the effect of reducing the CPU scheduling overhead under virtualization by making small changes to the existing scheduling strategy in selecting the CPU strategy, especially in some high-frequency wake-up scenarios. , such as the scenario of TCP ping-pong sending and receiving packets, and there is no obvious impact on performance in these scenarios.

图5示出了根据本说明书一个实施例提供的一种任务处理方法的流程图,具体包括以下步骤。Fig. 5 shows a flowchart of a task processing method provided according to an embodiment of the present specification, which specifically includes the following steps.

步骤502:接收针对目标虚拟对象的任务分配请求,其中,所述任务分配请求中携带有待分配任务。Step 502: Receive a task assignment request for the target virtual object, wherein the task assignment request carries the task to be assigned.

在实际应用中,本说明书提供的任务处理方法能够应用于目标虚拟对象中的调度模块,该调度模块可以理解为部署在目标虚拟对象中、用于为待分配任务分配一个vCPU的模块;例如,该调度模块可以为调度器。In practical applications, the task processing method provided in this specification can be applied to a scheduling module in a target virtual object, and the scheduling module can be understood as a module deployed in the target virtual object for allocating a vCPU to a task to be allocated; for example, The scheduling module may be a scheduler.

其中,该虚拟单元可以理解为通过硬件虚拟化技术生成的、用于执行待分配任务的虚拟机单元,例如,该虚拟单元可以理解为虚拟机、安全容器、云服务器等,本说明书对此不作具体限定;在本说明书提供的实施例中,以该目标虚拟对象为虚拟机为例对该任务处理方法进行说明。Wherein, the virtual unit can be understood as a virtual machine unit generated by hardware virtualization technology and used to perform tasks to be assigned. For example, the virtual unit can be understood as a virtual machine, a security container, a cloud server, etc., which is not described in this specification. Specific limitations; in the embodiments provided in this specification, the task processing method is described by taking the target virtual object as a virtual machine as an example.

该任务分配请求可以理解为指示调度器为待分配任务分配一个vCPU进行任务执行的请求。The task allocation request may be understood as a request for instructing the scheduler to allocate a vCPU for the task to be allocated to execute the task.

该待分配任务可以理解为需要vCPU运行执行的任务,例如,该待分配任务包括但不限于待执行指令、待执行线程等。其中,该待执行指令、以及该待执行线程可以根据实际应用场景进行设置,本说明书对此不作具体限定。例如,该待执行线程包括但不限于实现ping-pong收发包操作的线程。该待执行指令可以为实现ping-pong收发包操作过程中所需要执行的指令等。The to-be-allocated task may be understood as a task that requires the vCPU to run and execute. For example, the to-be-allocated task includes but is not limited to an instruction to be executed, a thread to be executed, and the like. The instruction to be executed and the thread to be executed may be set according to actual application scenarios, which are not specifically limited in this specification. For example, the thread to be executed includes, but is not limited to, a thread that implements the ping-pong packet sending and receiving operation. The to-be-executed instruction may be an instruction that needs to be executed in the process of implementing the ping-pong packet sending and receiving operation, and the like.

具体地,目标虚拟对象内的调度器能够接收到针对该目标虚拟对象的任务分配请求,其中,针对该目标虚拟对象的任务分配请求可以理解为该目标虚拟对象需要执行的任务分配请求。Specifically, the scheduler in the target virtual object can receive a task allocation request for the target virtual object, where the task allocation request for the target virtual object can be understood as a task allocation request that the target virtual object needs to execute.

下面以本说明书提供的任务处理方法在将收发包线程分配至vCPU场景下的应用为例,对该任务处理方法进行说明,其中,该目标虚拟对象为目标虚拟机,待分配任务为收发包线程,该任务分配请求为收发包线程分配操作对应vCPU的请求,该收发包线程可以为实现ping-pong收发包操作的线程。The task processing method is described below by taking the application of the task processing method provided in this specification in the scenario of allocating a packet sending and receiving thread to a vCPU as an example, wherein the target virtual object is a target virtual machine, and the task to be allocated is a packet sending and receiving thread , the task allocation request is a request for a packet sending and receiving thread to allocate an operation corresponding to the vCPU, and the packet sending and receiving thread may be a thread that implements a ping-pong sending and receiving operation of packets.

基于此,该目标虚拟机的调度器能够接收到将收发包线程分配至vCPU进行执行的任务分配请求,该任务分配请求中携带有收发包线程。Based on this, the scheduler of the target virtual machine can receive a task allocation request for allocating the packet sending and receiving thread to the vCPU for execution, and the task allocation request carries the packet sending and receiving thread.

步骤504:基于所述任务分配请求,确定所述目标虚拟对象对应的至少两个vCPU,并从所述至少两个vCPU中确定初始vCPU,其中,所述初始vCPU的当前资源占用信息大于其他vCPU。Step 504: Based on the task allocation request, determine at least two vCPUs corresponding to the target virtual object, and determine an initial vCPU from the at least two vCPUs, wherein the current resource occupancy information of the initial vCPU is larger than other vCPUs .

其中,该当前资源占用信息可以理解为表征vCPU当前计算资源被占用情况的信息,例如,该当前资源占用信息可以为vCPU的占用率。初始vCPU可以理解为该至少两个vCPU中的资源占用率最高的vCPU。该其他vCPU可以理解为至少两个vCPU中出该初始vCPU之外的其他vCPU。Wherein, the current resource occupancy information may be understood as information representing the current occupancy of computing resources of the vCPU, for example, the current resource occupancy information may be the occupancy rate of the vCPU. The initial vCPU may be understood as the vCPU with the highest resource usage among the at least two vCPUs. The other vCPU may be understood as other vCPUs other than the initial vCPU among the at least two vCPUs.

具体地,该调度器在接收到任务分配请求之后,能够基于该任务分配请求,确定该目标虚拟对象对应的至少两个vCPU,之后,该调度器从该至少两个vCPU中确定当前资源占用信息大于其他vCPU的初始vCPU。Specifically, after receiving the task allocation request, the scheduler can determine at least two vCPUs corresponding to the target virtual object based on the task allocation request, and then the scheduler determines current resource occupation information from the at least two vCPUs An initial vCPU larger than the other vCPUs.

沿用上例,该调度器在接收到将收发包线程分配vCPU进行运行执行的请求之后,能够基于该请求确定该虚拟机对应的至少两个vCPU,比如,vCPU1、vCPU2、vCPU3。Following the above example, after receiving a request for allocating a vCPU for running and executing a packet sending and receiving thread, the scheduler can determine at least two vCPUs corresponding to the virtual machine based on the request, for example, vCPU1, vCPU2, and vCPU3.

之后,该调度器确定每个vCPU的占用率,并从vCPU1、vCPU2、vCPU3中确定占用率最高的vCPU;比如vCPU1的占用率为65%、vCPU2的占用率为50%、vCPU3的占用率为0%,该调度器从vCPU1、vCPU2、vCPU3中选择占用率最高的vCPU1。After that, the scheduler determines the occupancy rate of each vCPU, and determines the vCPU with the highest occupancy rate from vCPU1, vCPU2, and vCPU3; for example, the occupancy rate of vCPU1 is 65%, the occupancy rate of vCPU2 is 50%, and the occupancy rate of vCPU3 is 50%. 0%, the scheduler selects vCPU1 with the highest occupancy rate from vCPU1, vCPU2, and vCPU3.

在本说明书提供的实施例中,该调度器可以通过排序的方式从至少两个vCPU中确定初始vCPU,从而保证后续能够基于当前资源占用信息最高的vCPU处理该待分配任务,从而避免了由于空闲vCPU频繁陷出到宿主机,所导致的CPU调度损耗的问题,进一步降低了物理CPU调度损耗。具体地,所述从所述至少两个vCPU中确定初始vCPU,包括:In the embodiments provided in this specification, the scheduler can determine the initial vCPU from at least two vCPUs in a sorting manner, so as to ensure that the to-be-allocated task can be subsequently processed based on the vCPU with the highest current resource occupancy information, thereby avoiding idleness The problem of CPU scheduling loss caused by the frequent trapping of vCPUs to the host machine further reduces the physical CPU scheduling loss. Specifically, the determining the initial vCPU from the at least two vCPUs includes:

确定每个vCPU的当前资源占用信息;Determine the current resource occupancy information of each vCPU;

基于所述当前资源占用信息对所述每个vCPU进行降序排序,获得所述每个vCPU的降序排序结果;Sort each vCPU in descending order based on the current resource occupancy information, and obtain a descending sorting result of each vCPU;

将所述降序排序结果中第一位置的vCPU,确定为初始vCPU。The vCPU at the first position in the descending sorting result is determined as the initial vCPU.

沿用上例,调度器确定每个vCPU的占用率,比如vCPU1的占用率为75%、vCPU2的占用率为50%、vCPU3的占用率为0%;并基于该占用率对vCPU1、vCPU2、vCPU3降序排序,获得vCPU对应的降序排序结果,比如vCPU1→vCPU2→vCPU3。Following the above example, the scheduler determines the occupancy rate of each vCPU, for example, the occupancy rate of vCPU1 is 75%, the occupancy rate of vCPU2 is 50%, and the occupancy rate of vCPU3 is 0%; Sort in descending order to obtain the descending sorting result corresponding to vCPU, such as vCPU1→vCPU2→vCPU3.

之后,调度器从该降序排序结果中选择排列在第一位置的vCPU1,作为占用率最高的vCPU。After that, the scheduler selects the vCPU1 in the first position from the descending sorting result as the vCPU with the highest occupancy rate.

在本说明书提供的一实施例中,为了节省调度开销,本说明书提供的任务处理方法,会从所有vCPU中选择最繁忙的一个vCPU,后续能够基于该选择的vCPU执行任务。同时,由于vCPU在不同层级共享的Cache(缓存)以及NUMA导致的内存访问速率不同,调度器可能分为相同CPU core、相同CPU package、相同NUMA、所有CPU等不同层级,每个层级里的CPU就称为一个调度域。基于此,本说明书提供的任务处理方法统一还能够兼顾考虑到任务的运行性能,通过调度域选择策略,从同一NUMA的CPU中选择最繁忙的CPU;尽可能避免把线程调度到与以前所在NUMA不同的其他NUMA上去,而是将线程调度到与以前所在NUMA上,从而保证该线程的执行效率。其中,该调度域选择策略可以为任意一种能够实现从一组CPU中选择最繁忙的CPU的策略,具体选择哪些CPU,也就是调度域选择策略不影响本方案,本说明书对此不作具体限定。其中,本实施例提供的一种调度域选择策略如下。In an embodiment provided in this specification, in order to save scheduling overhead, the task processing method provided in this specification will select the busiest vCPU from all vCPUs, and subsequently execute tasks based on the selected vCPU. At the same time, due to the different memory access rates caused by the Cache (cache) and NUMA shared by vCPUs at different levels, the scheduler may be divided into different levels such as the same CPU core, the same CPU package, the same NUMA, and all CPUs. The CPUs in each level is called a scheduling domain. Based on this, the unified task processing method provided in this specification can also take into account the running performance of the task. Through the scheduling domain selection strategy, the busiest CPU is selected from the CPUs of the same NUMA; try to avoid scheduling threads to the same NUMA as possible. Instead of going up to other NUMA, the thread is scheduled to the NUMA where it was before, so as to ensure the execution efficiency of the thread. The scheduling domain selection strategy can be any strategy that can select the busiest CPU from a group of CPUs. Which CPUs are selected specifically, that is, the scheduling domain selection strategy does not affect this solution, which is not specifically limited in this specification. . Among them, a scheduling domain selection strategy provided by this embodiment is as follows.

所述从所述至少两个vCPU中确定初始vCPU,包括:The determining an initial vCPU from the at least two vCPUs includes:

确定每个vCPU对应的vCPU集合,其中,所述vCPU集合中包含同一类型的vCPU;determining a vCPU set corresponding to each vCPU, wherein the vCPU set includes vCPUs of the same type;

基于历史任务执行信息,确定与所述待分配任务的任务类型对应的目标vCPU集合;Determine the target vCPU set corresponding to the task type of the to-be-allocated task based on the historical task execution information;

从所述目标vCPU集合中确定初始vCPU,其中,所述初始vCPU的当前资源占用信息,大于所述目标vCPU集合中的其他vCPU。An initial vCPU is determined from the target vCPU set, wherein the current resource occupation information of the initial vCPU is greater than other vCPUs in the target vCPU set.

其中,该vCPU集合可以理解为调度域,该同一类型的vCPU可以理解为共享同一Cache以及NUMA的vCPU。The vCPU set can be understood as a scheduling domain, and the same type of vCPUs can be understood as vCPUs sharing the same Cache and NUMA.

该历史任务执行信息可以理解为至少两个vCPU在执行历史任务过程中所产生的数据。该历史任务执行信息中包含每个vCPU历史执行的任务所对应的任务类型。The historical task execution information may be understood as data generated by at least two vCPUs in the process of executing the historical task. The historical task execution information includes the task type corresponding to the historically executed task of each vCPU.

该任务类型可以理解为表征一个待分配任务的类型的信息,例如,在待分配任务为收发包线程的情况下,该任务类型可以为收发包类型。The task type can be understood as information representing the type of a task to be allocated. For example, in the case that the task to be allocated is a thread for sending and receiving packets, the task type can be a type for sending and receiving packets.

具体地,调度器确定每个vCPU对应的vCPU集合,并确定每个vCPU在历史执行任务过程中产生的历史任务执行信息;基于该历史任务执行信息,确定与待分配任务的任务类型对应的目标vCPU集合;并从该目标vCPU集合中确定初始vCPU,其中,所述初始vCPU的当前资源占用信息,大于所述目标vCPU集合中的其他vCPU。需要说明的是,针对本说明书实施例中确定初始vCPU的解释,可以参见上述实施例中对应或相应的内容,本实施例在此不过多赘述。Specifically, the scheduler determines the vCPU set corresponding to each vCPU, and determines the historical task execution information generated by each vCPU during the historical task execution process; based on the historical task execution information, determines the target corresponding to the task type of the task to be allocated. vCPU set; and determining an initial vCPU from the target vCPU set, wherein the current resource occupation information of the initial vCPU is greater than other vCPUs in the target vCPU set. It should be noted that, for the explanation of the determination of the initial vCPU in the embodiment of this specification, reference may be made to the corresponding or corresponding content in the foregoing embodiment, and details are not described here in this embodiment.

沿用上例,该调度器确定每个vCPU所属的调度域,并确定根据每个vCPU历史执行线程过程中所产生的历史执行记录;基于该历史执行记录,确定历史执行过收发包线程的vCPU,以及该vCPU所属的调度域A;并从该调度域A中选择占用率最高的vCPU,也即是,从该调度域A中选择最忙的vCPU。Following the above example, the scheduler determines the scheduling domain to which each vCPU belongs, and determines the historical execution records generated in the process of executing threads according to the history of each vCPU; and the scheduling domain A to which the vCPU belongs; and the vCPU with the highest occupancy rate is selected from the scheduling domain A, that is, the busiest vCPU is selected from the scheduling domain A.

步骤506:在确定所述初始vCPU的当前资源占用信息,满足所述待分配任务的任务处理条件的情况下,确定所述初始vCPU为目标vCPU。Step 506: In the case that the current resource occupancy information of the initial vCPU is determined and the task processing condition of the to-be-allocated task is satisfied, determine the initial vCPU as the target vCPU.

其中,该目标vCPU以理解为该待分配任务分配的、能够对该待分配任务进行任务处理的vCPU。The target vCPU refers to the vCPU allocated to the task to be allocated and capable of performing task processing on the task to be allocated.

该待分配任务的任务处理条件可以根据实际应用场景进行设置,本说明书对此不作具体限定,例如,该待分配任务的任务处理条件可以为,该初始vCPU需要是未负载的vCPU,该初始vCPU的占用率需要小于预设阈值(例如70%)等。The task processing condition of the to-be-allocated task may be set according to the actual application scenario, which is not specifically limited in this specification. For example, the task processing condition of the to-be-allocated task may be that the initial vCPU needs to be an unloaded vCPU, and the initial vCPU The occupancy rate needs to be less than a preset threshold (eg 70%), etc.

具体地,在本说明书提供的一实施例中,所述在确定所述初始vCPU的当前资源占用信息,满足所述待分配任务的任务处理条件的情况下,确定所述初始vCPU为目标vCPU,包括:Specifically, in an embodiment provided in this specification, the initial vCPU is determined as the target vCPU under the condition that the current resource occupation information of the initial vCPU is determined and the task processing condition of the to-be-allocated task is satisfied, include:

在确定所述初始vCPU的当前资源占用信息,满足预设负载条件的情况下,将所述初始vCPU确定为目标vCPU。When the current resource occupation information of the initial vCPU is determined and the preset load condition is satisfied, the initial vCPU is determined as the target vCPU.

其中,该预设负载条件可以理解为该初始vCPU的占用率小于预设占用率阈值。Wherein, the preset load condition can be understood as the occupancy rate of the initial vCPU is less than the preset occupancy rate threshold.

沿用上例,调度器在从虚拟机的多个vCPU中,确定占用率最高的vCPU之后,为了保证收发包线程的顺利执行,会确定该占用率最高的vCPU是否存在负载的情况,具体地,该调度器在确定占用率最高的vCPU,确定该占用率是否小于预设占用率阈值(70%),若是,则确定该vCPU并未负载,还能够顺利的执行该收发包线程,基于此,将该占用率最高的vCPU作为执行该收发包线程的vCPU。其中,该预设占用率阈值可以根据实际应用场景进行设置,本说明书对此不作具体限定。Following the above example, after determining the vCPU with the highest occupancy rate from the multiple vCPUs of the virtual machine, in order to ensure the smooth execution of the packet sending and receiving thread, the scheduler will determine whether the vCPU with the highest occupancy rate is under load. Specifically, When determining the vCPU with the highest occupancy rate, the scheduler determines whether the occupancy rate is less than the preset occupancy rate threshold (70%). If so, it is determined that the vCPU is not loaded and the packet sending and receiving thread can be successfully executed. Based on this, The vCPU with the highest occupancy rate is used as the vCPU that executes the packet sending and receiving thread. The preset occupancy rate threshold may be set according to an actual application scenario, which is not specifically limited in this specification.

进一步地,在本说明书提供的实施中,若该占用率最高的vCPU,其对应的占用率大于等于预设占用率阈值,则确定该vCPU处于负载状态,无法顺利执行该收发包线程,则重新确定一个新的vCPU,并继续判断新的vCPU的占用率是否小于预设占用率阈值,直至找到一个占用率小于预设占用率阈值,且占用率相对较高的vCPU,从而在保证待处理任务顺利执行的同时,也能够避免了由于空闲vCPU频繁陷出到宿主机,所导致的CPU调度损耗的问题,进一步降低了物理CPU调度损耗,具体地,所述从所述至少两个vCPU中确定初始vCPU之后,还包括:Further, in the implementation provided in this specification, if the corresponding occupancy rate of the vCPU with the highest occupancy rate is greater than or equal to the preset occupancy rate threshold, it is determined that the vCPU is in a load state and cannot successfully execute the packet sending and receiving thread, then restart the process. Determine a new vCPU, and continue to judge whether the occupancy rate of the new vCPU is less than the preset occupancy rate threshold, until a vCPU with a occupancy rate less than the preset occupancy rate threshold and a relatively high occupancy rate is found, so as to ensure the pending tasks While executing smoothly, it can also avoid the problem of CPU scheduling loss caused by the frequent trapping of idle vCPUs to the host, and further reduce the physical CPU scheduling loss. Specifically, the determination from the at least two vCPUs After the initial vCPU, also includes:

在确定所述初始vCPU的当前资源占用信息,不满足预设负载条件的情况下,从所述其他vCPU中确定候选vCPU,其中,所述候选vCPU的当前资源占用信息满足所述预设负载条件;In the case where the current resource occupancy information of the initial vCPU is determined and does not meet the preset load condition, a candidate vCPU is determined from the other vCPUs, wherein the current resource occupancy information of the candidate vCPU satisfies the preset load condition ;

从所述候选vCPU中确定目标vCPU,其中,所述目标vCPU的当前资源占用信息,大于所述候选vCPU中除所述目标vCPU之外的其他候选vCPU。A target vCPU is determined from the candidate vCPUs, wherein the current resource occupation information of the target vCPU is greater than other candidate vCPUs in the candidate vCPUs except the target vCPU.

其中,候选vCPU可以理解为其他vCPU中占用率小于预设占用率阈值的vCPU。The candidate vCPU may be understood as a vCPU whose occupancy rate is less than the preset occupancy rate threshold among other vCPUs.

沿用上例,调度器在确定当前占用率最高的vCPU1,且确定该vCPU1的占用率(75%)大于等于预设占用率阈值(70%),处于负载状态的情况下,该调度器能够从vCPU2、vCPU3中确定占有率小于预设占用率阈值的vCPU,由于vCPU2的占用率为50%、vCPU3的占用率为0%,因此,调度器能够选择vCPU2、vCPU3,并从vCPU2、vCPU3中确定占用率最高的vCPU,也即是vCPU2。之后该调度器将该vCPU2作为执行该收发包线程的vCPU。Following the above example, when the scheduler determines the vCPU1 with the highest current occupancy rate, and determines that the occupancy rate (75%) of this vCPU1 is greater than or equal to the preset occupancy rate threshold (70%), in the load state, the scheduler can start from Among vCPU2 and vCPU3, the vCPU whose occupancy rate is less than the preset occupancy rate threshold is determined. 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 from vCPU2 and vCPU3. The vCPU with the highest utilization rate is vCPU2. After that, the scheduler uses the vCPU2 as the vCPU that executes the packet sending and receiving thread.

在本说明书提供的实施例中,为了保证该待分配任务的顺利执行,该调度器从至少两个vCPU中确定当前资源占用信息大于其他vCPU的初始vCPU之后,还需要确定该初始vCPU的剩余计算资源是否能够顺利运行该待分配任务,从而保证该待分配任务的顺利执行,具体地,所述在确定所述初始vCPU的当前资源占用信息,满足所述待分配任务的任务处理条件的情况下,确定所述初始vCPU为目标vCPU,包括:In the embodiments provided in this specification, in order to ensure the smooth execution of the to-be-allocated task, after the scheduler determines from at least two vCPUs that the current resource occupancy information is greater than the initial vCPUs of other vCPUs, it also needs to determine the remaining calculation of the initial vCPUs Whether the resource can run the to-be-allocated task smoothly, so as to ensure the smooth execution of the to-be-allocated task, specifically, when determining the current resource occupancy information of the initial vCPU and satisfying the task processing conditions of the to-be-allocated task , determine the initial vCPU as the target vCPU, including:

确定所述待分配任务的资源占用信息;determining the resource occupation information of the to-be-allocated task;

基于所述初始vCPU的当前资源占用信息,确定所述初始vCPU对应的剩余资源信息;Determine remaining resource information corresponding to the initial vCPU based on the current resource occupation information of the initial vCPU;

在所述剩余资源信息大于等于所述资源占用信息的情况下,将所述初始vCPU确定为目标vCPU。When the remaining resource information is greater than or equal to the resource occupation information, the initial vCPU is determined as the target vCPU.

其中,该待分配任务的资源占用信息可以理解为vCPU运行执行该待分配任务所需要的计算资源。例如,在待分配任务收发包线程的情况下,该资源占用信息可以理解为该vCPU执行该收发包线程所需要的占用率。The resource occupation information of the to-be-allocated task may be understood as computing resources required by the vCPU to run and execute the to-be-allocated task. For example, in the case of a thread for sending and receiving packets of a task to be allocated, the resource occupancy information may be understood as the occupancy rate required by the vCPU to execute the thread for sending and receiving packets.

该初始vCPU对应的剩余资源信息可以理解为,表征该初始vCPU当前剩余的、能够执行该待分配任务的计算资源的信息,例如,剩余资源信息可以为剩余资源占用率;在初始vCPU对应的占用率为55%的情况下,该初始vCPU的剩余资源占用率可以为45%。The remaining resource information corresponding to the initial vCPU can be understood as the information representing the computing resources currently remaining in the initial vCPU and capable of executing the task to be allocated. For example, the remaining resource information can be the remaining resource occupancy rate; the occupancy rate corresponding to the initial vCPU In the case of 55%, the remaining resource occupancy rate of the initial vCPU can be 45%.

具体地,该调度器在从至少两个vCPU中确定初始vCPU之后,能够确定处理该待分配任务所需要的资源占用信息,并基于该初始vCPU的当前资源占用信息,确定初始vCPU对应的剩余资源信息。Specifically, after determining the initial vCPU from the at least two vCPUs, the scheduler can determine the resource occupancy information required to process the task to be allocated, and determine the remaining resources corresponding to the initial vCPU based on the current resource occupancy information of the initial vCPU information.

在确定该剩余资源信息大于等于资源占用信息的情况下,则确定该初始vCPU能够对顺利的执行该待分配任务,因此,将该初始vCPU确定为目标vCPU。When it is determined that 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-allocated task, and therefore, the initial vCPU is determined as the target vCPU.

沿用上例,调度器在确定占用率最高的vCPU之后,能够确定执行该收发包线程所需要的资源占用率为30%,并基于该vCPU的当前占用率确定该vCPU所剩余的计算资源剩余率为50%,在确定该计算资源剩余率35%大于等于该资源占用率15%的情况下,该调度器将当前占用率最高的vCPU,作为处理该收发包线程的vCPU。Following the above example, after determining the vCPU with the highest occupancy rate, the scheduler can determine that the resource occupancy rate required to execute the packet sending and receiving thread is 30%, and determine the remaining computing resource remaining rate of the vCPU based on the current occupancy rate of the vCPU. is 50%, and when it is determined that the remaining computing resource rate of 35% is greater than or equal to the resource occupancy rate of 15%, the scheduler uses the vCPU with the highest current occupancy rate as the vCPU for processing the packet sending and receiving thread.

进一步地,在本说明书提供的实施例中,在vCPU的计算资源剩余率小于该待分配任务的资源占用率的情况下,为了保证待分配任务的顺利执行,会重新选择一个vCPU,并继续执行计算资源剩余率与资源占用率的比较,直至找到一个计算资源剩余率大于等于资源占用率的vCPU,具体地,所述基于所述初始vCPU的当前资源占用信息,确定所述初始vCPU对应的剩余资源信息之后,还包括:Further, in the embodiment provided in this specification, in the case that the residual rate of computing resources of the vCPU is less than the resource occupancy rate of the task to be allocated, in order to ensure the smooth execution of the task to be allocated, a vCPU will be re-selected, and the execution will continue. Comparing the residual rate of computing resources with the resource occupancy rate, until a vCPU whose residual rate of computing resources is greater than or equal to the resource occupancy rate is found, specifically, determining the residual rate corresponding to the initial vCPU based on the current resource occupancy information of the initial vCPU After the resource information, it also includes:

在所述剩余资源信息小于所述资源占用信息的情况下,继续执行从所述至少两个vCPU中确定初始vCPU的步骤,直至所述剩余资源信息大于等于所述资源占用信息。In the case that the remaining resource information is smaller than the resource occupation information, the step of determining an 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.

其中,针对本实施例中继续执行从至少两个vCPU中确定初始vCPU的解释,可以参见上述实施例中对应或相应的内容,本说明书对此不作过多赘述。Wherein, for the explanation of continuing to determine the initial vCPU from at least two vCPUs in this embodiment, reference may be made to the corresponding or corresponding content in the foregoing embodiment, which will not be repeated in this specification.

沿用上例,其中,该vCPU1的计算资源剩余率为25%,该收发包线程对应的资源占用率为30%,基于此,该调度器将vCPU1的计算资源剩余率,与执行收发包线程所需要的资源占用率比较,从而确定该计算资源剩余率25%小于资源占用率30%,之后,该调度器从vCPU2、vCPU3中确定占用率最高的vCPU,也即是vCPU2。之后该调度器确定该vCPU2计算资源剩余率为50%,将该计算资源剩余率50%与执行收发包线程所需要的资源占用率30%进行比较,确定该计算资源剩余率50%大于资源占用率30%,从而将该vCPU2确定为执行该收发包线程的vCPU。Following the above example, the remaining computing resource rate of the vCPU1 is 25%, and the resource occupancy rate corresponding to the packet sending and receiving thread is 30%. The required resource occupancy ratio is compared to determine that the remaining computing resource ratio of 25% is less than the resource occupancy ratio of 30%. After that, the scheduler determines the vCPU with the highest occupancy ratio from vCPU2 and vCPU3, that is, vCPU2. After that, the scheduler determines that the remaining rate of computing resources of the vCPU2 is 50%, and compares the remaining rate of 50% of computing resources with the resource occupancy rate of 30% required for executing the packet sending and receiving thread, and determines that the remaining rate of computing resources of 50% is greater than the resource occupancy rate. The rate is 30%, so that the vCPU2 is determined as the vCPU that executes the packet sending and receiving thread.

步骤508:将所述待分配任务分配至所述目标vCPU进行任务执行。Step 508: Allocate the to-be-allocated task to the target vCPU for task execution.

沿用上例,将这个可执行的收发包线程调度到选定的vCPU2上执行。Following the above example, schedule this executable packet sending and receiving thread to the selected vCPU2 for execution.

在本说明书提供的实施例中,所述将所述待分配任务分配至所述目标vCPU进行任务执行,包括:In the embodiments provided in this specification, allocating the to-be-allocated task to the target vCPU for task execution includes:

将所述待分配任务分配至所述目标vCPU对应的待执行任务队列,在所述待执行任务队列中进行任务执行。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.

其中,该待执行任务队列可以理解为存储目标vCPU需要执行的待分配任务的队列。The to-be-executed task queue may be understood as a queue for storing to-be-allocated tasks to be executed by the target vCPU.

沿用上例,该虚拟机中的vCPU具有对应的任务队列,该任务队列中存储有该vCPU需要执行的待执行任务。基于此,该调度器在确定执行该收发包线程的vCPU之后,能够将该收发包线程发送至该vCPU对应的任务队列中,该vCPU对该任务队列中的收发包线程进行执行。Following the above example, the vCPU in the virtual machine has a corresponding task queue, and the task queue stores the tasks to be executed that the vCPU needs to execute. Based on this, after determining the vCPU that executes the packet sending and receiving thread, the scheduler can send the packet sending and receiving thread to a task queue corresponding to the vCPU, and the vCPU executes the packet sending and receiving thread in the task queue.

在本说明书提供的实施例中,该虚拟机中的调度器,在确定vCPU上没有别的任务等待调度运行,那么则确定该vCPU处于空闲状态,并对该vCPU进行陷出操作,从而避免了没有任务执行的vCPU,对物理CPU的计算资源的浪费,具体地,所述将所述待分配任务分配至所述目标vCPU进行任务执行之后,还包括:In the embodiment provided in this specification, when the scheduler in the virtual machine determines that there is no other task waiting to be scheduled and running on the vCPU, it determines that the vCPU is in an idle state, and performs a trapping operation on the vCPU, thereby avoiding The vCPU without task execution wastes the computing resources of the physical CPU. Specifically, after allocating the to-be-allocated task to the target vCPU for task execution, the method further includes:

在确定所述目标vCPU对应的待执行任务队列为空的情况下,将所述目标vCPU的当前运行状态调整为空闲状态,并释放所述目标vCPU对应的物理计算资源。When it is determined that the queue of tasks 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 resources corresponding to the target vCPU are released.

其中,该物理计算资源包括但不限于该目标vCPU对应的物理vCPU计算资源、目标vCPU对应的物理存储资源等等。The physical computing resources include, but are not limited to, physical vCPU computing resources corresponding to the target vCPU, physical storage resources corresponding to the target vCPU, and the like.

具体地,该调度器在确定该待执行任务队列中不存在等待执行的待分配任务时,则将该目标vCPU的当前运行状态调整为空闲状态;在实际应用中,每次任务调度都会经过调度器,因此,在任务经过调度器进行调度时,该调度器进行一次判断即可确定该目标vCPU当前具有等待执行任务。Specifically, when the scheduler determines that there is no to-be-allocated task waiting to be executed in the to-be-executed task queue, it adjusts the current running state of the target vCPU to an idle state; in practical applications, each task scheduling will be scheduled Therefore, when a task is scheduled by the scheduler, the scheduler can determine that the target vCPU currently has tasks waiting to be executed by making a judgment.

之后该调度器释放所述目标vCPU对应的物理计算资源,其中,该释放目标vCPU对应的物理计算资源,可以理解为对该目标vCPU执行陷出操作;对vCPU执行陷出操作的解释可参见上述实施例中对应或相应的内容,或者可以参考任意一种实现对vCPU执行陷出操作的方式,本实施例对此不作过多赘述。Afterwards, the scheduler releases the physical computing resources corresponding to the target vCPU, wherein the releasing of the physical computing resources corresponding to the target vCPU can be understood as performing a trapping operation on the target vCPU; for the explanation of performing a trapping operation on the vCPU, please refer to the above Corresponding or corresponding content in the embodiment, or any method for implementing the trapping operation on the vCPU may be referred to, and this embodiment will not describe it in detail in this embodiment.

进一步的,在本说明书提供的一实施例中,本说明书提供的任务处理方法的调度思路是,尽可能让等待执行的线程集中在少数几个CPU上运行,从而除了上述少数几个CPU之外的其他vCPU较少的执行任务,实现该其他vCPU一种处于空闲状态,从而进一步达到调度开销的目的。但是,该调度器在当前针对该目标虚拟对象的任务分配请求较多的情况下,为了保证顺利的对任务分配请求进行处理,避免目标虚拟对象出现负载的情况下,该调度器会将空闲状态的vCPU调整为运行状态,并通过该vCPU执行该任务分配请求中携带的待分配任务,从而避免目标虚拟对象出现负载的问题,具体的,所述接收针对目标虚拟对象的任务分配请求之后,还包括:Further, in an embodiment provided in this specification, the scheduling idea of the task processing method provided in this specification is to make the threads waiting for execution run on a few CPUs as much as possible, so that in addition to the above few CPUs, The other vCPUs perform fewer tasks, so that one of the other vCPUs is in an idle state, thereby further achieving the purpose of scheduling overhead. However, when the scheduler currently has many task allocation requests for the target virtual object, in order to ensure smooth processing of the task allocation requests and avoid the load on the target virtual object, the scheduler will put the idle state The vCPU is adjusted to the running state, and the task to be allocated carried in the task allocation request is executed by the vCPU, so as to avoid the problem of load on the target virtual object. Specifically, after receiving the task allocation request for the target virtual object, also include:

在确定所述任务分配请求的属性信息满足vCPU状态调整条件的情况下,确定所述目标虚拟对象对应的至少两个vCPU;In the case of determining that the attribute information of the task allocation request satisfies the vCPU state adjustment condition, determine at least two vCPUs corresponding to the target virtual object;

将所述至少两个vCPU中、当前运行状态为空闲状态的vCPU,确定为目标vCPU;Determining the vCPU whose current running state is in the idle state among the at least two vCPUs as the target vCPU;

将所述目标vCPU的当前运行状态调整为运行状态,并将所述待分配任务分配至所述目标vCPU进行任务执行。The current running state of the target vCPU is adjusted to the running state, and the to-be-allocated task is allocated to the target vCPU for task execution.

其中,该任务分配请求的属性信息可以理解为该任务分配请求的数量信息;对应的,该属性信息满足vCPU状态调整条件可以理解为,该任务分配请求的数量信息大于预设数量阈值;该预设数量阈值可以根据实际应用场景进行设置,例如,1000个、10000个等等。The attribute information of the task allocation request may be understood as the quantity information of the task allocation request; correspondingly, if the attribute information satisfies the vCPU state adjustment condition, it may be understood that the quantity information of the task allocation request is greater than the preset quantity threshold; The number threshold can be set according to the actual application scenario, for example, 1000, 10000 and so on.

其中,将目标vCPU的当前运行状态调整为运行状态,可以理解为对该目标vCPU执行陷入操作;而对vCPU执行陷入操作的解释,可以参见上述实施例中对应或相应的内容,或者可以参考任意一种实现对vCPU执行陷入操作的方式,本说明书对此不作过多赘述。Wherein, adjusting the current running state of the target vCPU to the running state can be understood as performing a trapping operation on the target vCPU; and for the explanation of the trapping operation performed by the vCPU, refer to the corresponding or corresponding content in the above embodiment, or refer to any A way to implement the trapping operation on the vCPU, which is not described in detail in this specification.

具体的,调度器能够确定任务分配请求的属性信息,并在确定该任务分配请求的属性信息满足vCPU状态调整条件的情况下,该调度器能够确定目标虚拟对象对应的至少两个vCPU;并将至少两个vCPU中、当前运行状态为空闲状态的vCPU,确定为目标vCPU;然后将目标vCPU的当前运行状态调整为运行状态,并待分配任务分配至目标vCPU进行任务执行。Specifically, the scheduler can determine the attribute information of the task allocation request, and when it is determined that 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 Among at least two vCPUs, a vCPU whose current running state is idle is determined as the target vCPU; then, the current running state of the target vCPU is adjusted to the running state, and the task to be allocated is allocated to the target vCPU for task execution.

沿用上例,该调度器能够确定当前接收到的任务分配请求的请求数量,在实际应用中,每次任务调度都会经过调度器,因此,在任务经过调度器进行调度时,该调度器能够确定接收接收到的任务分配请求的数量。基于此,调度器在确定该请求数量大于预设数量阈值的情况下,为了避免虚拟机出现负载的问题,该调度器确定该虚拟机对应的多个vCPU,并从多个vCPU中确定处于空闲状态的vCPU;将该vCPU确定为对请求中携带的收发包线程进行处理的vCPU,并对该vCPU执行陷入操作,使得该vCPU能够运行该收发包线程。Following the above example, the scheduler can determine the number of currently received task allocation requests. In practical applications, each task scheduling will go through the scheduler. Therefore, when a task is scheduled through the scheduler, the scheduler can determine Receives the number of task assignment requests received. Based on this, when the scheduler determines that the number of requests is greater than the preset number threshold, in order to avoid the problem of load on the virtual machine, the scheduler determines multiple vCPUs corresponding to the virtual machine, and determines from the multiple vCPUs that they are idle The vCPU in the state; the vCPU is determined as the vCPU that processes the packet sending and receiving thread carried in the request, and the trapping operation is performed on the vCPU, so that the vCPU can run the packet sending and receiving thread.

本说明书提供的任务处理方法,能够从目标虚拟对象对应的至少两个vCPU中,确定当前资源占用信息大于该至少两个vCPU中其他vCPU的初始vCPU;在确定该初始vCPU的当前资源占用信息,满足待分配任务的任务处理条件的情况下,将该初始vCPU确定为目标vCPU,并通过该目标vCPU执行该待分配任务,从而避免了由于空闲vCPU频繁陷出到宿主机,所导致的CPU调度损耗的问题,进一步降低了物理CPU调度损耗。The task processing method provided in this specification can determine, from at least two vCPUs corresponding to the target virtual object, that the current resource occupancy information is greater than the initial vCPUs of other vCPUs in the at least two vCPUs; when determining the current resource occupancy information of the initial vCPU, When the task processing conditions of the task to be allocated are met, the initial vCPU is determined as the target vCPU, and the target vCPU is used to execute the to-be-allocated task, thereby avoiding CPU scheduling caused by frequent trapping of idle vCPUs to the host. The problem of loss further reduces the physical CPU scheduling loss.

进一步的,本说明书提供的任务处理方法中,Host上的调度器也可以选择该任务处理方法提供的调度策略,该Host上的调度器基于该调度策略也能够达到降低CPU调度开销的效果,但由于Host上的调度器不涉及guest和host两层调度以及虚拟化带来的陷出,因此,该降低CPU调度开销的幅度效果不如虚拟化下那么明显。Further, in the task processing method provided in this specification, the scheduler on the Host can also select the scheduling policy provided by the task processing method, and the scheduler on the Host can also achieve the effect of reducing the CPU scheduling overhead based on the scheduling policy, but Since the scheduler on the Host does not involve the two-layer scheduling of the guest and the host and the traps brought by virtualization, the effect of reducing the CPU scheduling overhead is not as obvious as that under virtualization.

与上述方法实施例相对应,本说明书还提供了任务处理装置实施例,图6示出了本说明书一个实施例提供的一种任务处理装置的结构示意图。如图6所示,该装置包括:Corresponding to the foregoing method embodiments, the present specification also provides an embodiment of a task processing apparatus, and FIG. 6 shows a schematic structural diagram of a task processing apparatus provided by an embodiment of the present specification. As shown in Figure 6, the device includes:

接收模块602,被配置为接收针对目标虚拟对象的任务分配请求,其中,所述任务分配请求中携带有待分配任务;A receiving module 602, configured to receive a task assignment request for the target virtual object, wherein the task assignment request carries a task to be assigned;

第一确定模块604,被配置为基于所述任务分配请求,确定所述目标虚拟对象对应的至少两个vCPU,并从所述至少两个vCPU中确定初始vCPU,其中,所述初始vCPU的当前资源占用信息大于其他vCPU;The first determining module 604 is configured to, based on the task allocation request, determine at least two vCPUs corresponding to the target virtual object, and determine an initial vCPU from the at least two vCPUs, wherein the current value of the initial vCPU is The resource occupancy information is larger than other vCPUs;

第二确定模块606,被配置为在确定所述初始vCPU的当前资源占用信息,满足所述待分配任务的任务处理条件的情况下,确定所述初始vCPU为目标vCPU;The second determination module 606 is configured to determine the initial vCPU as the target vCPU under the condition that the current resource occupation information of the initial vCPU is determined and the task processing condition of the to-be-allocated task is satisfied;

执行模块608,被配置为将所述待分配任务分配至所述目标vCPU进行任务执行。The execution module 608 is configured to allocate the to-be-allocated task to the target vCPU for task execution.

可选地,所述第二确定模块606,还被配置为:Optionally, the second determining module 606 is further configured to:

在确定所述初始vCPU的当前资源占用信息,满足预设负载条件的情况下,将所述初始vCPU确定为目标vCPU。When the current resource occupation information of the initial vCPU is determined and the preset load condition is satisfied, the initial vCPU is determined as the target vCPU.

可选地,所述任务处理装置还包括第三确定模块,被配置为:Optionally, the task processing apparatus further includes a third determination module configured to:

在确定所述初始vCPU的当前资源占用信息,不满足预设负载条件的情况下,从所述其他vCPU中确定候选vCPU,其中,所述候选vCPU的当前资源占用信息满足所述预设负载条件;In the case where the current resource occupancy information of the initial vCPU is determined and does not meet the preset load condition, a candidate vCPU is determined from the other vCPUs, wherein the current resource occupancy information of the candidate vCPU satisfies the preset load condition ;

从所述候选vCPU中确定目标vCPU,其中,所述目标vCPU的当前资源占用信息,大于所述候选vCPU中除所述目标vCPU之外的其他候选vCPU。A target vCPU is determined from the candidate vCPUs, wherein the current resource occupation information of the target vCPU is greater than other candidate vCPUs in the candidate vCPUs except the target vCPU.

可选地,所述第一确定模块604,还被配置为:Optionally, the first determining module 604 is further configured to:

确定每个vCPU对应的vCPU集合,其中,所述vCPU集合中包含同一类型的vCPU;基于历史任务执行信息,确定与所述待分配任务的任务类型对应的目标vCPU集合;Determine a vCPU set corresponding to each vCPU, wherein the vCPU set includes vCPUs of the same type; based on historical task execution information, determine a target vCPU set corresponding to the task type of the to-be-allocated task;

从所述目标vCPU集合中确定初始vCPU,其中,所述初始vCPU的当前资源占用信息,大于所述目标vCPU集合中的其他vCPU。An initial vCPU is determined from the target vCPU set, wherein the current resource occupation information of the initial vCPU is greater than other vCPUs in the target vCPU set.

可选地,所述第一确定模块604,还被配置为:Optionally, the first determining module 604 is further configured to:

确定每个vCPU的当前资源占用信息;Determine the current resource occupancy information of each vCPU;

基于所述当前资源占用信息对所述每个vCPU进行降序排序,获得所述每个vCPU的降序排序结果;Sort each vCPU in descending order based on the current resource occupancy information, and obtain a descending sorting result of each vCPU;

将所述降序排序结果中第一位置的vCPU,确定为初始vCPU。The vCPU at the first position in the descending sorting result is determined as the initial vCPU.

可选地,所述第二确定模块606,还被配置为:Optionally, the second determining module 606 is further configured to:

确定所述待分配任务的资源占用信息;determining the resource occupation information of the to-be-allocated task;

基于所述初始vCPU的当前资源占用信息,确定所述初始vCPU对应的剩余资源信息;Determine remaining resource information corresponding to the initial vCPU based on the current resource occupation information of the initial vCPU;

在所述剩余资源信息大于等于所述资源占用信息的情况下,将所述初始vCPU确定为目标vCPU。When the remaining resource information is greater than or equal to the resource occupation information, the initial vCPU is determined as the target vCPU.

可选地,所述任务处理装置还包括第四确定模块,被配置为:Optionally, the task processing apparatus further includes a fourth determination module configured to:

在所述剩余资源信息小于所述资源占用信息的情况下,继续执行从所述至少两个vCPU中确定初始vCPU的步骤,直至所述剩余资源信息大于等于所述资源占用信息。In the case that the remaining resource information is smaller than the resource occupation information, the step of determining an 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.

可选地,所述执行模块608,还被配置为:Optionally, the execution module 608 is further configured to:

将所述待分配任务分配至所述目标vCPU对应的待执行任务队列,在所述待执行任务队列中进行任务执行。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.

可选地,所述任务处理装置还包括第一状态调整模块,被配置为:Optionally, the task processing apparatus further includes a first state adjustment module configured to:

在确定所述目标vCPU对应的待执行任务队列为空的情况下,将所述目标vCPU的当前运行状态调整为空闲状态,并释放所述目标vCPU对应的物理计算资源。When it is determined that the queue of tasks 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 resources corresponding to the target vCPU are released.

可选地,所述任务处理装置还包括第二状态调整模块,被配置为:Optionally, the task processing apparatus further includes a second state adjustment module configured to:

在确定所述任务分配请求的属性信息满足vCPU状态调整条件的情况下,确定所述目标虚拟对象对应的至少两个vCPU;In the case of determining that the attribute information of the task allocation request satisfies the vCPU state adjustment condition, determine at least two vCPUs corresponding to the target virtual object;

将所述至少两个vCPU中、当前运行状态为空闲状态的vCPU,确定为目标vCPU;Determining the vCPU whose current running state is in the idle state among the at least two vCPUs as the target vCPU;

将所述目标vCPU的当前运行状态调整为运行状态,并将所述待分配任务分配至所述目标vCPU进行任务执行。The current running state of the target vCPU is adjusted to the running state, and the to-be-allocated task is allocated to the target vCPU for task execution.

本说明书提供的任务处理装置,能够从目标虚拟对象对应的至少两个vCPU中,确定当前资源占用信息大于该至少两个vCPU中其他vCPU的初始vCPU;在确定该初始vCPU的当前资源占用信息,满足待分配任务的任务处理条件的情况下,将该初始vCPU确定为目标vCPU,并通过该目标vCPU执行该待分配任务,从而避免了由于空闲vCPU频繁陷出到宿主机,所导致的CPU调度损耗的问题,进一步降低了物理CPU调度损耗。The task processing apparatus provided in this specification can determine, from at least two vCPUs corresponding to the target virtual object, that the current resource occupancy information is greater than the initial vCPUs of other vCPUs in the at least two vCPUs; when determining the current resource occupancy information of the initial vCPU, When the task processing conditions of the task to be allocated are met, the initial vCPU is determined as the target vCPU, and the target vCPU is used to execute the to-be-allocated task, thereby avoiding CPU scheduling caused by frequent trapping of idle vCPUs to the host. The problem of loss further reduces the physical CPU scheduling loss.

上述为本实施例的一种任务处理装置的示意性方案。需要说明的是,该任务处理装置的技术方案与上述的任务处理方法的技术方案属于同一构思,任务处理装置的技术方案未详细描述的细节内容,均可以参见上述任务处理方法的技术方案的描述。The above is a schematic solution of a task processing apparatus according to this embodiment. It should be noted that the technical solution of the task processing device and the technical solution of the above-mentioned task processing method belong to the same concept. For details that are not described in detail in the technical solution of the task processing device, please refer to the description of the technical solution of the above-mentioned task processing method. .

图7示出了根据本说明书一个实施例提供的一种计算设备700的结构框图。该计算设备700的部件包括但不限于存储器710和处理器720。处理器720与存储器710通过总线730相连接,数据库750用于保存数据。FIG. 7 shows a structural block diagram of a computing device 700 provided according to an embodiment of the present specification. Components of the computing device 700 include, but are not limited to, memory 710 and processor 720 . The processor 720 is connected with the memory 710 through the bus 730, and the database 750 is used for storing data.

计算设备700还包括接入设备740,接入设备740使得计算设备700能够经由一个或多个网络760通信。这些网络的示例包括公用交换电话网(PSTN)、局域网(LAN)、广域网(WAN)、个域网(PAN)或诸如因特网的通信网络的组合。接入设备740可以包括有线或无线的任何类型的网络接口(例如,网络接口卡(NIC))中的一个或多个,诸如IEEE802.11无线局域网(WLAN)无线接口、全球微波互联接入(Wi-MAX)接口、以太网接口、通用串行总线(USB)接口、蜂窝网络接口、蓝牙接口、近场通信(NFC)接口,等等。Computing device 700 also includes access device 740 that enables computing device 700 to communicate via one or more networks 760 . Examples of such 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. Access device 740 may include one or more of any type of network interface (eg, network interface card (NIC)), wired or wireless, such as IEEE 802.11 wireless local area network (WLAN) wireless interface, World Interoperability for Microwave Access ( Wi-MAX) interface, Ethernet interface, Universal Serial Bus (USB) interface, cellular network interface, Bluetooth interface, Near Field Communication (NFC) interface, and the like.

在本说明书的一个实施例中,计算设备700的上述部件以及图7中未示出的其他部件也可以彼此相连接,例如通过总线。应当理解,图7所示的计算设备结构框图仅仅是出于示例的目的,而不是对本说明书范围的限制。本领域技术人员可以根据需要,增添或替换其他部件。In one embodiment of the present specification, the above-described components of computing device 700 and other components not shown in FIG. 7 may also be connected to each other, such as through a bus. It should be understood that the structural block diagram of the computing device shown in FIG. 7 is only for the purpose of example, rather than limiting the scope of the present specification. Those skilled in the art can add or replace other components as required.

计算设备700可以是任何类型的静止或移动计算设备,包括移动计算机或移动计算设备(例如,平板计算机、个人数字助理、膝上型计算机、笔记本计算机、上网本等)、移动电话(例如,智能手机)、可佩戴的计算设备(例如,智能手表、智能眼镜等)或其他类型的移动设备,或者诸如台式计算机或PC的静止计算设备。计算设备700还可以是移动式或静止式的服务器。Computing device 700 may be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (eg, tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (eg, smart phones) ), wearable computing devices (eg, smart watches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. Computing device 700 may also be a mobile or stationary server.

其中,处理器720用于执行如下计算机可执行指令,该计算机可执行指令被处理器720执行时实现上述任务处理方法的步骤。The processor 720 is configured to execute the following computer-executable instructions, and when the computer-executable instructions are executed by the processor 720, implement the steps of the above task processing method.

上述为本实施例的一种计算设备的示意性方案。需要说明的是,该计算设备的技术方案与上述的任务处理方法的技术方案属于同一构思,计算设备的技术方案未详细描述的细节内容,均可以参见上述任务处理方法的技术方案的描述。The above is a schematic solution of a computing device according to this embodiment. It should be noted that the technical solution of the computing device and the technical solution of the above-mentioned task processing method belong to the same concept. For details not described in detail in the technical solution of the computing device, refer to the description of the technical solution of the above-mentioned task processing method.

本说明书一实施例还提供一种计算机可读存储介质,其存储有计算机可执行指令,该计算机可执行指令被处理器执行时实现上述任务处理方法的步骤。An embodiment of the present specification further provides a computer-readable storage medium, which stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, implements the steps of the above task processing method.

上述为本实施例的一种计算机可读存储介质的示意性方案。需要说明的是,该存储介质的技术方案与上述的任务处理方法的技术方案属于同一构思,存储介质的技术方案未详细描述的细节内容,均可以参见上述任务处理方法的技术方案的描述。The above is a schematic solution of a computer-readable storage medium of this embodiment. It should be noted that the technical solution of the storage medium and the technical solution of the above-mentioned task processing method belong to the same concept, and the details not described in detail in the technical solution of the storage medium can be referred to the description of the technical solution of the above-mentioned task processing method.

本说明书一实施例还提供一种计算机程序,其中,当所述计算机程序在计算机中执行时,令计算机执行上述任务处理方法的步骤。An embodiment of the present specification further provides a computer program, wherein, when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned task processing method.

上述为本实施例的一种计算机程序的示意性方案。需要说明的是,该计算机程序的技术方案与上述的任务处理方法的技术方案属于同一构思,计算机程序的技术方案未详细描述的细节内容,均可以参见上述任务处理方法的技术方案的描述。The above is a schematic solution of a computer program of this embodiment. It should be noted that the technical solution of the computer program and the technical solution of the above-mentioned task processing method belong to the same concept. For details that are not described in detail in the technical solution of the computer program, refer to the description of the technical solution of the above-mentioned task processing method.

上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve desirable results. Additionally, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

所述计算机指令包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质等。需要说明的是,所述计算机可读介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读介质不包括电载波信号和电信信号。The computer instructions include computer program code, which may be in source code form, object code form, an executable file, some intermediate form, or the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM, Read-Only Memory) , Random Access Memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable media may be appropriately increased or decreased 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 media Electric carrier signals and telecommunication signals are not included.

需要说明的是,对于前述的各方法实施例,为了简便描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本说明书实施例并不受所描述的动作顺序的限制,因为依据本说明书实施例,某些步骤可以采用其它顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定都是本说明书实施例所必须的。It should be noted that, for the convenience of description, the foregoing method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the embodiments of this specification are not limited by the described action sequences. Limitation, because certain steps may be performed in other orders or simultaneously according to embodiments of the present specification. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily all necessary for the embodiments of the specification.

在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.

以上公开的本说明书优选实施例只是用于帮助阐述本说明书。可选实施例并没有详尽叙述所有的细节,也不限制该发明仅为所述的具体实施方式。显然,根据本说明书实施例的内容,可作很多的修改和变化。本说明书选取并具体描述这些实施例,是为了更好地解释本说明书实施例的原理和实际应用,从而使所属技术领域技术人员能很好地理解和利用本说明书。本说明书仅受权利要求书及其全部范围和等效物的限制。The preferred embodiments of the present specification disclosed above are provided only to aid in the elaboration of the present specification. Alternative embodiments are not intended to exhaust all details, nor do they limit the invention to only the described embodiments. Obviously, many modifications and changes can be made in accordance with the contents of the embodiments of the present specification. These embodiments are selected and described in this specification to better explain the principles and practical applications of the embodiments of this specification, so that those skilled in the art can well understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.

Claims (13)

1. A method of task processing, comprising:
receiving a task allocation request aiming at a target virtual object, wherein 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, wherein the current resource occupation information of the initial vCPU is greater than that of other vCPUs;
under the condition that the current resource occupation information of the initial vCPU is determined to meet the task processing condition of the task to be distributed, determining the initial vCPU as a target vCPU;
and distributing the task to be distributed to the target vCPU for task execution.
2. The task processing method according to claim 1, wherein the determining that the initial vCPU is the target vCPU when determining that the current resource occupation information of the initial vCPU satisfies the task processing condition of the task to be allocated includes:
and under the condition that the current resource occupation information of the initial vCPU is determined to meet the preset load condition, determining the initial vCPU as a target vCPU.
3. The task processing method according to claim 1, further comprising, after determining an initial vCPU from the at least two vcpus:
determining candidate vCPUs from other vCPUs under the condition that the current resource occupation information of the initial vCPU is determined and does not meet the preset load condition, wherein the current resource occupation information of the candidate vCPUs meets the preset load condition;
and determining a target vCPU from the candidate vCPUs, wherein the current resource occupation information of the target vCPU is larger than other candidate vCPUs except the target vCPU in the candidate vCPUs.
4. The task processing method according to claim 1, wherein the determining an initial vCPU from the at least two vcpus comprises:
determining a vCPU set corresponding to each vCPU, wherein the vCPU sets comprise the vCPUs of the same type;
determining a target vCPU set corresponding to the task type of the task to be distributed based on historical task execution information;
and determining an initial vCPU from the target vCPU set, wherein the current resource occupation information of the initial vCPU is larger than other vCPUs in the target vCPU set.
5. The task processing method according to claim 1, wherein the determining an initial vCPU from the at least two vcpus comprises:
determining current resource occupation information of each vCPU;
sequencing each vCPU in a descending order based on the current resource occupation information to obtain a sequencing result of each vCPU in the descending order;
and determining the vCPU at the first position in the descending sorting result as an initial vCPU.
6. The task processing method according to claim 1, wherein the determining that the initial vCPU is a target vCPU when determining that the current resource occupation information of the initial vCPU satisfies the task processing condition of the task to be allocated includes:
determining resource occupation information of the tasks to be distributed;
determining residual resource information corresponding to the initial vCPU based on the current resource occupation information of the initial vCPU;
and determining the initial vCPU as a target vCPU under the condition that the residual resource information is greater than or equal to the resource occupation information.
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:
and under the condition that the residual resource information is smaller than the resource occupation information, continuously executing the step of determining the initial vCPU from the at least two vCPUs until the residual resource information is larger than or equal to the resource occupation information.
8. The task processing method according to claim 1, wherein the allocating the task to be allocated to the target vCPU for task execution includes:
and distributing the tasks to be distributed to the task queues to be executed corresponding to the target vCPU, and executing the tasks in the task queues to be executed.
9. The task processing method according to claim 7, further comprising, after the task is executed by allocating the task to be allocated to the target vCPU:
and under the condition that the task queue to be executed corresponding to the target vCPU is determined to be empty, adjusting the current running state of the target vCPU to be an idle state, and releasing the physical computing resource corresponding to the target vCPU.
10. The task processing method according to claim 1, further comprising, after receiving the task allocation request for the target virtual object:
under the condition that the attribute information of the task allocation request is determined to meet the vCPU state adjustment condition, determining at least two vCPUs corresponding to the target virtual object;
determining the vCPU of which the current operation state is an idle state in the at least two vCPUs as a target vCPU;
and adjusting the current running state of the target vCPU to be a running state, and distributing the task to be distributed to the target vCPU for task execution.
11. A task processing device comprising:
the system comprises a receiving module, a processing module and a processing module, wherein the receiving module is configured to receive a task allocation request aiming at a target virtual object, and the task allocation request carries a task to be allocated;
a first determining module 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, where current resource occupation information of the initial vCPU is greater than that of other vcpus;
the second determining module is configured to determine that the initial vCPU is a target vCPU under the condition that the current resource occupation information of the initial vCPU is determined to meet the task processing condition of the task to be distributed;
and the execution module is configured to allocate the task to be allocated to the target vCPU for task execution.
12. A computing device, comprising:
a memory and a processor;
the memory is configured to store computer-executable instructions, and the processor is configured to execute the computer-executable instructions, which when executed by the processor implement the steps of the task processing method of any of claims 1 to 10.
13. A computer-readable storage medium storing computer-executable instructions which, when executed by a processor, implement the steps of the task processing method of any one of claims 1 to 10.
CN202210682601.XA 2022-06-16 2022-06-16 Task processing method and device Pending CN115168028A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210682601.XA CN115168028A (en) 2022-06-16 2022-06-16 Task processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210682601.XA CN115168028A (en) 2022-06-16 2022-06-16 Task processing method and device

Publications (1)

Publication Number Publication Date
CN115168028A true CN115168028A (en) 2022-10-11

Family

ID=83486128

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210682601.XA Pending CN115168028A (en) 2022-06-16 2022-06-16 Task processing method and device

Country Status (1)

Country Link
CN (1) CN115168028A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118210593A (en) * 2024-03-27 2024-06-18 超聚变数字技术有限公司 A virtual machine core binding method and computing device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180088998A1 (en) * 2016-09-23 2018-03-29 Samsung Electronics Co., Ltd. Multi-thread processor and controlling method thereof
CN111949398A (en) * 2020-07-30 2020-11-17 西安万像电子科技有限公司 Resource scheduling method and device
CN113515351A (en) * 2021-09-07 2021-10-19 华南理工大学 Resource scheduling implementation method based on energy consumption and QoS (quality of service) cooperative optimization
CN114327767A (en) * 2021-12-28 2022-04-12 元心信息科技集团有限公司 Task processing method and device, electronic equipment and computer readable storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180088998A1 (en) * 2016-09-23 2018-03-29 Samsung Electronics Co., Ltd. Multi-thread processor and controlling method thereof
CN111949398A (en) * 2020-07-30 2020-11-17 西安万像电子科技有限公司 Resource scheduling method and device
CN113515351A (en) * 2021-09-07 2021-10-19 华南理工大学 Resource scheduling implementation method based on energy consumption and QoS (quality of service) cooperative optimization
CN114327767A (en) * 2021-12-28 2022-04-12 元心信息科技集团有限公司 Task processing method and device, electronic equipment and computer readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
钱建民: "虚拟化环境下面向NUMA架构的资源管理优化策略研究", 《中国博士学位论文全文数据库》, no. 01, 15 January 2022 (2022-01-15) *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118210593A (en) * 2024-03-27 2024-06-18 超聚变数字技术有限公司 A virtual machine core binding method and computing device

Similar Documents

Publication Publication Date Title
US11797327B2 (en) Dynamic virtual machine sizing
CN111488210B (en) Task scheduling method and device based on cloud computing and computer equipment
CN109564528B (en) System and method for computing resource allocation in distributed computing
US20160210174A1 (en) Hybrid Scheduler and Power Manager
WO2010082244A1 (en) Information processing device and information processing method
WO2007149188A1 (en) Method, system, and apparatus for scheduling computer micro-jobs to execute at non-disruptive times
CN103179048A (en) Method and system for changing main machine quality of service (QoS) strategies of cloud data center
CN106325996B (en) A method and system for allocating GPU resources
CN115167996A (en) Scheduling method and device, chip, electronic device and storage medium
CN118819864B (en) Unified scheduling method and system for resources of multiple types of loads
CN117472570A (en) Methods, apparatus, electronic devices and media for scheduling accelerator resources
CN113608845B (en) Data processing method and device
CN115168028A (en) Task processing method and device
CN103677959B (en) A kind of virtual machine cluster migration method and system based on multicast
CN115878260A (en) Low-carbon self-adaptive cloud host task scheduling system
CN108255572A (en) A kind of VCPU switching methods and physical host
CN114327929A (en) Priority processing method, device, scheduler and multi-core system based on AMP architecture
WO2023160359A1 (en) Resource scheduling method and device
US8245229B2 (en) Temporal batching of I/O jobs
CN114116220B (en) A GPU sharing control method, GPU sharing control device and storage medium
CN114253708B (en) Load scheduling method and system
CN116795503A (en) Task scheduling method, task scheduling device, graphics processor and electronic equipment
CN114579279A (en) Task scheduling method and device
CN112114967B (en) GPU resource reservation method based on service priority
CN119356888B (en) Intelligent management method for computer hardware resources

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination