Task scheduling method and device, computer device and readable storage medium

By monitoring the status of multi-core tasks, identifying idle and overloaded processor cores, and optimizing task migration, the inefficiency problem of traditional task scheduling methods is solved, and efficient task scheduling is achieved.

CN123177971APending Publication Date: 2026-11-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510695243.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-27
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Traditional task scheduling methods cannot accurately perceive the load status of multiple processor cores, resulting in low task migration success rate and long processing time, and low scheduling efficiency.

Method used

By acquiring multi-core task status monitoring information, idle and overloaded processor cores are identified. Idle cores are used to process the task queue, and tasks are migrated to overloaded cores to optimize load balancing.

Benefits of technology

It improves task scheduling efficiency, reduces the time consumed by frequent load balancing, and achieves efficient task scheduling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123177971A_ABST
    Figure CN123177971A_ABST
Patent Text Reader

Abstract

The application relates to a task scheduling method and device, computer equipment, a computer readable storage medium and a computer program product. The method comprises the following steps: acquiring multi-core task state monitoring information, the multi-core task state monitoring information indicating the load state of each processor core, and the plurality of processor cores sharing a same shared cache; determining a first processor core in an idle state in the plurality of processor cores; the first processor core is used for processing a first task acquired according to a first task queue; selecting a second processor core in an overload state from the plurality of processor cores according to the multi-core task state monitoring information; the second processor core is used for processing a second task acquired according to a second task queue; at least one second task is determined as the first task to update the first task queue, so that the first task is processed by the first processor core according to the first task queue. The method can improve the task scheduling efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a task scheduling method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Technology

[0002] With the development of computer technology and the growth of massive amounts of data, servers are being used more and more widely, and server specifications are getting larger and larger, with more and more processor cores. Efficiently utilizing multi-core processors containing multiple processor cores is the key to improving system performance and resource utilization.

[0003] Traditional technologies typically rely on control group functionality and Completely Fair Scheduling (CFS) to control processor core usage. Control group functionality allows for control over task processor affinity, binding tasks to specific processor cores and thus confining the use of multiple processor cores to the shared scope of the same cache. CFS, on the other hand, is primarily used to perceive the workload of tasks across multiple processor cores to achieve fair scheduling and load balancing.

[0004] However, traditional methods, such as the Completely Fair Scheduler (CFS), cannot accurately perceive the load of tasks on multiple processor cores. Furthermore, due to various condition judgments, the success rate of task migration on processor cores with the same shared cache is very low, and it will frequently enter the load balancing state, resulting in long task scheduling time and low task scheduling efficiency. Summary of the Invention

[0005] Therefore, it is necessary to provide a task scheduling method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve task scheduling efficiency in response to the above-mentioned technical problems.

[0006] Firstly, this application provides a task scheduling method, including:

[0007] Acquire multi-core task status monitoring information, which indicates the load status of each of the multiple processor cores, and the multiple processor cores share the same shared cache.

[0008] A first processor core that is in an idle state is identified among the plurality of processor cores. The first processor core is used to process a first task obtained according to a first task queue.

[0009] Based on the multi-core task status monitoring information, a second processor core that is in an overload state is selected from the multiple processor cores. The second processor core is used to process the second task obtained from the second task queue.

[0010] At least one of the second tasks is identified as the first task, and an updated first task queue is obtained to process the first task by the first processor core according to the updated first task queue.

[0011] Secondly, this application also provides a task scheduling apparatus, comprising:

[0012] The running status monitoring module is used to acquire multi-core task status monitoring information, which indicates the load status of each of the multiple processor cores, and the multiple processor cores share the same shared cache.

[0013] An idle core determination module is used to determine the first processor core that is in an idle state among the plurality of processor cores. The first processor core is used to process the first task obtained according to the first task queue.

[0014] The overloaded core selection module is used to select a second processor core that is in an overloaded state from the multiple processor cores based on the multi-core task status monitoring information. The second processor core is used to process the second task obtained from the second task queue.

[0015] A task migration module is configured to identify at least one second task as the first task, obtain an updated first task queue, and process the first task through the first processor core according to the updated first task queue.

[0016] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0017] Acquire multi-core task status monitoring information, which indicates the load status of each of the multiple processor cores, and the multiple processor cores share the same shared cache.

[0018] A first processor core that is in an idle state is identified among the plurality of processor cores. The first processor core is used to process a first task obtained according to a first task queue.

[0019] Based on the multi-core task status monitoring information, a second processor core that is in an overload state is selected from the multiple processor cores. The second processor core is used to process the second task obtained from the second task queue.

[0020] At least one of the second tasks is identified as the first task, and an updated first task queue is obtained to process the first task by the first processor core according to the updated first task queue.

[0021] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0022] Acquire multi-core task status monitoring information, which indicates the load status of each of the multiple processor cores, and the multiple processor cores share the same shared cache.

[0023] A first processor core that is in an idle state is identified among the plurality of processor cores. The first processor core is used to process a first task obtained according to a first task queue.

[0024] Based on the multi-core task status monitoring information, a second processor core that is in an overload state is selected from the multiple processor cores. The second processor core is used to process the second task obtained from the second task queue.

[0025] At least one of the second tasks is identified as the first task, and an updated first task queue is obtained to process the first task by the first processor core according to the updated first task queue.

[0026] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0027] Acquire multi-core task status monitoring information, which indicates the load status of each of the multiple processor cores, and the multiple processor cores share the same shared cache.

[0028] A first processor core that is in an idle state is identified among the plurality of processor cores. The first processor core is used to process a first task obtained according to a first task queue.

[0029] Based on the multi-core task status monitoring information, a second processor core that is in an overload state is selected from the multiple processor cores. The second processor core is used to process the second task obtained from the second task queue.

[0030] At least one of the second tasks is identified as the first task, and an updated first task queue is obtained to process the first task by the first processor core according to the updated first task queue.

[0031] The aforementioned task scheduling method, apparatus, computer equipment, computer-readable storage medium, and computer program product acquire multi-core task status monitoring information. This information allows for the determination of the load status of multiple processor cores sharing the same shared cache. Based on identifying an idle first processor core, the multi-core task status monitoring information enables rapid location of an overloaded second processor core. This allows at least one second task to be identified as the first task, resulting in an updated first task queue. The first processor core then processes the first task according to this updated queue. Throughout this process, by efficiently maintaining the load status of multiple processor cores under the shared cache, the efficiency of finding transferable tasks is improved. Tasks are quickly pulled to the idle first processor core for processing, achieving efficient task scheduling under the shared cache. This saves time caused by frequent load balancing during task scheduling and improves overall task scheduling efficiency. Attached Figure Description

[0032] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0033] Figure 1 This is a diagram illustrating the application environment of a task scheduling method in one embodiment;

[0034] Figure 2 This is a flowchart illustrating a task scheduling method in one embodiment;

[0035] Figure 3 This is a schematic diagram illustrating the migration of the second task in one embodiment;

[0036] Figure 4 This is a schematic diagram of multi-core task status monitoring information in one embodiment;

[0037] Figure 5 This is a schematic diagram illustrating the scanning of multi-core task status monitoring information in one embodiment;

[0038] Figure 6 This is a schematic diagram of selecting the scan start state flag bit in one embodiment;

[0039] Figure 7 This is a schematic diagram illustrating the effect of selecting the scan start state flag bit in one embodiment;

[0040] Figure 8This is a flowchart illustrating the process of updating multi-core task status monitoring information in one embodiment;

[0041] Figure 9 This is a flowchart illustrating the task scheduling method in another embodiment;

[0042] Figure 10 This is a schematic diagram of a structure variable in one embodiment;

[0043] Figure 11 This is a schematic diagram illustrating the monitoring of load status in one embodiment;

[0044] Figure 12 This is a schematic diagram of scanning structure variables in one embodiment;

[0045] Figure 13 This is a structural block diagram of a task scheduling device in one embodiment;

[0046] Figure 14 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0047] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0048] In order to clearly describe the technical solution of this application and facilitate understanding of the technical solution of this application, the key concepts involved in this application will be explained below.

[0049] 1. Multi-core task status monitoring information.

[0050] Multi-core task status monitoring information is used to maintain the load status of each of the multiple processor cores. It records the load status of each of the multiple processor cores.

[0051] 2. Processor core.

[0052] A processor core is an independent processing unit within a processor. It is the basic unit that makes up a processor and is responsible for independent instruction execution and data processing. It has its own control unit, arithmetic logic unit, and register set, and can independently complete the calculation process of a task.

[0053] 3. Load status.

[0054] Load state refers to the load status determined based on the task execution status of the processor cores. For example, a load state can be overloaded, indicating a large number of tasks awaiting processing on the processor cores. For instance, if the number of tasks indicated in the processor core's task queue is greater than or equal to a preset first task count threshold, the processor core can be considered overloaded. Conversely, a load state can be lightly loaded, indicating a small number of tasks awaiting processing on the processor cores. For instance, if the number of tasks indicated in the processor core's task queue is less than a preset first task count threshold, the processor core can be considered lightly loaded. The preset first task count threshold can be configured according to the actual application scenario; for example, the preset first task count threshold could be 2.

[0055] 4. Shared cache.

[0056] A shared cache is a high-speed cache area shared by multiple processor cores to store recently accessed data and instructions. This cache design can improve the performance and efficiency of multi-core processors. It allows different processor cores to share data and instructions, thereby reducing the number of accesses to main memory and improving the overall system performance. For example, a shared cache can specifically refer to the L3 cache.

[0057] 5. Task queue.

[0058] A task queue is a data structure used by the operating system to manage task scheduling. Each processor core is associated with a task queue, which stores tasks waiting to be processed by the processor core or task description information. When the processor core completes the current task, it can obtain the next task from the task queue to continue processing. The task here can be a process or a thread, etc.

[0059] The task scheduling method provided in this application embodiment can be applied to, for example, Figure 1 The application environment shown is illustrated. The data storage system stores the data that server 102 needs to process. The data storage system can be configured independently, integrated into server 102, or placed in the cloud or on other network servers.

[0060] Server 102 acquires multi-core task status monitoring information, which indicates the load status of each of the multiple processor cores. The multiple processor cores share the same shared cache. The server identifies a first processor core that is idle and processes a first task obtained from a first task queue. Based on the multi-core task status monitoring information, the server selects a second processor core that is overloaded and processes a second task obtained from a second task queue. At least one second task is identified as a first task, and an updated first task queue is obtained. The server then processes the first task through the first processor core based on the updated first task queue.

[0061] Among them, server 102 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.

[0062] In one exemplary embodiment, such as Figure 2 As shown, a task scheduling method is provided. This embodiment illustrates the method applied to a server, but it is understood that the method can also be applied to a terminal, or to a system including both a terminal and a server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes steps 202 to 208. Wherein:

[0063] Step 202: Obtain multi-core task status monitoring information. The multi-core task status monitoring information indicates the load status of each of the multiple processor cores. The multiple processor cores share the same shared cache.

[0064] The multi-core task status monitoring information is used to maintain the load status of each of the multiple processor cores. It records the load status of each processor core individually. Load status refers to the load determined based on the task execution status of the processor core. For example, a load status can be overloaded, indicating that the processor core has a large number of tasks waiting to be processed. For instance, if the number of tasks indicated in the task queue of a processor core is greater than or equal to a preset first task number threshold, the processor core can be considered overloaded. Conversely, a load status can be lightly loaded, indicating that the processor core has a small number of tasks waiting to be processed. For instance, if the number of tasks indicated in the task queue of a processor core is less than a preset first task number threshold, the processor core can be considered lightly loaded. The preset first task number threshold can be configured according to the actual application scenario; for example, the preset first task number threshold can be 2.

[0065] The processor core is an independent processing unit within the processor, the basic building block of the processor, responsible for independent instruction execution and data processing. It has its own control unit, arithmetic logic unit, and register set, and can independently complete the computational process of a task. For example, a processor can specifically be a central processing unit (CPU), one of the main components of a computer, whose primary function is to interpret computer instructions and process data in computer software. In the era of single-core processors, the CPU consisted of multiple independent units. Later, CPUs manufactured using integrated circuits were developed. These highly miniaturized devices are known as microprocessors. The most complex circuitry within the CPU can be made into a single, tiny, powerful unit, which is the processor core.

[0066] Understandably, in a multi-core processor, multiple processor cores can handle different tasks simultaneously, thereby improving overall computing efficiency. For example, in a multi-core processor, one processor core can handle video playback while another can handle document editing; they work independently and concurrently. The number and performance of processor cores directly affect the overall performance of the processor. Specifically, a larger number of processor cores improves multitasking capabilities, and processor cores with different performance levels have varying task processing capabilities.

[0067] Shared cache, in particular, is a high-speed cache area shared by multiple processor cores to store recently accessed data and instructions. This cache design can improve the performance and efficiency of multi-core processors. It allows different processor cores to share data and instructions, thereby reducing the number of accesses to main memory and improving the overall system performance. For example, shared cache can specifically refer to the Level 3 cache. The Level 3 cache, also known as L3 cache, is a type of RAM with a faster access speed than general RAM (Random Access Memory). It typically does not use DRAM (Dynamic Random Access Memory) technology like the system's main memory, but instead uses the more expensive but faster SRAM (Static Random Access Memory) technology.

[0068] For example, when task scheduling is required, the server obtains multi-core task status monitoring information, which indicates the load status of each of the multiple processor cores, and the multiple processor cores share the same shared cache.

[0069] In practical applications, servers can use system analysis tools to view processor cache information and determine the shared cache of multiple processor cores based on this information. The system analysis tools used may differ depending on the operating system. For example, on a Linux system, processor cache information can be viewed through the ` / proc / cpuinfo` file or the `lscpu` command. On a Windows system, processor cache information can be viewed through Task Manager or system information tools.

[0070] Step 204: Determine the first processor core that is idle among the multiple processor cores. The first processor core is used to process the first task obtained according to the first task queue.

[0071] In this context, "idle state" refers to a state where the number of tasks a processor core needs to process is relatively small, meaning the number of tasks indicated in the processor core's task queue is low. For example, an idle state could specifically mean that the number of tasks indicated in the processor core's task queue is less than a preset second task quantity threshold. This preset second task quantity threshold can be configured according to the actual application scenario. For instance, a preset second task quantity threshold of 1 means that the processor core is in an idle state when the number of tasks it needs to process is 0. Alternatively, an idle state could also mean that the percentage of tasks a processor core needs to process relative to the total number of tasks processed by multiple processor cores is less than a preset percentage threshold. This preset percentage threshold can also be configured according to the actual application scenario. For example, it could be 1%, 3%, etc.

[0072] The task queue is a data structure used by the operating system to manage task scheduling. Each processor core is associated with a task queue, which stores tasks waiting to be processed or task descriptions. When a processor core completes its current task, it can retrieve the next task from the task queue to continue processing. A task can specifically be a process or thread. For example, a specific task queue can be the CFS (Completely Fair Scheduler) run queue, which contains a red-black tree used to sort scheduling entities by virtual runtime. A scheduling entity represents an abstraction of a process or process group in CFS scheduling.

[0073] The first task queue refers to the task queue associated with the first processor core, that is, the task queue bound to the first processor core. The first processor core is used to process the first task obtained from the first task queue. The first task refers to the task waiting to be processed by the first processor core.

[0074] A process is a single execution of a program with a certain independent function on a specific set of data. It is the basic unit of dynamic execution in an operating system; in traditional operating systems, a process is both the basic unit of allocation and execution. A thread is the smallest unit of computation that an operating system can schedule. It is contained within a process and is the actual unit of operation within that process. In computer science, a process is divided into two or more threads (instances) or subprocesses, which are executed concurrently by a single-processor (single-thread), multi-processor (multi-thread), or multi-core processing system.

[0075] The Completely Fair Scheduler (CFS), part of the Linux kernel (an open-source Unix-like operating system kernel), is responsible for process scheduling. Adopted in Linux kernel 2.6.23 and later, it replaced the previous O(1) scheduler and became the system's default scheduler. It allocates processor resources to running processes, aiming to maximize program interaction performance and overall processor utilization. It is implemented using a red-black tree. For example, the server determines the first idle processor core based on the number of tasks pending on each processor core. This first processor core is then selected to retrieve and process the first task from the first task queue. For example, for each processor core, after completing its current task, it retrieves the next task from its associated task queue. In response to this, the server can determine whether a processor core is idle based on the number of tasks pending on that core.

[0076] In practical applications, if the number of tasks to be processed by a processor core is less than a preset second threshold, the processor core can be determined to be in an idle state. Similarly, if the proportion of the number of tasks to be processed by a processor core to the total number of tasks to be processed by multiple processor cores is less than a preset proportion threshold, the processor core can also be determined to be in an idle state.

[0077] In practical applications, the first task queue can include the first task itself, allowing the first task to be retrieved and processed directly from the queue. Furthermore, the first task queue can also include task description information related to the first task; different task descriptions indicate different first tasks. Specifically, the task description information can include task identifier, task status, task priority, task waiting time, and task context.

[0078] The task identifier is a unique identifier for each task, used to distinguish different tasks. The task state describes the current execution status of the task. For example, the task state can be: ready, running, waiting, blocked, etc. The task priority indicates the urgency or importance of the task; higher-priority tasks are usually processed first. The task wait time refers to the time a task waits to be executed. The task context includes the task's register state, memory mapping, stack information, etc., and is mainly used to correctly save and restore the task's state, ensuring task continuity.

[0079] In a specific application, taking a preset second task quantity threshold of 1 as an example, if the processor core cannot obtain the next task from the task queue associated with the processor core for processing, it means that the number of tasks to be processed by the processor core is less than the preset second task quantity threshold, and the server will determine that the processor core is the first processor core in an idle state.

[0080] In practical applications, when multi-core task status monitoring information is obtained, since this information indicates the load status of each processor core, the server can also scan for the first idle processor core among the multiple processor cores based on this information. Furthermore, if the load status recorded in the multi-core task status monitoring information includes both overload and light load states, the server needs to further determine the idle processor cores from the lightly loaded processor cores. If it includes overload, light load, and idle states, the server can directly scan and query the load status of the processor cores.

[0081] Step 206: Based on the multi-core task status monitoring information, select a second processor core that is in an overloaded state from multiple processor cores. The second processor core is used to process the second task obtained from the second task queue.

[0082] Overload state refers to a state where the processor core needs to process a large number of tasks, that is, a state where the number of tasks indicated by the processor core's task queue is large. For example, overload state can specifically refer to a state where the number of tasks indicated by the processor core's task queue is greater than or equal to a preset first task number threshold.

[0083] The second task queue refers to the task queue associated with the second processor core, that is, the task queue bound to the second processor core. The second processor core is used to process the second tasks obtained from the second task queue. The second task refers to the task waiting to be processed by the second processor core.

[0084] For example, the server can determine the load status of each of the multiple processor cores based on the multi-core task status monitoring information, and then select a second processor core that is in an overloaded state from the multiple processor cores using the load status of each of the multiple processor cores.

[0085] In practical applications, the server can select a second processor core by scanning multi-core task status monitoring information. Specifically, the server can select the first processor core that is in an overload state as the second processor core.

[0086] In practical applications, the second task queue can include the second task itself, allowing for direct retrieval and processing of the second task. Furthermore, the second task queue can also include task description information related to the second task; different task descriptions indicate different second tasks. Specifically, the task description information can include task identifier, task status, task priority, task waiting time, and task context.

[0087] Step 208: Identify at least one second task as the first task, obtain an updated first task queue, and process the first task through the first processor core according to the updated first task queue.

[0088] For example, when a second processor core is identified, the server will designate at least one second task as the first task, obtain an updated first task queue, and then process the first task according to the updated first task queue through the first processor core. This achieves idle reversal of the first processor core, thereby fully utilizing the computing resources of the first processor core. In other words, when at least one second task is identified as the first task, the first processor core can obtain and process the first task according to the updated first task queue. Specifically, the processing method can be to process the first task based on task data related to the first task in the shared cache.

[0089] It is understandable that by using a first processor core that shares the same shared cache as the second processor core, the second task, which is determined to be the first task, can be processed based on the task data in the shared cache. Relying on cache consistency, data hit efficiency can be accelerated and execution efficiency can be improved.

[0090] In practical applications, designating the second task as the first task essentially means migrating the second task to the first processor core for processing. When migrating the second task, it can be any second task that meets preset migration conditions. Meeting the preset migration conditions means that the second task satisfies the preset migration conditions and is therefore considered suitable for migration to the first processor core for processing. These preset migration conditions can be configured according to the actual application scenario. For example, specific preset migration conditions could include the second task not being bound to a second processor core, or the second task's task type being a task type that the first processor core can process.

[0091] In a specific application, when a processable first task exists, the server will merge at least one second task into the processable first task, awaiting processing by the first processor core. The processable first tasks can form a first task group. When merging at least one second task into the first task group, the server can prioritize the at least one second task and the processable first tasks in the first task group to determine the merging position of the at least one second task. The task priority ranking can be based on at least one of the task priority, task waiting time, and task execution time in the task description information of the first and second tasks. When no processable first task exists, the server will directly treat at least one second task as a processable first task, awaiting processing by the first processor core. In a specific application, taking a task queue including tasks as an example, through... Figure 3 The second migration task in this embodiment will be described. For example... Figure 3 As shown, the first task queue of the first processor core is empty, indicating that the first processor core is in an idle state. The second task queue of the second processor core contains tasks 1, 2, 3, 4, and 5. If tasks that meet the preset migration conditions include tasks 3, 4, and 5, the server can select at least one of these tasks as the first task and migrate it to the first task queue to update the first task queue so that the first task can be processed by the first processor core. Taking task 3 as the first task as an example, during migration, task 3 will be dequeued from the second task queue and enqueued into the first task queue.

[0092] In practical applications, designating at least one second task as the first task can essentially mean replacing the first task with at least one second task. That is, replacing the first task with at least one second task allows the first processor core to process the at least one second task that has been replaced by the first task. When replacing the first task with at least one second task, the updated first task queue can include either the at least one second task itself or task description information for at least one second task. Based on the task description information, at least one second task can be obtained for processing.

[0093] In a specific application, when replacing a first task with at least one second task, the replacement method can be a complete replacement, where the entire first task is replaced with at least one second task. In this case, the updated first task queue includes at least one second task itself, or at least one second task's task description information, and no longer retains the original first task or its task description information. Alternatively, the replacement method can be a partial replacement, where the first task is partially replaced with at least one second task, allowing the first processor core to process both the first task and the at least one second task that was replaced with it. In this case, the updated first task queue includes the first task and the at least one second task that was replaced with it, or the task attribute information of the first task and the at least one second task that was replaced with it. Finally, the replacement method can be merging without replacing, meaning the second task is migrated to the first processor core for processing. The aforementioned task scheduling method acquires multi-core task status monitoring information, enabling the determination of the load status of multiple processor cores sharing the same shared cache. Based on identifying the first idle processor core, the method uses the multi-core task status monitoring information to quickly locate the second overloaded processor core. This allows at least one second task to be identified as the first task, resulting in an updated first task queue. The first processor core then processes the first task according to the updated queue. Throughout this process, by efficiently maintaining the load status of multiple processor cores under the shared cache, the method improves the efficiency of finding transferable tasks, thereby quickly pulling tasks to the idle first processor core for processing. This achieves efficient task scheduling under the shared cache, saving time caused by frequent load balancing during task scheduling and improving overall task scheduling efficiency.

[0094] In an exemplary embodiment, the multi-core task status monitoring information includes status bit values ​​for each of the multiple processor cores, each status bit value representing the load status of the processor core; selecting a second processor core in an overload state from the multiple processor cores based on the multi-core task status monitoring information includes:

[0095] Based on the status bit values ​​of each of the multiple processor cores, determine the first status bit value that represents the overload state.

[0096] Determine the first state bit value, which is the first state flag bit in the multi-core task state monitoring information;

[0097] The processor core represented by the first status flag is used as the second processor core.

[0098] In this context, the status bit value refers to the value at each status flag bit in the multi-core task status monitoring information, used to characterize the load status of the processor core represented by the status flag bit. The status flag bit is the basic unit constituting the multi-core task status monitoring information and is the smallest unit for storing information. In this embodiment, the processor core is represented by the status flag bit, and the load status of the processor core is represented by the status bit value. It can be understood that each status flag bit represents a different processor core; that is, there is a one-to-one correspondence between the status flag bit and the processor core.

[0099] For example, multi-core task status monitoring information can be a bit array, also known as a bitmap. The status bit value refers to the Boolean value at each status flag bit in the bit array, specifically 0 or 1, used to characterize the load status of the processor core. Taking a bitmap as the multi-core task status monitoring information, and multiple processor cores as N processor cores, the format of the multi-core task status monitoring information can be as follows: Figure 4 As shown, there are status flags 402 representing N processor cores, and each status flag 402 has a status bit value, which is either 0 or 1, used to represent the load state of the processor core. Here, N is a positive integer greater than 1.

[0100] It should be noted that, since the load state of a processor core can be represented by 0 or 1, the correspondence between each value and the load state can be configured according to the actual application scenario. For example, a value of 0 can represent a light load state, and a value of 1 can represent an overload state. Alternatively, a value of 1 can represent a light load state, and a value of 0 can represent an overload state.

[0101] Furthermore, taking the example of using a value of 0 to represent a light load state and a value of 1 to represent a load state of overload, for example, regarding... Figure 4 The multi-core task status monitoring information shown indicates that the first processor core and the (N-1)th processor core are in an overload state, while the remaining processor cores are in a light load state.

[0102] For example, the multi-core task status monitoring information includes the status bit values ​​of each of the multiple processor cores. Each status bit value represents the load status of the processor core. When selecting the second processor core, the server will scan the status bit values ​​of each of the multiple processor cores, determine the first status bit value representing the overload status, determine the first status flag bit of the first status bit value in the multi-core task status monitoring information, and take the processor core represented by the first status flag bit as the second processor core.

[0103] In practical applications, when determining the first state bit value representing the overload state by scanning the state bit value, the server will take the first state bit value representing the overload state as the first state bit value and record the state flag bit of the first state bit value representing the overload state as the first state flag bit.

[0104] In a specific application, taking the value 0 to represent a light load state and the value 1 to represent an overload state as an example, for example, regarding... Figure 4 The multi-core task status monitoring information shown can be used as follows: If the scanning method starts from the first status flag bit in the multi-core task status monitoring information, the status bit value of 1 at the first status flag bit can be used as the first status bit value, and the first status flag bit can be recorded as the first status flag bit. If the scanning method starts from the (N-2)th status flag bit in the multi-core task status monitoring information, the status bit value of 1 at the (N-1)th status flag bit can be used as the first status bit value, and the (N-1)th status flag bit can be recorded as the first status flag bit. Here, N is a positive integer greater than 2.

[0105] In this embodiment, based on the status bit values ​​of each of the multiple processor cores, a first status bit value representing an overloaded state can be determined. Furthermore, based on the location of this first status bit value and its position in the first status flag bit of the multi-core task status monitoring information, the second processor core can be accurately identified using this first status flag bit. By efficiently maintaining the load status of multiple processor cores under the shared cache and using the status bit value representing the load status to locate the second processor core in an overloaded state, the efficiency of finding the second processor core can be improved, thereby enhancing task scheduling efficiency.

[0106] In an exemplary embodiment, determining a first state bit value representing an overload state based on the state bit values ​​of each of the plurality of processor cores includes:

[0107] Obtain the scan start status flag for multi-core task status monitoring information;

[0108] Starting with the scan start status flag, scan the status bit values ​​of each of the multiple processor cores;

[0109] The first state bit value that indicates an overload state is scanned is taken as the first state bit value.

[0110] The scan start status flag refers to the specific position where the scan begins, proceeding bit by bit, within the multi-core task status monitoring information. For example, the scan start status flag could be the first status flag in the multi-core task status monitoring information. Alternatively, it could be a status flag determined based on historical scan records. In this case, the scan start status flag could be the first status flag or any other status flag.

[0111] For example, the server will obtain the scan start status flag for multi-core task status monitoring information, and scan the status bit values ​​of each of the multiple processor cores starting from the scan start status flag. The first status bit value that indicates that the load state is overloaded will be taken as the first status bit value.

[0112] In practical applications, when obtaining the scan start status flag, the server first attempts to retrieve historical scan records for multi-core task status monitoring information. If such records exist, the server can obtain them and then locate the scan start status flag based on them. If no historical scan records exist, the server will use the first status flag in the multi-core task status monitoring information as the scan start status flag.

[0113] In a specific application, taking multi-core task status monitoring information as a bitmap, and multiple processor cores as N processor cores, the format of multi-core task status monitoring information can be as follows: Figure 5 As shown, this includes status flags representing N processor cores, with each flag having a status value of either 0 or 1, used to characterize the load state of the processor core. Here, N is a positive integer greater than 9. If the scan starts with the first status flag (e.g., ...), ... Figure 5 The image shows the status flags representing processor core 1. The server will start from the first status flag and scan the status flags of multiple processor cores. The first status flag indicating an overload state (e.g., ...) will be selected. Figure 5 The value shown is the status bit value of the fourth status flag (as indicated by the image), which is used as the first status bit value. If the scan's initial status flag is the sixth status flag (e.g., ...), then... Figure 5The image shows the status flags representing processor core 6. Starting from the sixth status flag, the server scans the status flags of multiple processor cores, selecting the first flag indicating an overloaded state (e.g., ...). Figure 5 The value shown is the status bit value of the eighth status flag, which serves as the first status bit value. It is understandable that when scanning the status bit values ​​of multiple processor cores, the first status bit value determined by the scan may differ depending on the starting status flag.

[0114] In this embodiment, by obtaining the scanning start status flag for multi-core task status monitoring information, the scanning start status flag can be used as the starting point to scan the status bit values ​​of each of the multiple processor cores. Thus, the first status bit value that indicates an overloaded load state can be directly used as the first status bit value, thereby achieving accurate determination of the first status bit value.

[0115] In an exemplary embodiment, obtaining the scan start status flag for multi-core task status monitoring information includes:

[0116] If there are historical scan records for monitoring the status of multiple core tasks, determine the scanned status flag of the last scan based on the historical scan records.

[0117] Select the scan start status flag based on the scan status flag.

[0118] Historical scan records refer to the historical information from which multi-core task status monitoring information was scanned. For example, historical scan records may include the scanned status flags from the last scan. These scanned status flags could be either the last status flag scanned or all status flags scanned previously.

[0119] In this embodiment, the previous scan can specifically refer to the previous successful scan, which only records the cases where a state bit value representing an overload state was scanned. The previous scan can also include the previous successful scan and the previous failed scan, that is, in addition to recording the cases where a state bit value representing an overload state was scanned, it will also record the cases where a state bit value representing an overload state was not scanned.

[0120] For example, if there are historical scan records for monitoring the status of multiple core tasks, the server will determine the scanned status flag of the last scan based on the historical scan records, and then select the scan start status flag based on the scanned status flag.

[0121] In practical applications, if the scanned status flag is the last status flag previously scanned, the server will use the next status flag after the scanned status flag as the scan start status flag. If the scanned status flag includes all the previously scanned status flags, the server can determine the last status flag from all the status flags and use the next status flag after the last status flag as the scan start status flag. The server can also select any status flag other than all the previously scanned status flags as the scan start status flag.

[0122] In a specific application, taking multi-core task status monitoring information as a bitmap, and multiple processor cores as N processor cores, the format of multi-core task status monitoring information can be as follows: Figure 6 As shown, this includes status flags representing N processor cores, with each flag having a status value of either 0 or 1, used to represent the load state of the processor core. Here, N is a positive integer greater than 9. If the scanned status flag is the last status flag previously scanned, and the last status flag previously scanned was the fifth status flag (e.g., ...), then... Figure 6 The image shows the status flags representing processor core 5. The server can then use the sixth status flag (e.g.) Figure 6 The image shows the status flags representing processor core 6, which can be used as the scan start status flags. If the scanned status flags are all the previously scanned status flags, and all the previously scanned status flags include the first to fifth status flags, the server can use the sixth status flag as the scan start status flag, or it can select any status flag from the remaining status flags excluding the first to fifth status flags. Figure 6 Assuming the ninth status flag is selected (e.g.) Figure 6 The flag shown represents the status flag of processor core 9, which serves as the scan start status flag.

[0123] In a specific application, taking the next status flag bit after the last scanned status flag bit as the scan start status flag bit as an example, the effect of this embodiment will be explained. Figure 7 As shown, assuming the state bit representing the load state as overloaded is the eighth state flag bit (e.g., ... Figure 7 The image shows the status flag value at the position of processor core 8. If, through historical scan records, it is determined that the scan start status flag is the sixth status flag (e.g., ...). Figure 7The image shows the status flags representing processor core 6. Therefore, only three status flags need to be scanned to find the first status flag. If the first status flag (e.g.) is used... Figure 7 The flag shown represents the status flag of processor core 1. If the flag is the scan start flag, then eight status flags need to be scanned to find the first status flag. Compared to using the first status flag as the scan start flag each time, this embodiment selects the scan start flag by combining the already scanned status flags. This allows for selection of the scan start flag based on the actual scanning situation, rather than starting the scan from the first status flag each time. This ensures scanning fairness, guaranteeing that the status flags of multiple processor cores can be scanned, while significantly improving scanning efficiency and enabling rapid retrieval of the first status flag.

[0124] In one exemplary embodiment, the task scheduling method further includes:

[0125] In response to determining that at least one second task is completed as the first task is completed, the number of first tasks indicated by the second task queue is determined;

[0126] If the number of first tasks is less than the preset threshold for the number of first tasks, the load status of the second processor core recorded in the multi-core task status monitoring information will be updated from overload status to light load status.

[0127] The preset first task quantity threshold is a pre-set threshold used to determine the load state of the processor core. Specifically, if the number of tasks indicated in the processor core's task queue is less than the preset first task quantity threshold, the processor core is considered to be in a light-load state. If the number of tasks indicated in the processor core's task queue is greater than or equal to the preset first task quantity threshold, the processor core is considered to be in an overload state. The preset task quantity can be configured according to the actual application scenario. For example, the preset first task quantity threshold can be 2.

[0128] The number of tasks indicated by the task queue refers to the total number of tasks pending processing as determined by the task queue. For example, if the task queue includes the tasks themselves, the number of tasks indicated by the task queue is the total number of tasks pending processing in the task queue. Alternatively, if the task queue includes task-related description information, the number of tasks indicated by the task queue is the same as the number of task descriptions in the task queue.

[0129] For example, in response to determining that at least one second task is completed as the first task, the server determines the number of first tasks indicated by the second task queue, compares the number of first tasks with a preset first task number threshold, and if the number of first tasks is less than the preset first task number threshold, it indicates that the second processor core is in a light-load state after dequeuing at least one second task, and the server updates the load state of the second processor core recorded in the multi-core task status monitoring information from an overload state to a light-load state. If the number of first tasks is greater than or equal to the preset first task number threshold, it indicates that the load state of the second processor core is still in an overload state after dequeuing at least one second task, and it is not necessary to update the load state of the second processor core recorded in the multi-core task status monitoring information. In a specific application, taking a second task queue that includes two second tasks, a preset threshold for the number of first tasks that is 2, and a migration of 1 second task as an example, in response to determining that a second task is completed as the first task, the server can determine that the number of first tasks indicated by the second task queue is 1. After comparing the number of first tasks with the preset threshold for the number of first tasks, it can determine that the second processor core is in a light-load state, and will update the load state of the second processor core recorded in the multi-core task status monitoring information from the overload state to the light-load state.

[0130] Furthermore, taking an example where the multi-core task status monitoring information includes the status bit value of the second processor core, and the status bit value represents the load status of the processor core, the server will update the status bit value of the second processor core from a status bit value representing an overloaded load state to a status bit value representing a light load state. Even further, taking an example where a status bit value of 0 represents a light load state, and a status bit value of 1 represents an overloaded load state, the server will update the status bit value of the second processor core recorded in the multi-core task status monitoring information from 1 to 0.

[0131] In a specific application, taking a second task queue containing 3 second tasks, a preset threshold for the number of first tasks being 2, and a migration of 1 second task as an example, in response to identifying a second task as a first task, the server can determine that the number of first tasks indicated by the second task queue is 2. After comparing the number of first tasks with the preset threshold for the number of first tasks, it can determine that the load status of the second processor core is still overloaded, and there is no need to update the load status of the second processor core recorded in the multi-core task status monitoring information.

[0132] In this embodiment, in response to determining that at least one second task is completed as the first task, the number of first tasks indicated by the second task queue is determined. The first task number can be used to realize real-time monitoring of the load status of the second processor core. When the number of first tasks is less than a preset first task number threshold, the load status of the second processor core recorded in the multi-core task status monitoring information is updated in a timely manner, ensuring the accuracy of the recorded load status of the second processor core and the real-time maintenance of the multi-core task status monitoring information.

[0133] In one exemplary embodiment, the task scheduling method further includes:

[0134] If a task scheduling event is detected for the third task queue, the number of second tasks indicated by the third task queue is updated according to the number of scheduled tasks indicated by the task scheduling event.

[0135] The first load state of the third processor core is determined based on the number of second tasks and the preset threshold for the number of first tasks; the third processor core is used to process the third tasks obtained from the third task queue.

[0136] Based on the multi-core task status monitoring information, determine the load status recorded for the third processor core;

[0137] When the first load state differs from the recorded load state, the multi-core task status monitoring information is updated based on the first load state.

[0138] Task scheduling events refer to various operations related to task scheduling. They describe the state changes of tasks or task descriptions in the task queue, including task enqueue events and task dequeue events. A task enqueue event is the event where a task or task description is added to the task queue. A task dequeue event is the event where a task or task description is removed from the task queue and is ready for execution.

[0139] The "number of scheduled tasks" indicates the number of tasks scheduled in a task scheduling event. For example, in the case of a task enqueueing event, the "number of scheduled tasks" can specifically refer to the number of enqueueing tasks or the number of enqueueing task descriptions, where the enqueueing task descriptions indicate that there are enqueueing tasks. Similarly, in the case of a task dequeueing event, the "number of scheduled tasks" can specifically refer to the number of dequeueing tasks or the number of dequeueing task descriptions, where the dequeueing task descriptions indicate that there are dequeueing tasks.

[0140] The third task queue refers to the task queue associated with the third processor core, that is, the task queue bound to the third processor core. The third processor core is used to process the third tasks obtained from the third task queue. The third task refers to the task waiting to be processed by the third processor core.

[0141] For example, the server monitors task scheduling events for the task queues of multiple processor cores in real time. Upon detecting a task scheduling event for the third task queue, the server updates the number of second tasks indicated by the third task queue based on the number of scheduled tasks indicated by the task scheduling event. Then, based on the number of second tasks and a preset first task quantity threshold, the server determines the first load state of the third processor core, i.e., the real-time load state. Here, the third task queue refers to the task queue where a task scheduling event has been detected; specifically, it can be the task queue of any processor core. The third processor core is determined to obtain and process the third task from the third task queue.

[0142] For example, based on the determined first load state, the server determines the recorded load state for the third processor core according to the multi-core task status monitoring information, and compares the first load state with the recorded load state. If the first load state and the recorded load state are different, it means that the recorded load state needs to be updated, and the server updates the multi-core task status monitoring information according to the first load state. If the first load state and the recorded load state are the same, it means that the recorded load state does not need to be updated, and the server will not perform any further processing.

[0143] In practical applications, when the task scheduling event is a task enqueueing event, taking the number of scheduled tasks as the number of enqueueing tasks as an example, the server will accumulate the number of enqueueing tasks indicated by the task enqueueing event and the number of second tasks indicated by the third task queue to update the number of second tasks indicated by the third task queue. In a specific application, taking the number of enqueueing tasks as N1, and the number of second tasks indicated by the third task queue as N2 before the task enqueueing event is detected as an example, after accumulating the number of enqueueing tasks N1 and the number of second tasks N2, the updated number of second tasks is (N1 + N2), where N1 and N2 are positive integers greater than 0.

[0144] In practical applications, taking the case where the task scheduling event is a task dequeue event and the number of scheduled tasks is the number of dequeue tasks as an example, the server will subtract the number of dequeue tasks indicated by the task dequeue event from the number of second tasks indicated by the third task queue to update the number of second tasks indicated by the third task queue. In a specific application, taking the number of dequeue tasks as N3 and the number of second tasks indicated by the third task queue as N2 before the task enqueue event is detected as an example, after subtracting the number of dequeue tasks N3 from the number of second tasks N2, the updated number of second tasks is (N2-N3), where N2 and N3 are positive integers greater than 0, and N2 is greater than N3.

[0145] In a specific application, taking task scheduling events as either task enqueueing events or task dequeueing events, and the number of scheduled tasks as either the number of enqueueed tasks or the number of dequeueed tasks, the monitoring process for the load status of the third task queue in this embodiment can be as follows: Figure 8 As shown, when a task enqueue event is detected for the third task queue, the server accumulates the number of enqueued tasks and the second task count to update the second task count. When a task dequeue event is detected for the third task queue, the server subtracts the number of dequeued tasks from the second task count to update the second task count. After updating the second task count, the server determines a first load state based on the second task count and a preset first task count threshold, and determines the recorded load state based on multi-core task status monitoring information. If the first load state and the recorded load state differ, the multi-core task status monitoring information is updated based on the first load state.

[0146] Furthermore, such as Figure 8 As shown, the task enqueueing event can be triggered by either the unthrottle function or the task enqueueing function. The unthrottle function removes the throttle effect from the task queue. It can add tasks back to the queue if they were previously removed due to throttle, allowing them to continue running. For example, the unthrottle function could be "unthrottle_cfs_rq", a function in the Linux kernel related to CFS (Completely Fair Scheduler) bandwidth control. Its main function is to remove the throttle effect from the CFS run queue (cfs_rq), specifically the third task queue in this example. The task enqueueing function adds tasks to the task queue. It can be called within the scheduler's context, ensuring tasks are scheduled fairly. For example, the task enqueueing function could be "enqueue_task_fair", a core function of the Completely Fair Scheduler in the Linux kernel, used to add tasks (processes) to the scheduling queue.

[0147] Furthermore, such as Figure 8 As shown, task dequeueing events can be triggered by either queue rate limiting functions or task dequeueing functions. Queue rate limiting functions are functions that set the task queue to a rate-limited state, removing tasks from the queue to prevent them from continuing to run. For example, the queue rate limiting function could be "throttle_cfs_rq", an important function of the Completely Fair Scheduler (CFS) in the Linux kernel, used to rate-limit the CFS run queue (cfs_rq). Task dequeueing functions are functions used to remove tasks from the task queue. They are called within the scheduler's context, ensuring that tasks can be scheduled or paused fairly. For example, the task dequeueing function could be "dequeue_task_fair", a core function of the Completely Fair Scheduler in the Linux kernel, used to remove tasks (processes) from the scheduling queue.

[0148] In this embodiment, when a task scheduling event for the third task queue is detected, the number of scheduled tasks indicated by the task scheduling event is used to update the number of second tasks. This enables real-time updating of the number of tasks indicated by the third task queue. Thus, the first load state of the third processor core maintaining the third task queue can be determined using the second task state and a preset first task state threshold. Since the first load state is a real-time load state, by comparing the real-time load state with the recorded load state, it is possible to determine whether the recorded load state is accurate. Furthermore, when the recorded load state is inaccurate, the multi-core task state monitoring information can be updated using the real-time load state to achieve real-time monitoring of the load state.

[0149] In an exemplary embodiment, determining the first load state of the third processor core based on the second number of tasks and a preset first task number threshold includes:

[0150] If the number of second tasks is greater than or equal to the preset threshold for the number of first tasks, it is determined that the third processor core is in an overloaded state.

[0151] If the number of second tasks is less than the preset threshold for the number of first tasks, the third processor core is determined to be in a light-load state.

[0152] For example, when determining the first load state, the server compares the number of second tasks with a preset threshold for the number of first tasks, and determines the real-time load state of the third processor core, i.e., the first load state, based on the comparison result. Specifically, if the number of second tasks is greater than or equal to the preset threshold for the number of first tasks, the server can determine that the third processor core is in an overload state; if the number of second tasks is less than the preset threshold for the number of first tasks, the server can determine that the third processor core is in a light load state.

[0153] In this embodiment, by comparing the number of second tasks with a preset threshold for the number of first tasks, the first load state of the third processor core can be determined using the number of second tasks, with the preset threshold for the number of first tasks as the judgment benchmark, thereby achieving accurate judgment of the real-time load state.

[0154] In one exemplary embodiment, determining the recorded load state for the third processor core based on multi-core task status monitoring information includes:

[0155] Obtain the second status flag representing the third processor core;

[0156] Based on the second status flag, query the multi-core task status monitoring information to determine the value of the second status flag.

[0157] Based on the second status bit value, determine the load status recorded for the third processor core.

[0158] For example, the server records the status flags configured for each processor core. When it is necessary to determine the recorded load status for the third processor core, the server obtains the second status flag representing the third processor core from the recorded configuration information, queries the multi-core task status monitoring information based on the second status flag, determines the second status bit value at the second status flag, and then determines the recorded load status for the third processor core based on the second status bit value.

[0159] In practical applications, the recorded configuration information can take the form of: Status Flag 1 - Processor Core 1, Status Flag 2 - Processor Core 2, ..., Status Flag N - Processor Core N, where N is a positive integer. Status Flag 1, Status Flag 2, Status Flag N, etc., are identifiers for the status flags, indicating their position in the multi-core task status monitoring information. For example, Status Flag 1 can represent the first status flag, Status Flag 2 the second, and so on, with Status Flag N representing the Nth status flag. Processor Core 0, Processor Core 1, Processor Core 2, Processor Core N, etc., are core identifiers for the processor cores. They uniquely identify the processor core and are assigned to each processor core during the processor design phase according to core identifier allocation rules. These identifiers can be configured according to the actual application scenario.

[0160] In a specific application, when retrieving the second status flag representing the third processor core from the recorded configuration information, the server will query the configuration information based on the core identifier of the third processor core to determine the status flag corresponding to the core identifier of the third processor core from the configuration information.

[0161] In specific applications, if the second status bit value is a status bit value indicating that the load state is overloaded, the server can determine that the load state recorded for the third processor core is overloaded. If the second status bit value is a status bit value indicating that the load state is light load, the server can determine that the load state recorded for the third processor core is light load.

[0162] In this embodiment, by obtaining the second status flag bit representing the third processor core, the multi-core task status monitoring information can be queried using the second status flag bit, thereby determining the second status bit value at the second status flag bit, and then the load status recorded for the third processor core can be accurately determined using the second status bit value.

[0163] In one exemplary embodiment, determining at least one second task as the first task includes:

[0164] Based on the second task queue, determine the task attribute information of each of the multiple second tasks;

[0165] Based on the task attribute information of each of the multiple second tasks, identify the transferable tasks that are not bound to the second processor core from among the multiple second tasks;

[0166] Based on the task type of the transferable tasks, select the first task from the transferable tasks.

[0167] Task attribute information refers to information describing the various characteristics and behaviors of a task. It helps in better managing and scheduling tasks to meet different system requirements and performance goals. For example, task attribute information can specifically refer to information describing the binding relationship between a task and a processor core, such as processor affinity. Processor affinity refers to the characteristic of binding a task (process or thread) to a specific processor core or processor group (including at least two processor cores). By setting processor affinity, it can be specified that a task can only run on certain specific processor cores, rather than on arbitrary processor cores.

[0168] A portable task refers to a second task that is not bound to a second processor core and can be migrated to other processor cores for processing. A task type refers to the category of tasks determined by classifying tasks according to their characteristics and requirements. This classification helps the system better understand the resource requirements, priorities, and execution characteristics of tasks, thereby enabling the rational allocation of system resources, optimization of task execution efficiency, and satisfaction of different performance and response time requirements. For example, task types can specifically include compute-intensive tasks, I / O (Input / Output) intensive tasks, real-time tasks, interactive tasks, batch processing tasks, etc.

[0169] Computationally intensive tasks require significant processor resources and typically involve complex mathematical operations, data processing, or algorithm execution; they are best suited for high-performance processors. I / O-intensive tasks primarily involve numerous input / output operations, such as disk read / write and network communication; they are best suited for low-performance processors. Real-time tasks require completion within strict time constraints and have stringent response time requirements; they are best suited for high-performance processors. Interactive tasks require frequent user interaction and have relatively short response times; they are best suited for medium-performance processors. Batch processing tasks typically run in the background, do not require real-time interaction, and can run when the system is idle; they are best suited for low-performance processors.

[0170] For example, the server determines the task attribute information of multiple second tasks based on the second task queue, and then determines whether each second task is bound to a second processor core based on its respective task attribute information. From the multiple second tasks, it filters out the transferable tasks that are not bound to the second processor core. Based on the determined transferable tasks, the server determines the processor performance requirements of the transferable tasks according to their task types, and matches the processor performance requirements with the performance attribute information of the first processor core. From the transferable tasks, the task with matching performance attributes is selected as the first task. Here, the task with matching performance attributes can also be understood as a task that the first processor core can process.

[0171] In practical applications, processor performance requirement information indicates the processor performance information needed for a portable task. For example, processor performance requirement information can specifically be a processor performance level, such as a high-performance processor, a medium-performance processor, or a low-performance processor. The server can then match the processor performance level with the performance level attribute in the performance attribute information of the first processor core to determine the task with the matching performance attribute, i.e., the task with the matching performance level. Alternatively, processor performance requirement information can specifically be the required processor performance parameters. The server can then match the required processor performance parameters with the performance parameters in the performance attribute information of the first processor core to determine the task with the matching performance attribute, i.e., the task with the matching performance parameters.

[0172] It should be noted that a performance-level matched task refers to a task whose required processor performance level is less than or equal to the performance attribute level of the first processor core. For example, if the performance attribute level is high performance, and all transferable tasks are performance-level matched tasks, then the server can select at least one task from multiple performance-level matched tasks and designate it as the first task.

[0173] In this embodiment, the first task can be accurately selected by utilizing task attribute information and task type, taking into account the binding requirements and performance requirements of task execution.

[0174] In one exemplary embodiment, the task scheduling method further includes:

[0175] In response to monitoring information configuration events, determine the set of processor cores that share the same shared cache based on the cache attribute information of the processor cores;

[0176] For each processor core in the processor core set, configure a status flag bit representing the target processor core, and obtain the load status of the target processor core;

[0177] Based on the load state of the targeted processor core, set the status bit value at the status flag bit representing the targeted processor core;

[0178] Initial multi-core task status monitoring information is generated based on the status bit value at each status flag bit.

[0179] Among these, monitoring information configuration events refer to events that configure multi-core task status monitoring information. For example, monitoring information configuration events can be triggered during computer system initialization or based on user needs. Processor core cache attribute information refers to detailed information describing the cache relationships between processor cores. This information helps the operating system and applications better understand the processor architecture, thereby optimizing task scheduling, resource allocation, and performance. For example, cache attribute information may specifically include cache architecture information, core-cache mapping rules, and mapping tables between core identifiers and cache partitions.

[0180] The cache architecture information determines the architecture of the cache shared by the processor cores. For example, it determines whether the L3 cache shared by the processor cores is fully shared or partitioned. The mapping rules between cores and caches define the mapping relationship between processor cores and caches and are planned during hardware design. For example, in the case of partitioned L3 cache, it specifies which cache partition the processor core is mapped to. The mapping table between core identifiers and cache partitions defines the cache partition corresponding to each core identifier.

[0181] For example, in response to a monitoring information configuration event, the server divides the processor cores based on the cache attribute information of the processor cores throughout the system, and determines the set of processor cores sharing the same shared cache. For each processor core in the set, the server configures a status flag representing the processor core, obtains the number of third tasks indicated by the task queue of the processor core, determines the load status of the processor core based on the number of third tasks, sets the status bit value at the status flag representing the processor core based on the load status, and finally generates initial multi-core task status monitoring information corresponding to the shared cache shared by the set of processor cores based on the status bit value at each status flag.

[0182] In practical applications, the server can bind the core identifier of the target processor core to the identifier of the status flag bit to configure the status flag bit of the target processor core, and record the bound core identifier and the identifier of the status flag bit in the configuration information, that is, generate a new record in the configuration information, which can be in the form of status flag bit identifier - core identifier.

[0183] In practical applications, if the cache shared by processor cores is determined to be fully shared based on cache attribute information, the server will determine that all processor cores share the same shared cache, meaning the processor core set includes all processor cores. If the cache shared by processor cores is determined to be partitioned shared based on cache attribute information, the server will determine that a portion of the processor cores share each cache partition (i.e., the same shared cache) as the processor core set, meaning the number of processor core sets is the same as the number of cache partitions.

[0184] In practical applications, the server is pre-set with status bit values ​​representing overload and light load states. After determining the load state of the target processor core, the status bit value representing the status flag of the target processor core can be set directly according to the load state of the target processor core. That is, if the target processor core is in an overload state, the status bit value representing the overload state is set, and if the target processor core is in a light load state, the status bit value representing the light load state is set.

[0185] In this embodiment, in response to a monitoring information configuration event, the cache attribute information of the processor cores can be used to determine the set of processor cores sharing the same shared cache, thereby allowing for separate processing for each set of processor cores. For each processor core in the set, by configuring a status flag representing the target processor core and obtaining the load status of the target processor core, and setting the status bit value at the status flag representing the target processor core based on the load status, the load status of the represented processor core can be maintained using the status bit value at the status flag. Furthermore, by generating initial multi-core task status monitoring information based on the status bit value at each status flag, the load status of each of the multiple processor cores in the set of processor cores sharing the same shared cache can be maintained.

[0186] In one exemplary embodiment, obtaining the load status of a targeted processor core includes:

[0187] Get the number of third tasks indicated by the task queue for the target processor core;

[0188] If the number of third tasks is less than the preset threshold for the number of first tasks, it is determined that the target processor core is in a light-load state.

[0189] If the number of third tasks is greater than or equal to the preset threshold for the number of first tasks, the processor core being targeted is determined to be in an overload state.

[0190] For example, when determining the load state of a target processor core, the server first obtains the number of third tasks indicated by the task queue of the target processor core, compares the number of third tasks with a preset first task number threshold. If the number of third tasks is less than the preset first task number threshold, the server determines that the target processor core is in a light-load state. If the number of third tasks is greater than or equal to the preset first task number threshold, the server can determine that the target processor core is in an overload state.

[0191] In practical applications, when obtaining the number of third tasks indicated by the task queue for a specific processor core, the server can first obtain the scheduler's debugging information, and then use the core identifier of the specific processor core to query the debugging information to obtain the number of third tasks. It's understandable that the debugging information contains detailed debugging information for each processor core, and the number of third tasks can be obtained through the field representing the number of tasks indicated by the task queue. For example, taking the entire system as a Linux system, the field representing the number of tasks indicated by the task queue can be the `nr_running` field. In the debugging information, the `nr_running` field can be in the form: `nr_running: number`, where the number is the number of tasks. It's understandable that the method for directly obtaining the number of first and second tasks can be the same as the method for obtaining the number of third tasks, or other methods can be used.

[0192] In this embodiment, based on the third number of tasks indicated by the task queue of the target processor core, by comparing the third number of tasks with a preset first task number threshold, the load state of the target processor core can be determined by using the third number of tasks with the preset first task number threshold as a judgment benchmark, thereby achieving an accurate judgment of the load state of the target processor core.

[0193] In one exemplary embodiment, the task scheduling method further includes:

[0194] If at least one second task is determined to be a failure of the first task, the load balancing mechanism is triggered to obtain the load statistics of each of the multiple scheduling domains containing the first processor core.

[0195] If a first scheduling domain with an unbalanced load is determined based on load statistics, a fourth processor core that is in an overloaded state is selected from the first scheduling domain; the fourth processor core is used to process the fourth task obtained from the fourth task queue.

[0196] At least one of the fourth tasks is identified as the first task, and an updated first task queue is obtained, so that the first task is processed by the first processor core according to the updated first task queue.

[0197] Load balancing is a computer system technology used to distribute workloads across computers (computer clusters), network connections, CPUs (Central Processing Units), disk drives, or other resources to optimize resource utilization, maximize throughput, minimize response time, and avoid overload. Replacing a single component with multiple server components equipped with load balancing improves reliability through redundancy. Its main function is to rationally distribute a large number of jobs across multiple processing units for execution, addressing the high concurrency and high availability challenges in internet architectures.

[0198] In a scheduling domain, a logical grouping of processor cores defines which processor cores can cooperate for load balancing. Each scheduling domain contains a group of processor cores and can nest multiple subdomains. The main purpose of scheduling domains is to organize processor cores into a hierarchical structure so that the scheduler can allocate tasks more efficiently based on hardware topology and load conditions. Scheduling domains typically have a hierarchical structure, with each level called a scheduling domain level. Common levels include: physical core level, NUMA (Non-Uniform Memory Access) node level, and system level. At the physical core level, logical cores (such as hyper-threads) on the same physical core belong to the same scheduling domain. At the NUMA node level, all physical cores within the same NUMA node belong to the same scheduling domain. At the system level, all processor cores in the entire system belong to the same top-level scheduling domain.

[0199] Load statistics refer to load-related information used by the scheduler to make load balancing decisions. Specifically, load statistics may include the number of tasks indicated in the task queues of each processor core within the scheduling domain, the load weights of each processor core within the scheduling domain, and the execution clock. The load weights reflect the load status of the processor cores, while the execution clock measures the execution time of the processor cores.

[0200] The fourth task queue refers to the task queue associated with the fourth processor core, that is, the task queue bound to the fourth processor core. The fourth processor core is used to process the fourth tasks obtained from the fourth task queue. The fourth task refers to the task waiting to be processed by the fourth processor core.

[0201] For example, if at least one second task is determined to be a failure of the first task, indicating a failure to migrate the second task, the server will trigger a load balancing mechanism. It will obtain load statistics for each of the multiple scheduling domains containing the first processor core, determine whether there is a first scheduling domain with an unbalanced load based on the load statistics, and if so, select a fourth processor core that is overloaded from the first scheduling domain. At least one fourth task will then be designated as the first task, resulting in an updated first task queue. The first processor core will then process the first task according to the updated first task queue. Specifically, the fourth processor core is designated to obtain and process the fourth task based on the fourth task queue.

[0202] In practical applications, a failure to migrate the second task indicates that the first processor core did not acquire the first task. Specifically, this could be because multiple processor cores are under light load, preventing the server from selecting a second processor core. Alternatively, even if a second processor core is selected, the pending second tasks on that core cannot be migrated to the first processor core for processing. Either of these scenarios constitutes a failure to migrate the second task.

[0203] In practical applications, for each scheduling domain, the server can determine whether the scheduling domain is under unbalanced based on the number of tasks indicated in the task queues of each processor core within the domain, and the load weight of each processor core within the domain, as found in the domain's load statistics. Specifically, the server can calculate the average load of all processor cores within the scheduling domain using the number of tasks indicated in the task queues of each processor core, and then calculate the load difference between the number of tasks indicated in the task queues of each processor core and the average load. If the load difference of a particular processor core exceeds a load difference threshold, the scheduling domain can be considered to have an unbalanced load. This load difference threshold can be configured according to the actual application scenario. For example, the load difference threshold could be 20% of the average load.

[0204] In this embodiment, if at least one second task is determined to be a failed first task, a load balancing mechanism can be triggered. Utilizing the load statistics of multiple scheduling domains containing the first processor core, the first scheduling domain with unbalanced load can be identified. This allows the selection of an overloaded fourth processor core from the first scheduling domain. By designating the fourth task awaiting processing on the fourth processor core as the first task, load balancing is achieved, enabling the first processor core to handle the designated fourth task. Throughout this process, the load balancing mechanism provides a fallback for task scheduling, ensuring its successful implementation.

[0205] In one exemplary embodiment, the task scheduling method further includes:

[0206] In response to a task selection event for the first task queue of the first processor core among multiple processor cores, if the selection of the first task fails, it is determined that there is no first task that can be processed.

[0207] If there is no first task to process, the first processor core is determined to be in an idle state.

[0208] Among them, the task selection event refers to the event in which the first task is selected for execution based on the first task queue of the first processor core.

[0209] For example, in response to a task selection event for a first task queue of a first processor core among a plurality of processor cores, the server selects a first task to run based on the first task queue. If the selection of the first task fails, it can be determined that there is no first task that can be processed for the first processor core, and the server can then determine that the first processor core is in an idle state.

[0210] In practical applications, after the first processor core has finished executing its current task, the server can trigger a task selection event through a function that indicates task selection, and select the first task to execute based on the first task queue of the first processor core. In this case, the server can determine whether there is a processable first task by checking the function's return value. If the function returns an empty value, it means that the selection of the first task failed. Taking Linux as an example, the function that indicates the selection of the first task can be the "pick_next_task" function, which selects the most suitable task from the current run queue to run. This function is the core part of the scheduler, and its specific implementation will vary depending on different scheduling policies (such as the Completely Fair Scheduler (CFS), the Real-Time Scheduler, etc.). In practical applications, the server can also determine whether there is a processable first task in the first task queue by obtaining the queue information. If the queue information indicates that the first task queue is empty, it means that there is no processable first task.

[0211] In this embodiment, in response to a task selection event for the first task queue of the first processor core among multiple processor cores, a first task is selected to run according to the first task queue. If the selection of the first task fails, it can be accurately determined that there is no first task available for processing, thereby enabling accurate determination that the first processor core is in an idle state.

[0212] In one exemplary embodiment, processing a first task by a first processor core according to an updated first task queue includes:

[0213] The first task is obtained from the updated first task queue through the first processor core, and the first task is processed based on the task data related to the first task in the shared cache.

[0214] Task data refers to the data required to process the first task. Specifically, task data can include at least one of the following: instruction code, data variables, constant data, task context information, configuration data, and parameter data.

[0215] For example, the server can obtain a first task from the updated first task queue through the first processor core, and process the first task based on the task data related to the first task in the shared cache.

[0216] In specific applications, when at least one second task is determined as the first task, if the first task queue stores the first task itself waiting to be processed, then at least one second task will be moved to the first task queue as the first task, and the updated first task queue will be obtained. The server can obtain the first task from the first task queue and process the first task according to the task data related to the first task in the shared cache.

[0217] In a specific application, if the first task queue stores the task description information of the first task, then the task description information of at least one second task will be stored in the first task queue to obtain the updated first task queue. The server can obtain the first task based on the task description information in the first task queue and process the first task based on the task data related to the first task in the shared cache.

[0218] It should be noted that when at least one fourth task is determined as the first task, the processing method is the same as when at least one second task is determined as the first task, and will not be repeated here in this embodiment.

[0219] In this embodiment, by using a first processor core that shares the same shared cache with the second processor core, other tasks identified as the first task are processed based on the task data in the shared cache. Relying on cache consistency, data hit efficiency can be accelerated and execution efficiency can be improved.

[0220] In an exemplary embodiment, the task scheduling method of this application is described using an example of a high-concurrency multithreaded scenario.

[0221] The inventors believe that in recent years, with the growth of massive amounts of data, large-scale server applications have become increasingly widespread, server specifications have become larger, and the number of processor cores has also increased. Efficiently utilizing multi-core processors with multiple processor cores has become a challenge in many business scenarios. Traditional technologies typically control processor core usage based on control group functionality and Completely Fair Scheduler (CFS). Control group functionality can control task processor affinity, binding tasks to specific processor cores, thus controlling the usage of multiple processor cores within the shared scope of the same shared cache. CFS is primarily used to perceive the load of tasks on multiple processor cores to achieve fair scheduling and load balancing. While control group functionality has brought some benefits to fully utilizing processor resources, it cannot solve the problem of uneven processor resource allocation. Group control technology can control task processor affinity, controlling processor core usage within a shared cache (specifically, a L3 cache), preventing cross-shared cache access. However, limitations are also obvious. For example, container instance sizes are limited, preventing full utilization of processor resources, and the use of different instance sizes inevitably leads to cross-shared cache issues. Control groups are a feature of the operating system kernel used to limit, control, and isolate the resources (such as CPU, memory, disk I / O, etc.) of a process group.

[0222] For example, the AMD CCD (AMD Core Chipplet Die) architecture typically shares a single L3 cache with 8 to 16 cores. Therefore, if instance specifications exceed this limit, issues can easily arise due to cross-cache usage. Furthermore, there are inherent limitations. Because load balancing's stringent conditions cannot effectively balance task distribution across processor cores within the same L3 cache, these factors cannot be completely resolved simply by controlling group functionality for core binding and limiting. Specifically, controlling group functionality only restricts the number of cores used; it doesn't address the issue of uneven processor core load across the L3 cache. Moreover, its applicability is poor; different platforms have different numbers of processor cores, and core binding strategies vary. Furthermore, core binding cannot fully and efficiently utilize the server's processor core resources, easily leading to uneven resource allocation.

[0223] In addition, even within the same shared cache, the Completely Fair Scheduler (CFS) cannot accurately perceive the load of tasks on multiple processor cores. Furthermore, due to various condition judgments, the success rate of task migration on processor cores within the same shared cache is very low, and it will frequently enter a load balancing state, resulting in long task scheduling time and low task scheduling efficiency.

[0224] In summary, the traditional core-binding approach for task scheduling based on group control can only address processor resource allocation and prevent severe processor core contention among multiple business instances. However, it does not solve the problem of cross-level 3 cache access, especially for large-scale instances. Furthermore, it has certain limitations in deployment and use. The core-binding strategy restricts the use of processor cores, failing to fully utilize server resources. Moreover, this approach cannot be reflected in load balancing. When a processor core on the same level 3 cache has no tasks, it will still enter the load balancer, scanning all scheduling domains, resulting in scheduling time consumption that is not effectively resolved.

[0225] Based on this, this application proposes a task scheduling method. In high-concurrency multi-threaded scenarios, based on the principle of multi-threaded data sharing, and by optimizing the Completely Fair Scheduling (CFS) strategy, when a processor core sharing the same cache with other processor cores (i.e., the first processor core) has no first task to process (i.e., the first task queue is in an idle state), and before the load balancing mechanism is about to be triggered, it attempts to obtain a second task from a processor core in an overloaded state (i.e., the second processor core) in the shared cache and assign it to the first processor core for processing. This allows tasks to share the same shared cache in a timely manner, minimizing the frequency of cross-shared cache access. Furthermore, by efficiently maintaining the running status (i.e., load status) of each processor core under the shared cache, the lookup efficiency is improved, and tasks can be quickly retrieved. This method is more efficient and less time-consuming than entering load balancing and finding a suitable task to run. It can further reduce the problem of buffer misses when accessing cross-shared cache, thereby improving business performance. In database business testing, QPS (Queries Per Second) performance was improved by up to 13%. In addition, a control group granularity control function was added, which can be used to select the business that needs to be optimized, providing high flexibility.

[0226] It should be noted that the core idea of ​​the task scheduling method in this application is to minimize frequent cross-cache (specifically, the L3 cache) operations by multiple tasks, but not to completely prohibit them. Otherwise, this would lead to excessive load imbalance, resulting in some processor cores under shared caches being too idle and in a "starved" state, while others under shared caches are too "saturated," causing multi-task blocking. Neither of these situations is allowed. The task scheduling method in this application aims to accelerate the lookup of "overloaded" tasks on processor cores under shared caches. Therefore, it can be understood as an efficient way to look up tasks on processor cores under shared caches. By relying on cache consistency, it can speed up data hits, improve execution efficiency, and save time caused by frequent load balancing during scheduling.

[0227] In an exemplary embodiment, the flowchart of the task scheduling method of this application can be as follows: Figure 9 As shown, it mainly consists of three parts: The first part generates the initial structure variables of the cache shared by the processor core set (i.e., multi-core task status monitoring information), maintaining the running status (i.e., load status) of each processor core under each shared cache, that is, maintaining the structure variables of the shared cache. The second part is the running status statistics of each processor core under the shared cache, mainly used to monitor the enqueueing and dequeueing of tasks on each processor core. Specifically, it monitors the task status of the task queue on each processor core through the enqueueing and dequeueing code paths of Completely Fair Scheduler, and records it in the structure variables, that is, monitoring the number of tasks on each processor core under the shared cache. The third part is to quickly scan the structure variables to obtain task execution, mainly used to quickly pull tasks from other processor cores under the shared cache for execution when a processor core under a certain shared cache is idle. Specifically, before the processor core fails to select a suitable task and enters load balancing, it enters the processor idle inversion (i.e., the processor core changes from an idle state to an active state), quickly scans the shared cache structure variables, selects a suitable task (i.e., the second task) to run, and if task acquisition fails (i.e., migration to the second task fails), the original code execution logic is not changed, and load balancing resumes, executing according to the original code logic. Each part will be explained in detail below.

[0228] First, this application uses a shared cache structure variable (i.e., multi-core task status monitoring information) to maintain the running status (i.e., load status) of multiple processor cores under the same shared cache. For ease of statistics and searching, a bitmap approach is used. When the first processor core has no more tasks to process, the shared cache of multiple processor cores, including the first processor core, is determined before load balancing. The shared cache structure variable is obtained, and the bitmap of the overloaded processor core is maintained and used to effectively identify candidate tasks (i.e., second tasks). The first processor core is determined to obtain and process the first task from the first task queue. This is done to attempt to obtain tasks from the overloaded processor core (i.e., the second processor core) in the shared cache. To minimize search time, the first transferable task is found when traversing the bitmap. This controls the time spent searching the structure variable to an accurate O(1) range, and in the worst case, it does not exceed the number of processor cores under the shared cache.

[0229] In practical applications, structure variables can take the form of, for example... Figure 10 As shown, the structure variable contains the status bit values ​​of each of the N processor cores (e.g., ...). Figure 10Specifically, each status bit value is either 0 or 1, and each bit represents the load state of the processor core. (As shown in the image...) Figure 10 In the structure variable shown, a status bit value of 0 represents a light-load state for the processor core, and a status bit value of 1 represents an overload state. Specifically, a light-load state means that the number of tasks indicated in the processor core's task queue is less than a preset first task quantity threshold. An overload state specifically means that the number of tasks indicated in the processor core's task queue is greater than or equal to the preset first task quantity threshold. The preset first task quantity threshold can be configured according to the actual application scenario; for example, the preset first task quantity threshold can be 2. Figure 10 When scanning the structure variable shown, using the first status flag as the scan start flag, it can be directly determined that processor core 1 is the second processor core in an overloaded state. Therefore, the server can identify at least one second task as the first task, update the first task queue, and process the first task through the first processor core. Specifically, the server will obtain the first task through the first processor core based on the updated first task queue, and process the first task based on the task data related to the first task in the shared cache. In practical applications, the structure variable creation event (i.e., the monitoring information configuration event) can be triggered during system initialization. In response to the monitoring information configuration event, the server determines the set of processor cores sharing the same shared cache based on the cache attribute information of the processor cores. For each processor core in the processor core set, it configures a status flag bit representing the target processor core and obtains the third task number indicated by the task queue of the target processor core. If the third task number is less than a preset first task number threshold, it is determined that the target processor core is in a light-load state. If the third task number is greater than or equal to the preset first task number threshold, it is determined that the target processor core is in an overload state. Based on the load state of the target processor core, it sets the status bit value at the status flag bit representing the target processor core. Based on the status bit value at each status flag bit, it generates the initial structure variable of the cache shared by the set of processor cores.

[0230] Secondly, to obtain the load status of each of the multiple processor cores, the structure variable needs to be updated in real time with the number of tasks indicated in the task queues of each processor core. Thanks to the bitmap-based maintenance method, searching within the structure variable is instantaneous, so its impact on scheduling time is negligible. In specific applications, such as... Figure 11As shown, in the Completely Fair Scheduler (CFS) code execution path, the dequeueing and enqueueing status of each task queue is monitored. In the implementation, to reduce the number of calls, in the enqueueing path, if the number of tasks indicated by the task queue exceeds a preset first task number threshold, we can consider the current processor core's load state to be overloaded. This avoids repeatedly counting the number of tasks indicated by the processor core's task queue, as we don't care about or need to consider the extent of overload. In contrast, idle processor cores have no tasks to run. Therefore, for idle processor cores, as long as the number of tasks indicated by the task queue exceeds the preset first task number threshold, the load state can be considered overloaded, and there is an opportunity to pull tasks from these processor cores for execution. Therefore, we can directly set the corresponding bit (i.e., the status flag bit) in the structure variable to 1, indicating an overloaded state. Similarly, in the dequeue path, when the number of tasks indicated by the task queue of the processor core is less than the preset first task number threshold, it means that the load state of the processor core is no longer overloaded, because no more tasks can be generated. Therefore, the status bit value of the corresponding bit (i.e. status flag bit) in the structure variable can be set to 0 directly through the bitmap, indicating that it is in a light load state.

[0231] In specific applications, such as Figure 11 As shown, for task dequeueing, the server monitors the queue rate limiting function or the task dequeueing function. That is, upon detecting the queue rate limiting function or the task dequeueing function, it determines whether the processor core load status needs to be updated. For task enqueueing, the server monitors the rate limiting de-limiting function or the task enqueueing function. That is, upon detecting the rate limiting de-limiting function or the task enqueueing function, it determines whether the processor core load status needs to be updated.

[0232] In a specific application, the server monitors task scheduling events (specifically, task enqueueing or dequeueing events) for any task queue. Upon detecting a task scheduling event for the third task queue, it updates the second task count indicated by the third task queue based on the number of scheduled tasks indicated by the event. If the second task count is greater than or equal to a preset first task count threshold, the third processor core is determined to be in an overloaded state. If the second task count is less than the preset first task count threshold, the third processor core is determined to be in a lightly loaded state. A second status flag representing the third processor core is obtained. Based on the second status flag, the multi-core task status monitoring information is queried to determine the second status bit value at the second status flag. Based on the second status bit value, the recorded load status for the third processor core is determined. If the first load status differs from the recorded load status, the multi-core task status monitoring information is updated based on the first load status. In this context, the third processor core is determined to acquire and process the third task from the third task queue.

[0233] Finally, the task execution part is obtained by quickly scanning the structure variables. When the processor core (i.e., the first processor core) selects a suitable task to run from the task queue, and fails to find a suitable task to run (i.e., failure to find a suitable task), it indicates that the processor core is in an idle state and enters the processor idle inversion. This can be achieved by scanning the structure variables of the shared cache of multiple processor cores, including the first processor core, to migrate the task (the migrated task is the second task) to the first processor core for processing. The process of scanning the structure variables (i.e., the bitmap of the shared cache) can be as follows: Figure 12 As shown, when a processor core fails to acquire a task and is about to enter load balancing, it will enter processor idle inversion. The task scheduling method of this application will scan the shared cache structure variables of the current processor core (i.e., the first processor core), select the second processor core in an overloaded state from multiple processor cores, and acquire the second task from the second processor core for the first processor core to process. During the scanning of the structure variables, in order to ensure fairness, it will not always start scanning from the bitmap starting position 0, but will obtain the scanned status flag bit through the historical scan record, and start scanning from the next bitmap position after the scanned status flag bit. This ensures that the remaining bitmap positions can be scanned. Similarly, in order not to affect the load balancing characteristics of completely fair scheduling, after a scan failure, it will not exit directly, but will execute according to the original execution path of the scheduling, and enter the load balancing processing logic, that is, enter the load balancing mode. In the load balancing mode, the load situation under all scheduling domains will be scanned until all scheduling domains have completed a loop. When an unbalanced scheduling domain is found, the balance problem will be solved by task migration.

[0234] In practical applications, assuming the scanned status flag bit refers to the status flag bit of the processor core that was last successfully scanned and acquired the task (e.g., ...). Figure 12 The image shows the status flags representing processor core N. In this scan, the status flag representing processor core 1 will be used as the scan start flag. If the scan successfully acquires a task, the status flag of the last successful scan, i.e., the status flag representing processor core 2, will be recorded. In the next scan, the next status flag representing processor core 2 will be used as the scan start flag.

[0235] In practical applications, when scanning structure variables, i.e., multi-core task status monitoring information, the server, if historical scan records for multi-core task status monitoring information exist, determines the scanned status flag bit of the last scan based on the historical scan records. Based on the scanned status flag bit, it selects the scan start status flag bit. If no historical scan records for multi-core task status monitoring information exist, the first status flag bit is used as the scan start status flag bit. Based on the determined scan start status flag bit, the server starts scanning the status bit values ​​of each of the multiple processor cores. The first status bit value scanned, indicating an overloaded state, is used as the first status bit value. The first status flag bit position of the first status bit value in the multi-core task status monitoring information is determined, and the processor core represented by the first status flag bit is used as the second processor core.

[0236] Furthermore, in response to determining that at least one second task is completed as the first task, the server determines the number of first tasks indicated by the second task queue. If the number of first tasks is less than a preset threshold for the number of first tasks, the server updates the load status of the second processor core recorded in the multi-core task status monitoring information from an overload state to a light load state.

[0237] In specific applications, when at least one second task is determined to be a failure of the first task, i.e., the migration of the second task fails (e.g.) Figure 9 Specifically, this could be due to failure to enter processor idle inversion, failure to find a task, etc. The server will trigger a load balancing mechanism to obtain the load statistics of each of the multiple scheduling domains containing the first processor core. If it is determined that there is a first scheduling domain with an unbalanced load based on the load statistics, the fourth processor core that is in an overloaded state will be selected from the first scheduling domain. The fourth processor core will be determined to obtain and process the fourth task according to the fourth task queue. At least one fourth task will be determined as the first task to update the first task queue so that the first task can be processed by the first processor core.

[0238] In an exemplary embodiment, the task scheduling method of this application can be applied to common business deployment scenarios, cloud scenarios, and other application scenarios. Specifically, in business deployment scenarios, while ensuring that system performance remains unchanged, it supports multiple deployment methods, which can utilize system resources more efficiently. While ensuring that system performance does not degrade, it can increase system load, handle more user requests and data traffic, and also increase the number of deployed services, providing more functions or services. For example, in e-commerce business scenarios, the task scheduling method of this application can be combined with other deployment methods to utilize system resources more efficiently and handle more user requests and data traffic. In cloud scenarios, the task scheduling method of this application can improve the business performance of cloud scenarios while ensuring business stability, handle more data traffic, and provide more functions or services. Furthermore, the task scheduling method of this application does not require complex operations from the business and can be deployed transparently and seamlessly in cloud scenarios.

[0239] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0240] Based on the same inventive concept, this application also provides a task scheduling apparatus for implementing the task scheduling method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more task scheduling apparatus embodiments provided below can be found in the limitations of the task scheduling method described above, and will not be repeated here.

[0241] In one exemplary embodiment, such as Figure 13 As shown, a task scheduling device is provided, including: a running status monitoring module 1302, an idle core determination module 1304, an overloaded core selection module 1306, and a task migration module 1308, wherein:

[0242] The running status monitoring module 1320 is used to acquire multi-core task status monitoring information. The multi-core task status monitoring information indicates the load status of each of the multiple processor cores. The multiple processor cores share the same shared cache.

[0243] The idle core determination module 1304 is used to determine the first processor core that is in an idle state among multiple processor cores; the first processor core is used to process the first task obtained according to the first task queue;

[0244] The overload core selection module 1306 is used to select a second processor core that is in an overload state from multiple processor cores based on multi-core task status monitoring information. The second processor core is used to process the second task obtained from the second task queue.

[0245] The task migration module 1308 is used to identify at least one second task as the first task, obtain an updated first task queue, and process the first task according to the updated first task queue through the first processor core.

[0246] The aforementioned task scheduling device acquires multi-core task status monitoring information and can use this information to determine the load status of multiple processor cores sharing the same shared cache. Based on identifying the first processor core in an idle state, the device can quickly locate the second processor core in an overloaded state using the multi-core task status monitoring information. This allows at least one second task to be identified as the first task, resulting in an updated first task queue. The first processor core then processes the first task according to this updated queue. Throughout this process, by efficiently maintaining the load status of multiple processor cores under the shared cache, the device improves the efficiency of finding transferable tasks, thereby quickly pulling tasks to the idle first processor core for processing. This achieves efficient task scheduling under the shared cache, saving time caused by frequent load balancing during task scheduling and improving overall task scheduling efficiency.

[0247] In an exemplary embodiment, the multi-core task status monitoring information includes the status bit values ​​of each of the multiple processor cores. Each status bit value represents the load status of the processor core. The overload core selection module is further configured to determine a first status bit value representing an overload status based on the status bit values ​​of the multiple processor cores, determine the first status bit value in the first status flag bit of the multi-core task status monitoring information, and select the processor core represented by the first status flag bit as the second processor core.

[0248] In an exemplary embodiment, the overload core selection module is further configured to obtain the scanning start status flag bit for multi-core task status monitoring information, and scan the status bit values ​​of each of the multiple processor cores starting from the scanning start status flag bit, and take the first status bit value that represents the load state as an overload state as the first status bit value.

[0249] In an exemplary embodiment, the overload core selection module is further configured to, in the presence of historical scan records for multi-core task status monitoring information, determine the scanned status flag bit of the last recorded scan based on the historical scan records, and select the scan start status flag bit based on the scanned status flag bit.

[0250] In an exemplary embodiment, the running status monitoring module is further configured to, in response to determining that at least one second task is completed as the first task is completed, determine the number of first tasks indicated by the second task queue, and if the number of first tasks is less than a preset first task number threshold, update the load status of the second processor core recorded in the multi-core task status monitoring information from an overload state to a light load state.

[0251] In an exemplary embodiment, the running status monitoring module is further configured to, upon detecting a task scheduling event for the third task queue, update the number of second tasks indicated by the third task queue according to the number of scheduled tasks indicated by the task scheduling event, determine the first load state of the third processor core according to the number of second tasks and a preset first task number threshold, the third processor core is configured to process the third tasks obtained from the third task queue, determine the recorded load state for the third processor core according to the multi-core task status monitoring information, and update the multi-core task status monitoring information according to the first load state when the first load state is different from the recorded load state.

[0252] In an exemplary embodiment, the operation status monitoring module is further configured to determine that the third processor core is in an overload state when the number of second tasks is greater than or equal to a preset first task number threshold, and to determine that the third processor core is in a light load state when the number of second tasks is less than the preset first task number threshold.

[0253] In an exemplary embodiment, the running status monitoring module is further configured to obtain a second status flag bit representing the third processor core, query multi-core task status monitoring information based on the second status flag bit, determine the second status bit value at the second status flag bit, and determine the load status recorded for the third processor core based on the second status bit value.

[0254] In an exemplary embodiment, the task migration module is further configured to determine the task attribute information of each of the multiple second tasks according to the second task queue, determine the migrateable tasks that are not bound to the second processor core from the multiple second tasks according to the task attribute information of each of the multiple second tasks, and select the first task from the migrateable tasks according to the task type of the migrateable tasks.

[0255] In an exemplary embodiment, the runtime status monitoring module is further configured to respond to a monitoring information configuration event, determine a set of processor cores sharing the same shared cache based on the cache attribute information of the processor cores, configure a status flag bit representing the target processor core for each processor core in the processor core set, obtain the load status of the target processor core, set the status bit value at the status flag bit representing the target processor core based on the load status of the target processor core, and generate initial multi-core task status monitoring information for the cache configuration shared by the processor core set based on the status bit value at each status flag bit.

[0256] In an exemplary embodiment, the running status monitoring module is further configured to obtain the number of third tasks indicated by the task queue of the target processor core, and determine that the target processor core is in a light-load state when the number of third tasks is less than a preset first task number threshold, and determine that the target processor core is in an overload state when the number of third tasks is greater than or equal to the preset first task number threshold.

[0257] In an exemplary embodiment, the task scheduling device further includes a load balancing module. The load balancing module is used to trigger a load balancing mechanism when at least one second task is determined to be a failed first task, obtain load statistics information of each of the multiple scheduling domains containing the first processor core, and select a fourth processor core in an overloaded state from the first scheduling domain when it is determined that there is a first scheduling domain with unbalanced load based on the load statistics information. The fourth processor core is used to process the fourth task obtained according to the fourth task queue, determine at least one fourth task as the first task, obtain an updated first task queue, and process the first task according to the updated first task queue through the first processor core.

[0258] In an exemplary embodiment, the idle core determination module is further configured to respond to a task selection event for a first task queue of a first processor core among a plurality of processor cores, and if the selection of a first task fails, determine that there is no processable first task, and if there is no processable first task, determine that the first processor core is in an idle state.

[0259] In one exemplary embodiment, the task scheduling device further includes a task processing module. This module retrieves a first task from the updated first task queue via the first processor core and processes the first task based on task data related to the first task in a shared cache. Each module in the task scheduling device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of the computer device in software form, so that the processor can invoke and execute the operations corresponding to each module.

[0260] In one exemplary embodiment, a computer device is provided, which can be a server or a terminal. Taking the computer device as a server as an example, its internal structure diagram can be as follows: Figure 14 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data such as multi-core task status monitoring information. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a task scheduling method.

[0261] Those skilled in the art will understand that Figure 14 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0262] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0263] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0264] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0265] It should be noted that the data involved in this application (including but not limited to data used for analysis, data stored, data displayed, etc.) are all data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0266] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0267] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0268] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A task scheduling method, characterized in that, The method includes: Acquire multi-core task status monitoring information, which indicates the load status of each of the multiple processor cores, and the multiple processor cores share the same shared cache. A first processor core that is in an idle state is identified among the plurality of processor cores. The first processor core is used to process a first task obtained according to a first task queue. Based on the multi-core task status monitoring information, a second processor core that is in an overload state is selected from the multiple processor cores. The second processor core is used to process the second task obtained from the second task queue. At least one of the second tasks is identified as the first task, and an updated first task queue is obtained to process the first task through the first processor core according to the updated first task queue.

2. The method according to claim 1, characterized in that, The multi-core task status monitoring information includes the status bit values ​​of each of the multiple processor cores, with each status bit value representing the load status of the processor core; the step of selecting a second processor core in an overloaded state from the multiple processor cores based on the multi-core task status monitoring information includes: Based on the state bit values ​​of each of the multiple processor cores, a first state bit value representing an overload state is determined; Determine the first status bit value, which is the first status flag bit in the multi-core task status monitoring information; The processor core represented by the first status flag is used as the second processor core.

3. The method according to claim 2, characterized in that, The step of determining a first state bit value representing an overload state based on the state bit values ​​of the plurality of processor cores includes: Obtain the scan start status flag for the multi-core task status monitoring information; Starting from the scan start status flag, scan the status bit values ​​of each of the plurality of processor cores; The first state bit value that indicates an overload state is scanned is taken as the first state bit value.

4. The method according to claim 3, characterized in that, The step of obtaining the scan start status flag for the multi-core task status monitoring information includes: If there are historical scan records for the multi-core task status monitoring information, determine the scanned status flag bit of the last scan recorded based on the historical scan records. Select the scan start status flag based on the scanned status flag.

5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: In response to determining that at least one of the second tasks is completed as the first task is completed, the number of first tasks indicated by the second task queue is determined; If the number of the first tasks is less than a preset threshold for the number of the first tasks, the load status of the second processor core recorded in the multi-core task status monitoring information is updated from overload status to light load status.

6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: If a task scheduling event is detected for the third task queue, the number of second tasks indicated by the third task queue is updated according to the number of scheduled tasks indicated by the task scheduling event. Based on the second number of tasks and a preset first task number threshold, the first load state of the third processor core is determined; the third processor core is used to process the third tasks obtained from the third task queue. Based on the multi-core task status monitoring information, determine the load status recorded for the third processor core; When the first load state differs from the recorded load state, the multi-core task status monitoring information is updated based on the first load state.

7. The method according to claim 6, characterized in that, The step of determining the first load state of the third processor core based on the second number of tasks and a preset first task number threshold includes: If the number of the second task is greater than or equal to the preset threshold for the number of the first task, it is determined that the third processor core is in an overload state. If the number of the second task is less than the preset threshold for the number of the first task, the third processor core is determined to be in a light-load state.

8. The method according to claim 6, characterized in that, The step of determining the load status recorded for the third processor core based on the multi-core task status monitoring information includes: Obtain the second status flag bit representing the third processor core; Based on the second status flag, query the multi-core task status monitoring information to determine the value of the second status flag at the second status flag. Based on the second status bit value, the load status recorded for the third processor core is determined.

9. The method according to any one of claims 1 to 8, characterized in that, The step of identifying at least one of the second tasks as the first task includes: Based on the second task queue, determine the task attribute information of each of the multiple second tasks; Based on the task attribute information of each of the multiple second tasks, determine the transferable tasks that are not bound to the second processor core from among the multiple second tasks; Based on the task type of the transferable task, select the first task from the transferable tasks.

10. The method according to any one of claims 1 to 9, characterized in that, The method further includes: In response to monitoring information configuration events, determine the set of processor cores that share the same shared cache based on the cache attribute information of the processor cores; For each processor core in the processor core set, configure a status flag bit representing the target processor core, and obtain the load status of the target processor core; Based on the load state of the targeted processor core, set the state bit value at the state flag bit representing the targeted processor core; Initial multi-core task status monitoring information is generated based on the status bit value at each status flag bit.

11. The method according to claim 10, characterized in that, The step of obtaining the load status of the targeted processor core includes: Obtain the third number of tasks indicated by the task queue of the target processor core; If the number of the third tasks is less than a preset threshold for the number of the first tasks, it is determined that the targeted processor core is in a light-load state. If the number of the third task is greater than or equal to the preset threshold for the number of the first task, it is determined that the processor core being targeted is in an overload state.

12. The method according to any one of claims 1 to 11, characterized in that, The method further includes: If at least one of the second tasks is determined to be a failure of the first task, a load balancing mechanism is triggered to obtain load statistics information for each of the multiple scheduling domains containing the first processor core. If a first scheduling domain with unbalanced load is determined based on the load statistics, a fourth processor core that is in an overloaded state is selected from the first scheduling domain; the fourth processor core is used to process the fourth task obtained from the fourth task queue. At least one of the fourth tasks is identified as the first task, and an updated first task queue is obtained to process the first task by the first processor core according to the updated first task queue.

13. The method according to any one of claims 1 to 12, characterized in that, The method further includes: In response to a task selection event for a first task queue of a first processor core among the plurality of processor cores, if the selection of a first task fails, it is determined that there is no first task that can be processed. If there is no first task to process, the first processor core is determined to be in an idle state.

14. The method according to any one of claims 1 to 13, characterized in that, The step of processing the first task through the first processor core according to the updated first task queue includes: The first task is obtained from the updated first task queue through the first processor core, and the first task is processed according to the task data related to the first task in the shared cache.

15. A task scheduling device, characterized in that, The device includes: The running status monitoring module is used to acquire multi-core task status monitoring information, which indicates the load status of each of the multiple processor cores, and the multiple processor cores share the same shared cache. An idle core determination module is used to determine the first processor core that is in an idle state among the plurality of processor cores. The first processor core is used to process the first task obtained according to the first task queue. The overloaded core selection module is used to select a second processor core that is in an overloaded state from the multiple processor cores based on the multi-core task status monitoring information. The second processor core is used to process the second task obtained from the second task queue. A task migration module is used to identify at least one second task as the first task, obtain an updated first task queue, and process the first task through the first processor core according to the updated first task queue.

16. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 14.

17. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 14.

18. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 14.