Method for binding processor core to application program instance and related device

By optimizing the allocation and binding of processor cores with the NUMA function enabled by multiple processors, the performance reduction problem caused by application access to memory across NUMA nodes or Sockets is solved, and the performance and processor of application are improved. Resource utilization efficiency.

WO2024230416A1PCT designated stage expired Publication Date: 2024-11-14ALIBABA CLOUD COMPUTING CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/087781
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-08
Filing Date
2024-04-15
Publication Date
2024-11-14

AI Technical Summary

Technical Problem

When the processor's non-unified memory access (NUMA) function is enabled, application instances randomly bind the processor core, resulting in memory access across NUMA nodes and even across processors across different Sockets, resulting in reduced application performance.

Method used

By responding to the creation request of the application instance when the NUMA function of multiple processors is enabled, determine the number of processor cores required, obtain the assigned processor core information, and select the minimum number of processors to allocate processors for the application instance. Core, and bind it, prioritizing the allocation of processor cores within the same NUMA node or Socket to reduce memory access latency.

Benefits of technology

It effectively solves the problem of application performance degradation caused by the NUMA function opening, improves the performance of application, especially in the RDS database system, which significantly improves the utilization efficiency of processor core resources and memory access speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024087781_14112024_PF_FP_ABST
    Figure CN2024087781_14112024_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to a method for binding a processor core to an application program instance and a related device. The method comprises: when the NUMA functions of a plurality of processors are enabled, in response to a creation request of an application program instance, determining the number of processor cores required by the application program instance; acquiring information of allocable processor cores of the plurality of processors; according to the number of allocable processor cores of the plurality of processors, selecting several processors from the plurality of processors to allocate processor cores to the application program instance, and making the number of selected processors the least possible; and binding the allocated processor cores to the application program instance. The present application solves the problem of the reduction in performance of application programs caused by enabling a NUMA function, and improves the performance of application programs.
Need to check novelty before this filing date? Find Prior Art

Description

Method for binding application instance to processor core and related device

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on May 8, 2023, with application number CN202310512777.5 and invention name “Method for binding application instances to processor cores and related devices”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of computer technology, and in particular to a method for binding an application instance to a processor core and related devices. Background Art

[0003] When adapting a processor (CPU) to an application, such as a database program, and enabling the processor's non-uniform memory access (NUMA) feature, application instances are randomly bound to processor cores. This can cause the application instances to access memory across NUMA nodes or even across processors in different sockets, degrading application performance.

[0004] Summary of the Invention

[0005] The method for binding an application instance to a processor core and the related devices provided in this embodiment at least solve the problem in the related art of reduced application performance due to activation of the NUMA function.

[0006] A method for binding an application instance to a processor core, comprising:

[0007] When NUMA functions of the multiple processors are enabled, in response to a request to create an application instance, determining the number of processor cores required by the application instance;

[0008] Acquiring information about allocatable processor cores of the plurality of processors;

[0009] Selecting a number of processors from the plurality of processors according to the number of allocatable processor cores of the plurality of processors to allocate processor cores to the application instance, and minimizing the number of selected processors;

[0010] The allocated processor core is bound to the application instance.

[0011] In some embodiments, selecting a number of processors from the plurality of processors to allocate processor cores to the application instance based on the number of allocatable processor cores of the plurality of processors, and minimizing the number of selected processors comprises:

[0012] sorting the plurality of processors according to the number of allocatable processor cores of the plurality of processors;

[0013] When the number of processor cores required by the application instance is not greater than the number of allocatable processor cores of one or more processors of the plurality of processors, selecting a processor with the least number of allocatable processor cores from the one or more processors to allocate processor cores to the application instance;

[0014] When the number of processor cores required by the application instance is greater than the number of allocatable processor cores of each of the multiple processors, a processor with the largest number of allocatable processor cores is selected from the multiple processors to allocate processor cores to the application instance.

[0015] In some embodiments, each of the plurality of processors includes a plurality of NUMA nodes, each NUMA node being associated with one or more processor cores of the processor; and selecting, based on a number of allocatable processor cores of the plurality of processors, a number of processors from the plurality of processors to allocate processor cores to the application instance comprises:

[0016] Get the NUMA node information of the selected processor;

[0017] When the number of processor cores required by the application instance is not greater than the number of processor cores allocatable on one of the selected NUMA nodes, processor cores are allocated to the application instance from the allocatable processor cores on the one NUMA node.

[0018] In some embodiments, selecting a number of processors from the plurality of processors to allocate processor cores to the application instance based on the number of allocatable processor cores of the plurality of processors further includes:

[0019] When the number of processor cores required by the application instance is greater than the number of processor cores allocatable to each NUMA node in the selected processor, obtaining the affinity between processor cores and memories between any two NUMA nodes in the processor; and

[0020] According to the affinity values ​​in ascending order, two or more NUMA nodes are selected from the NUMA nodes of the processor, and processor cores are allocated to the application instance from the allocatable processor cores of the two or more NUMA nodes, wherein a smaller affinity value indicates a faster speed of processors accessing memory between each pair of NUMA nodes.

[0021] In some embodiments, obtaining information about allocatable processor cores of the plurality of processors includes:

[0022] In a case where the application instance is an application instance that shares a processor, obtaining allocated time slice ratios of the multiple processors; if the allocated time slice ratios of the multiple processors are lower than a set value, selecting a processor based on the processor load, and determining that all processor cores of the selected processor are allocatable processor cores;

[0023] In a case where the application instance is an application instance that exclusively uses a processor, idle processor cores in the multiple processors are obtained, and the idle processor cores are determined to be allocatable processor cores.

[0024] In some embodiments, binding the allocated processor core to the application instance includes:

[0025] The allocated processor core is bound to the process of the application instance through the Linux CGroup, and the binding information is written into the configuration file of the Linux CGroup.

[0026] In some embodiments, after writing the binding information into the Linux CGroup configuration file, the method further includes:

[0027] Check whether the binding information in the configuration file has taken effect;

[0028] If the binding information is not effective, the process information of the application instance corresponding to the binding information is re-acquired, the allocated processor core is bound to the re-acquired process of the application instance, and the binding information is updated to the configuration file.

[0029] In some embodiments, after writing the binding information into the Linux CGroup configuration file, the method further includes:

[0030] In a case where the application instance is an application instance that shares a processor, rebinding the application instance to the allocatable processor cores of the multiple processors according to the instance load of the application instance so as to balance the instance loads of the multiple processors; and updating the binding information of the application instance to the configuration file;

[0031] In a case where the application instance is an application instance that uses a dedicated processor, determine whether the instance load of the application instance on a single NUMA node is higher than a first load value; if the instance load of the application instance on a single NUMA node is higher than the first load value, rebind the application instance to the allocatable processor cores of multiple NUMA nodes; and update the binding information of the application instance to the configuration file.

[0032] In some embodiments, the method further comprises:

[0033] In the case where the application instance is an application instance that uses a dedicated processor, the processor cores bound to two application instances in the application instance are exchanged so that the processor core required by at least one of the application instances is bound to the processor core of a NUMA node, or the processor cores required by the two application instances are each bound to the processor core of a NUMA node.

[0034] A controller for binding an application instance to a processor core includes: a processor, and a memory for storing a program, wherein the program includes instructions, and when the instructions are executed by the processor, the processor executes any one of the above methods.

[0035] A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute any one of the methods described above.

[0036] The method and related devices for binding application instances to processor cores provided in this embodiment determine the number of processor cores required for an application instance in response to a request to create an application instance when the NUMA function of multiple processors is enabled; obtain information about allocable processor cores of the multiple processors; select several processors from the multiple processors based on the number of allocable processor cores of the multiple processors to allocate processor cores to the application instance, and minimize the number of selected processors; and bind the allocated processor cores to the application instance, thereby solving the problem of reduced application performance due to the enabling of the NUMA function and improving application performance.

[0037] The details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0039] FIG1 is a flowchart of a method for binding an application instance to a processor core according to an embodiment of the present invention.

[0040] FIG2 is a schematic diagram of the NUMA architecture of the processor of this embodiment.

[0041] FIG3 is a schematic diagram of NUMA Node affinity in this embodiment.

[0042] FIG4 is a schematic diagram of offline scheduling according to this embodiment.

[0043] FIG5 is a schematic structural diagram of the electronic device of this embodiment. DETAILED DESCRIPTION

[0044] The following describes embodiments of the present invention in more detail with reference to the accompanying drawings. Although certain embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as being limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present invention. It should be understood that the accompanying drawings and embodiments of the present invention are for illustrative purposes only and are not intended to limit the scope of protection of the present invention.

[0045] It should be understood that the various steps described in the method implementation of this embodiment can be performed in different orders and / or in parallel. In addition, the method implementation may include additional steps and / or omit the steps shown. The scope of this embodiment is not limited in this respect.

[0046] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.

[0047] It should be noted that the modifications of "one" and "multiple" mentioned in this embodiment are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".

[0048] Explanation of terms

[0049] RDS: Relational Database Service, the full English name is Relational Database Service.

[0050] CPU: The full name is Central Processing Unit. It is used to execute code and process various logic. It can be called the brain of the computer. Usually, CPU refers to the CPU Package, which is also called the physical CPU.

[0051] CPU core: A processor core is a separate execution unit within a CPU package. Currently, a CPU package typically includes multiple processing units, known as a multi-core CPU. Application instance specifications are described as xCyG, where xC (e.g., 1C, 5C, etc.) indicates that the application instance can use x processor cores, and yG indicates that the application instance can use y GB of memory.

[0052] CPU Socket: Socket for short. The CPU Package is installed on the motherboard through a slot. This slot is called a Socket. One Socket can accommodate one CPU Package.

[0053] NUMA (Non-Uniform Memory Access) is a technical architecture and also refers to the functions based on it. Under the NUMA architecture, memory and processor cores are assigned to different NUMA nodes, each with its own integrated memory controller (IMC). Within a NUMA node, communication between processor cores occurs via the IMC bus; communication between NUMA nodes occurs via the Quick Path Interconnect (QPI). The latency of QPI communication is higher than that of the IMC bus, meaning that processor cores can access memory at varying distances, described by distances.

[0054] NUMA Node: A group of processor cores and memory devices with similar distances in the NUMA architecture form a NUMA Node.

[0055] DISTANCES: In the NUMA architecture, the distance between the processor core and the memory device; also known as affinity. A processor core accesses memory within a NUMA node with the shortest distance, resulting in the fastest speed and the highest affinity. Affinity is expressed as the value of DISTANCES. Therefore, a higher affinity indicates a lower value.

[0056] Application instances that share a CPU: referred to as RDS shared instances. These instances share the CPU but not the memory or disk. CPU resources are allocated based on time slicing and the shared instance's specifications.

[0057] An application instance with dedicated CPU resources: referred to as an RDS dedicated instance; it exclusively uses CPU, memory, and disk resources.

[0058] An application is composed of various classes that do not occupy processes and memory. After the application class is instantiated, an application instance is obtained. The application instance includes one or more processes and may also include one or more threads. Processes and threads occupy processor cores and memory to run and implement corresponding functions. The application of the embodiment of the present invention can be a service program or a client program. For example, the application can be a database service program or a database client program. The processor core refers to a separate execution unit in the processor. The processor of the embodiment of the present invention includes but is not limited to a CPU or other type of processor with multiple separate execution units, such as a graphics processing unit (GPU), a tensor processing unit (TPU) or a microprocessor (MPU).

[0059] To address at least one of the issues identified in the background, this embodiment provides a method for binding an application instance to a processor core. This method is applied to a core binding controller. FIG1 is a flow chart of the method for binding an application instance to a processor core according to this embodiment. As shown in FIG1 , the process includes the following steps:

[0060] Step S101 : When NUMA functions of multiple processors are enabled, in response to a request to create an application instance, determining the number of processor cores required by the application instance.

[0061] Step S102: Acquire information on allocatable processor cores of multiple processors.

[0062] Step S103 : selecting a number of processors from the plurality of processors to allocate processor cores to the application instance according to the number of allocable processor cores of the plurality of processors, and making the number of selected processors the minimum.

[0063] Step S104: Bind the allocated processor core to the application instance.

[0064] It should be noted that the multiple processors in the above steps refer to multiple processor packages (eg, CPU Packages). In this embodiment, the term "Socket" is sometimes used to refer to a processor package.

[0065] Through the above steps, when creating an application instance, if the NUMA function of multiple processors has been enabled, processor cores are allocated according to the number of processor cores required by the application instance from the processor's allocatable cores, and the number of processors selected for the application instance is the minimum compared to any other allocation method. This ensures that an application instance is bound to the minimum number of processors (preferably one) as much as possible. This avoids binding application instances to different processors when processor core resources are sufficient, which may cause application instances to access memory across sockets, thereby improving the performance of the RDS database system.

[0066] When allocating processor cores to application instances, if the application instances are randomly assigned to processors that meet the requirements without planning the distribution of the allocable cores of the processors after the allocation is completed, the processor cores on each processor may be fragmented after the initial random allocation of processor cores to some application instances. This may result in the application instances being unable to be bound to a smaller number of processors even if the total number of processor cores can meet the requirements of the application instances. To this end, in some embodiments, in step S103, planning is also performed based on the number of allocable processor cores of each processor and the number of processor cores required by the application instances, while ensuring that the number of selected processors is minimal. For example, in step S103, multiple processors may be sorted according to the number of allocable processor cores of the multiple processors; then (Case 1), if the number of processor cores required by the application instance is not greater than the number of allocable processor cores of one or more of the multiple processors, the processor with the least number of allocable processor cores is selected from the one or more processors to allocate processor cores to the application instance.

[0067] The above steps avoid binding the application instance to the processor with the most allocatable cores. Instead, the application instance is assigned a core by selecting a suitable processor from one or more processors that can meet the application instance's core requirements, namely the processor with the fewest allocatable cores. This allows the remaining allocatable cores to be concentrated on a single processor, effectively ensuring a more reasonable binding result when binding processor cores to other application instances in the future.

[0068] Similarly, to ensure that the application instance can be bound to the minimum number of processors, if (Scenario 2) the number of processor cores required by the application instance is greater than the number of allocatable CPU cores of each of the multiple processors, then in some embodiments, the processor with the largest number of allocatable processor cores can be selected from the multiple processors to allocate processor cores to the application instance. For any unmet processor core requirements of the application instance, allocation continues based on Scenario 1 and Scenario 2 until all processor core requirements of the application instance are met.

[0069] Because the IMC bus is used to communicate between different processor cores within a NUMA node, and QPI (Quick Path Interconnect) is used for communication between NUMA nodes. The latency of QPI communication is higher than that of the IMC bus. Therefore, if an application instance can be bound to a processor core within the same NUMA node, the efficiency of the application instance in accessing memory will be optimized. In some embodiments, each of the multiple processors includes multiple NUMA nodes, and each NUMA node is associated with one or more processor cores of the processor. Then, in the above-mentioned step S103, the NUMA node information of the selected processor can be obtained; if the number of processor cores required by the application instance is not greater than the number of allocatable processor cores of a NUMA node in the selected processor, processor cores are allocated to the application instance from the allocatable processor cores of a NUMA node.

[0070] By using the above method, application instances are preferentially bound to the processor cores within a NUMA node, thereby optimizing the memory access efficiency of the application instance and further improving the performance of the RDS database system.

[0071] If the number of processor cores required by the application instance is greater than the number of processor cores that can be allocated to the NUMA node, and the application instance cannot be bound to the processor cores within a NUMA node, then in some embodiments, a neighboring NUMA node with the highest affinity to the current NUMA node may be selected based on the affinity between the processor cores and the memory between the NUMA nodes, and the remaining processor cores required by the application instance may be bound to the allocable processor cores of the neighboring NUMA node. For example, if the number of processor cores required by the application instance is greater than the number of processor cores that can be allocated to each NUMA node in the selected processor, the affinity between the processor cores and the memory between each pair of NUMA nodes in the processor is obtained; and then, in ascending order of affinity values, two or more NUMA nodes are selected from the processor's NUMA nodes, and processor cores are allocated to the application instance from the allocable processor cores of the two or more NUMA nodes, wherein a smaller affinity value indicates a faster memory access speed between the processors between each pair of NUMA nodes.

[0072] Through the above-described embodiment, application instances are preferentially bound to the allocatable processor cores of the same NUMA node. If the allocatable processor cores of a single NUMA node cannot meet the demand, the application instance is bound to the allocatable processor cores of multiple NUMA nodes of the same processor package. If the allocatable processor cores of a single processor package cannot meet the demand, the application instance is bound to the allocatable processor cores of one or more NUMA nodes of different processor packages. This approach maximizes the memory access efficiency of the processor cores bound to the application instance under current conditions, thereby improving the performance of the RDS database system.

[0073] Because application instances can be divided into two types: those that share a processor and those that exclusively own a processor, the allocatable processor cores have different meanings for these two types of application instances.

[0074] For application instances sharing a processor, whether the processor still has allocatable cores depends on whether the proportion of the processor's time slices occupied reaches the maximum allowable proportion. For example, for a processor with 100% time slices, in order to ensure system stability and cope with high-level burst tasks at the system level, a portion of the time slices may be reserved to ensure that all application instances bound to the processor's cores have the opportunity to obtain processor core execution time within the allocated time slices, while ensuring normal system operation. This maximum allowable proportion is a set value, such as 80%, 90%, or 95%.

[0075] For application instances that share a processor, as long as the allocated time ratio of the processor does not exceed the above-mentioned set value, all processor cores of the processor can be regarded as allocable processor cores, that is, application instances that share a processor can be bound to any processor core of the processor. However, in order to ensure load balancing and to ensure that the affinity of the processor cores in accessing the memory is the highest, when the loads of multiple processors (the proportion of occupied time slices) do not exceed the maximum allowed ratio, the processor with the smallest processor load can be determined and all processor cores of the processor can be determined to be allocable processor cores. When binding processor cores for application instances in a processor package, the application instance is also bound to the allocable processor cores of the same NUMA node in the processor package as much as possible according to the affinity.

[0076] Therefore, in some embodiments, obtaining information on allocatable processor cores of multiple processors includes: when the application instance is an application instance that shares a processor, obtaining the allocated time slice ratios of the multiple processors; if the allocated time slice ratios of the multiple processors are lower than a set value, selecting a processor based on the processor load, and determining that all processor cores of the selected processor are allocatable processor cores.

[0077] For an application instance that exclusively uses a processor, whether the processor still has allocatable processor cores depends on whether there are any processor cores in the processor that are not bound to any other application instance or process. Therefore, in some embodiments, obtaining information about allocatable processor cores of multiple processors includes: if the application instance is an application instance that exclusively uses a processor, obtaining idle processor cores in the multiple processors and determining the idle processor cores as allocatable processor cores.

[0078] In some embodiments, binding the allocated processor core to the application instance includes binding the allocated processor core to a process of the application instance via a Linux CGroup and writing the binding information to the Linux CGroup configuration file. By writing the binding information to the Linux CGroup configuration file, a core binding rule is formed, enabling recovery or offline scheduling of the application instance's bound core.

[0079] For example, the recovery of the core binding of an application instance based on a configuration file. In some embodiments, after the binding information is written to the configuration file of the Linux CGroup, it is possible to periodically check whether the binding information in the configuration file has taken effect; if the binding information is not effective, the process information of the application instance corresponding to the binding information is retrieved, the allocated processor core is bound to the process of the re-retrieved application instance, and the binding information is updated to the configuration file. In cases where the process of the application instance is recycled, resulting in a process restart, or the device where the processor is located is restarted, the process number of the application instance may be changed, or the binding relationship between the application instance and the processor core may become invalid. In the above manner, the recovery of the core binding of the application instance is triggered periodically or based on a machine or process restart, which can ensure that the application instance can run stably.

[0080] For example, offline scheduling of application instances is performed based on a configuration file. In some embodiments, after the binding information is written to the Linux CGroup configuration file, if the application instance is an application instance that shares a processor, the application instance is re-bound to the allocatable processor cores of multiple processors based on the instance load of the application instance to balance the instance loads of the multiple processors; and the binding information of the application instance is updated in the configuration file.

[0081] In some of the embodiments, when the application instance is an application instance that uses a dedicated processor, it is determined whether the instance load of the application instance on a single NUMA node is higher than a first load value; when the instance load of the application instance on a single NUMA node is higher than the first load value, the application instance is re-bound to the allocatable processor cores of multiple NUMA nodes; and the binding information of the application instance is updated to the configuration file.

[0082] The above embodiments are based on instance load optimization and are intended to balance instance loads on different processors or different NUMA nodes, thereby making system resource utilization more reasonable.

[0083] In other embodiments, offline scheduling of application instances based on a configuration file further includes: if the application instance is an application instance that uses a dedicated processor, swapping the processor cores bound to two application instances in the application instance, such that the processor core required by at least one of the application instances is bound to a processor core of a single NUMA node, or the processor cores required by the two application instances are each bound to a processor core of a single NUMA node. In this manner, the processor cores bound to the application instances are defragmented, thereby allowing multiple application instances currently bound to a processor core of a single processor to be concentrated onto as few NUMA nodes as possible, thereby improving memory access efficiency for the processor cores bound to the application instances.

[0084] The above-mentioned offline scheduling can be performed periodically or based on event triggering. For example, the event can be that the instance load value of the application instance is greater than a certain set value. In particular, in the case where the application instance is an application instance with a dedicated processor, the offline scheduling based on instance load is intended to disperse the processor cores bound to an application instance to multiple NUMA nodes or processors, while the offline scheduling based on processor core defragmentation is intended to concentrate the processor cores bound to an application instance to one NUMA node. That is, the above-mentioned two offline scheduling methods are opposite processes. Therefore, a critical value of the instance load value of an application instance can be set to distinguish which offline scheduling strategy to adopt.

[0085] The above embodiment will be described and illustrated below by taking a processor package with 64 processor cores as an example with reference to the accompanying drawings.

[0086] This embodiment aims to prioritize binding the processor cores required by the application instance within the NUMA Node based on the NUMA Node affinity relationship, and secondly bind them within the same Socket across NUMA Nodes, and avoid cross-Socket binding as much as possible.

[0087] Figure 2 is a schematic diagram of the NUMA architecture of the processor of this embodiment. The upper and lower figures in Figure 2 each show two sockets. Socket 0, the upper one, includes NUMA nodes 0 to 7, for a total of eight NUMA nodes. Socket 1, the lower one, includes NUMA nodes 8 to 15, for a total of eight NUMA nodes. Each NUMA node in Figure 2 includes eight cores, each of which is connected to a 5Gb memory unit via the IMC bus. Because this socket is a 64-core processor, each socket in Figure 2 has a total of 8×8 cores.

[0088] As shown in Figure 2, because NUMA Nodes 0 to 7 belong to Socket 0 and NUMA Nodes 8 to 15 belong to Socket 1, when applying for an 8-core application instance, to avoid processor cross-socket memory access, the c5 to c8 processor cores under NUMA Node 3 are not selected. Instead, the processor cores on Nodes 8 and 9 are selected.

[0089] The method for binding application instances to processor cores in this embodiment can be implemented by a computer system. The computer system may include a NUMA node collector, a processor core resource manager, an application instance core binding controller (online), and an application instance core binding controller (offline). The functions of each of these modules or units are described below.

[0090] NUMA Node Collector

[0091] Using the NUMActl instruction, which is compatible with processor chips from various manufacturers, it calculates the NUMA architecture corresponding to the processor chip, including the number of NUMA nodes and the number of processor cores in each NUMA node.

[0092] Collect processor and memory affinity within the same NUMA node and between different NUMA nodes, and within the same processor socket and between different processor sockets, and identify the critical affinity between processor and memory in cross-socket scenarios.

[0093] Identify whether there is memory inserted in the memory slots under each NUMA node. When binding memory nodes later, only the nodes with inserted memory sticks are bound.

[0094] Processor core resource manager

[0095] Maintain the number of processor cores and core numbers under each NUMA Node node.

[0096] Stores processor and memory affinity data within the same NUMA node and between different NUMA nodes, and within the same processor socket and between different processor sockets.

[0097] Maintain the allocated processor cores and control resource levels.

[0098] Application instance binding core controller

[0099] Based on the number of processor cores required by the instance specifications and the remaining processor cores on each NUMA node in the current resource manager, processor cores are allocated first within the NUMA node, then across nodes, and finally across sockets.

[0100] Use the CGroup tool to bind the allocated processor cores to the application instance processes and related threads.

[0101] CGroup is a mechanism in Linux for managing processes by group. From a user perspective, CGroup technology organizes all processes in the system into an independent tree. Each tree contains all the processes in the system. Each node of the tree is a process group, and each tree is associated with one or more subsystems. The role of the tree is to group processes, and the role of the subsystem is to operate on these groups.

[0102] Use the CGroup tool to bind the corresponding NUMA Node memory node based on the bound processor core.

[0103] Update the binding relationship between the application instance and the processor core in the local configuration file.

[0104] Application instance binding core offline controller

[0105] Based on the binding relationship between application instances and processor cores in the local configuration file, the CGroup configuration is refreshed regularly to prevent the CGroup configuration from becoming invalid due to machine restart or application instance process restart.

[0106] Analyze the binding relationship between all application instances and processor cores on the current host, defragment the processor cores, and refresh the binding relationship between application instances and processor cores.

[0107] In some embodiments, based on the above-mentioned computer system, when the application instance is an instance of a shared processor, the application instance core binding is implemented through a process including the following steps:

[0108] Step 1: Select the application instance type and create the application instance.

[0109] Step 2: Use the NUMA Node collector to obtain the NUMA architecture and socket number of the current processor.

[0110] In step 3, the processor core resource manager queries the currently available allocatable memory and the processor's sales ratio. If the memory is insufficient or exceeds the processor's maximum allowed allocated shard time ratio, the application instance creation is terminated. If resources are sufficient, a socket is randomly selected and the processor cores of the NUMA node corresponding to the socket are returned. For example, for the 64-core Socket 0 in Figure 2, the corresponding processor cores are 0 to 63, and the corresponding processor cores for Socket 1 are 65 to 127.

[0111] In step 4, the application instance core binding controller binds the processor core returned by the resource manager to the application instance process and the corresponding thread through the CGroup command.

[0112] Step 5: Calculate the processor ratio available to the application instance based on the application instance specifications and the number of bound processor cores. Use the CGroup command to limit processor usage. For example, if a 2-core application instance is bound to Socket 0, the processor time available to the instance is 2 / 64 of the total processor time.

[0113] In step 6, all NUMA nodes with memory sticks inserted are bound to the application instance process and the corresponding threads through CGroup, and memory usage is limited through CGroup according to the application instance specifications.

[0114] In some embodiments, based on the above-mentioned computer system, when the application instance is an instance of a dedicated processor, the application instance core binding is implemented through a process including the following steps:

[0115] Step 1: Select the application instance type and create the application instance.

[0116] Step 2: Obtain the NUMA architecture and socket number of the current processor through the NUMA Node collector.

[0117] In step 3, the NUMA node collector determines whether to identify cross-socket NUMA nodes based on the number of sockets. If the number of sockets is 1, there is no cross-socket situation. If the number of sockets is greater than 1, the NUMA node affinities are sorted and the maximum affinity is used as the condition for identifying cross-socket NUMA nodes.

[0118] Figure 3 is a schematic diagram of NUMA node affinity according to this embodiment, illustrating the affinity between the NUMA nodes of the two processors in Figure 2. In Figure 3, both the horizontal and vertical axes represent NUMA node numbers, and the values ​​represent the affinity between the NUMA nodes. It can be seen that when the affinity value reaches the maximum value of 100 (the minimum affinity), a cross-socket situation has occurred.

[0119] In step 4, the processor core resource manager queries the currently available memory and the number of processor cores that can be allocated. If the memory or the number of processor cores is insufficient, the creation of this application instance is terminated. If the resources are sufficient, the processor cores are allocated within the NUMA node based on the affinity of the processor and memory. The processor cores are then allocated across NUMA nodes within a socket, and finally across sockets.

[0120] In step 5, the application instance core binding controller binds the processor core returned by the resource manager to the application instance process and the corresponding thread through the CGroup command. Because the instance exclusively uses the processor, the instance uses 100% of the processor time.

[0121] In step 6, all NUMA nodes with memory sticks inserted are bound to the application instance process and the corresponding threads through CGroup, and memory usage is limited through CGroup according to the application instance specifications.

[0122] In some embodiments, based on the aforementioned computer system, offline scheduling of application instance core binding is implemented through a process including the following steps:

[0123] Step 1: The application instance is bound to the offline controller that starts a scheduled task to periodically check whether the CGroup configuration of the application instance is effective.

[0124] In step 2, if a machine or process restart causes the process ID in the CGroup core binding rule to change, the offline controller will obtain the latest process ID and refresh it to the CGroup core binding rule.

[0125] In step 3, the offline controller analyzes the distribution of currently allocated processor cores and rebalances resources. For shared instances, the controller balances the instances to different sockets based on the instance load. For dedicated instances, the controller distributes the highly loaded instances to different NUMA nodes.

[0126] Step 4: For dedicated instances, identify whether processor cores are allocated across sockets. Figure 4 is a schematic diagram of offline scheduling in this embodiment. As shown in Figure 4, Node3 and Node8 each allocate 5 cores to the same application instance. If the 5-core instance on Node3 is assigned to Node8, 8 cores will be idle on Node3. Through offline scheduling, the 8-core instance will be rebound to Node3.

[0127] A 64-core processor package of model FT2500 was used to stress test the database performance of an instance of mysql.x8.medium.2 (resources required are 2C16G) using the sysbench tool. When the conventional method of random core binding is used to bind the cores, the instance is bound to two cores on Node7 and Node8; when the core binding method of this embodiment is used to bind the cores, the instance is bound to two cores on Node0. The number of queries per second (QPS) at different concurrency numbers of 1 to 512 was tested under the corresponding core binding results. QPS can reflect the performance index of the database, and the higher the value, the better the performance. The test results are shown in Table 1. In the scenario where the NUMA function of the processor is turned on, compared with accessing memory across sockets, binding the application instance to a NUMA node node of a socket improves the average performance by 20% compared to binding to different NUMA nodes.

[0128] Table 1 Performance test results corresponding to different core binding methods

[0129] This embodiment further provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor. The memory stores a computer program executable by the at least one processor, wherein the computer program, when executed by the at least one processor, causes the electronic device to perform a method according to an embodiment of the present disclosure.

[0130] This embodiment further provides a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to perform the method according to the embodiment of the present disclosure.

[0131] With reference to Figure 5, a block diagram of an electronic device 500 that can serve as a server or client of the present disclosure will now be described, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0132] As shown in Figure 5, electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. Various programs and data required for the operation of device 500 can also be stored in RAM 503. Computing unit 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to bus 504.

[0133] Multiple components within electronic device 500 are connected to I / O interface 505, including an input unit 506, an output unit 507, a storage unit 508, and a communication unit 509. Input unit 506 can be any type of device capable of inputting information into electronic device 500. Input unit 506 can receive input numeric or character information and generate key input signals related to user settings and / or function control of the electronic device. Output unit 507 can be any type of device capable of presenting information and may include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. Storage unit 508 may include, but is not limited to, a magnetic disk or an optical disk. Communication unit 509 allows electronic device 500 to exchange information / data with other devices via computer networks such as the Internet and / or various telecommunication networks and may include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.

[0134] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a CPU, a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above. For example, in some embodiments, the above-described method (such as the method shown in Figure 1) may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 500 via the ROM 502 and / or the communication unit 509. In some embodiments, the computing unit 501 may be configured to perform the above-described method in any other appropriate manner (e.g., by means of firmware).

[0135] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0136] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0137] As used in this disclosure, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., a magnetic disk, an optical disk, a memory, a programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including machine-readable media that receive machine instructions as machine-readable signals. The term "machine-readable signal" refers to any signal used to provide machine instructions and / or data to a programmable processor.

[0138] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) display) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0139] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0140] Computer systems may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The client and server relationship arises through computer programs running on the respective computers and having a client-server relationship to each other.

[0141] It should be understood that the specific embodiments described herein are only used to explain this application and are not used to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0142] Obviously, the accompanying drawings are merely examples or embodiments of the present application. A person skilled in the art can also apply the present application to other similar situations based on these drawings without inventive effort. Furthermore, it is understandable that, although the work involved in this development process may be complex and lengthy, certain design, manufacturing, or production changes based on the technical content disclosed in this application are merely routine technical means for a person skilled in the art and should not be considered to constitute a deficiency in the disclosure of the present application.

[0143] The term "embodiment" as used in this application refers to specific features, structures, or characteristics described in conjunction with the embodiment that can be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily mean that the embodiment is the same, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is understood, either explicitly or implicitly, by those skilled in the art that the embodiments described in this application can be combined with other embodiments when there is no conflict.

[0144] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of patent protection. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.

Claims

1. A method for binding an application instance to a processor core, comprising: In a case where NUMA functions of the plurality of processors are enabled, in response to a request to create an application instance, determining the number of processor cores required for the application instance; Acquire information of allocatable processor cores of the plurality of processors; According to the number of allocatable processor cores of the plurality of processors, selecting a number of processors from the plurality of processors to allocate processor cores to the application instance, and minimizing the number of selected processors; The allocated processor core is bound to the application instance.

2. The method according to claim 1, wherein: According to the number of allocatable processor cores of the multiple processors, selecting a number of processors from the multiple processors to allocate processor cores to the application instance, and making the number of the selected processors minimum comprises: sorting the plurality of processors according to the number of allocatable processor cores of the plurality of processors; In a case where the number of processor cores required by the application instance is not greater than the number of processor cores that can be allocated to one or more processors of the multiple processors, selecting a processor with the least number of processor cores that can be allocated to the application instance from the one or more processors; When the number of processor cores required by the application instance is greater than the number of processor cores allocatable to each of the multiple processors, a processor with the largest number of processor cores allocatable is selected from the multiple processors to allocate processor cores to the application instance.

3. The method according to claim 1, wherein: Each of the multiple processors includes multiple NUMA nodes, and each NUMA node is associated with one or more processor cores of the processor; According to the number of allocatable processor cores of the multiple processors, selecting a number of processors from the multiple processors to allocate processor cores to the application instance comprises: Get the NUMA node information of the selected processor; When the number of processor cores required by the application instance is not greater than the number of processor cores allocatable in one of the selected processor NUMA nodes, processor cores are allocated to the application instance from the allocatable processor cores in the one NUMA node.

4. The method according to claim 3, wherein: According to the number of allocatable processor cores of the multiple processors, selecting a number of processors from the multiple processors to allocate processor cores to the application instance further comprises: When the number of processor cores required by the application instance is greater than the number of processor cores that can be allocated to each NUMA node in the selected processor, obtaining the affinity between processor cores and memories between two NUMA nodes in the processor; and Select two or more of the following from the NUMA nodes of the processor according to the order of the affinity values ​​from small to large: or more than two NUMA nodes, and allocate processor cores to the application instance from the allocatable processor cores of the two or more NUMA nodes, wherein a smaller value of the affinity indicates a faster speed at which processors between two NUMA nodes access memory.

5. The method according to claim 1, wherein: Acquiring information about allocatable processor cores of the plurality of processors includes: In the case where the application instance is an application instance of a shared processor, obtaining the allocated time slice ratio of the multiple processors; if the allocated time slice ratio of the multiple processors is lower than a set value, selecting a processor according to the processor load, and determining that all processor cores of the selected processor are allocatable processor cores; In the case that the application instance is an application instance that exclusively uses a processor, an idle processor core in the multiple processors is obtained, and the idle processor core is determined to be an allocatable processor core.

6. The method according to any one of claims 1 to 5, wherein: Binding the allocated processor core to the application instance includes: The allocated processor core is bound to the process of the application instance through Linux CGroup, and the binding information is written into the configuration file of Linux CGroup.

7. The method according to claim 6, wherein: After writing the binding information into the configuration file of the Linux CGroup, the method further includes: Check whether the binding information in the configuration file has taken effect; In the case that the binding information is not effective, the process information of the application instance corresponding to the binding information is re-acquired, the allocated processor core is bound to the re-acquired process of the application instance, and the binding information is updated to the configuration file.

8. The method according to claim 6, wherein: After writing the binding information into the configuration file of the Linux CGroup, the method further includes: In the case where the application instance is an application instance of a shared processor, rebinding the application instance to the allocatable processor cores of the multiple processors according to the instance load of the application instance so as to balance the instance loads of the multiple processors; and updating the binding information of the application instance to the configuration file; In the case where the application instance is an application instance that uses a dedicated processor, determine whether the instance load of the application instance on a single NUMA node is higher than a first load value; in the case where the instance load of the application instance on a single NUMA node is higher than the first load value, rebind the application instance to the allocatable processor cores of multiple NUMA nodes; and update the binding information of the application instance to the configuration file.

9. The method according to claim 6, wherein: The method further comprises: When the application instance is an application instance that exclusively uses a processor, the application instance is exchanged. The processor cores bound to the two application instances in the NUMA node are bound so that the processor core required by at least one of the application instances is bound to the processor core of a NUMA node, or the processor cores required by the two application instances are each bound to the processor core of a NUMA node.

10. An electronic device, comprising: A processor, and a memory storing a program, wherein the program comprises instructions which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 9.

11. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method and apparatus for unit operation multiple MySQL database examples

    CN103634344A

  • CPU resource distribution method and device under simultaneous running of multiple program examples

    CN107479976A

  • Process running method and related equipment

    CN115705247A

  • Method for binding application program instance to processor core and related equipment

    CN116700949A

  • Assigning pre-existing processes to select sets of non-uniform memory access (NUMA) aligned resources

    US20140237069A1