Method for memory localization, and related device for same

By migrating memory pages of unbound NUMA nodes to local nodes under the multi-NUMA node architecture, the problem of high memory consumption for applications is solved, the access performance is improved and the memory balance method is supplemented.

WO2025050894A1PCT designated stage expired Publication Date: 2025-03-13HANGZHOU ALICLOUD FEITIAN INFORMATION TECH CO LTD

Patent Information

Application Number
PCT/CN2024/109423
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-09-04
Filing Date
2024-08-02
Publication Date
2025-03-13

AI Technical Summary

Technical Problem

Under the multi-NUMA node architecture, the average time-consuming application that does not bind the memory of the NUMA node is high.

Method used

By determining the target container configuration group of the processor bound to the local NUMA node from the running container configuration group, determine the target memory page distributed on the remote NUMA node in the memory page of the target container configuration group, and invoke the kernel-state page migration interface in the user space to migrate the target memory page to the local NUMA node.

Benefits of technology

It improves the performance of application access memory, reduces the average access time of memory, and effectively supplements the kernel-state memory balance method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024109423_13032025_PF_FP_ABST
    Figure CN2024109423_13032025_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method for memory localization, and a related device for same. The method comprises: determining, from among container configuration groups in operation, a target container configuration group of a processor which is bound with a local NUMA node; determining, from among memory pages of the target container configuration group, a target memory page distributed on a far-end NUMA node; and calling a kernel-mode page migration interface in a user space, so as to migrate the target memory page to the local NUMA node. By means of the present disclosure, the problem of, under a multi-NUMA-node architecture, the average time taken by an application program, which is not bound with a memory of an NUMA node, for accessing the memory being long is solved, and the performance of the application program for accessing a memory is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Memory localization method and related device

[0001] This disclosure claims priority to the Chinese patent application filed with the China Patent Office on September 4, 2023, with application number 202311142971.5 and application name “Memory Localization Method and Related Devices Thereof,” the entire contents of which are incorporated by reference into this disclosure. Technical Field

[0002] The present disclosure relates to the field of computer technology, and in particular to a memory localization method and related devices. Background Art

[0003] This section is intended to provide a background or context to the embodiments of the present disclosure that are recited in the claims. No admission is made that the description herein is prior art by virtue of its inclusion in this section.

[0004] In a multi-NUMA node architecture, reading remote memory pages across NUMA nodes requires traversing the QPI bus, which takes longer than reading memory pages on the local NUMA node. This time is positively correlated with the distance between NUMA nodes. Therefore, the distribution of memory pages across NUMA nodes affects the memory access efficiency of applications. If the application is not bound to the memory of a NUMA node, the application's memory pages may be randomly distributed across NUMA nodes, resulting in higher average memory access times for the application.

[0005] Public content

[0006] The memory localization method and related devices provided by the embodiments of the present disclosure at least solve the problem of high average time consumption for applications that are not bound to NUMA nodes to access memory in a multi-NUMA node architecture in the related art.

[0007] A memory localization method, comprising:

[0008] Determine the target container configuration group bound to the processor of the local NUMA node from the running container configuration group;

[0009] Determine target memory pages distributed on a remote NUMA node among the memory pages of the target container configuration group;

[0010] A kernel-mode page migration interface is called in user space to migrate the target memory page to the local NUMA node.

[0011] In some embodiments, before determining the target memory pages in the target container configuration group that are distributed on the remote NUMA node, the method further includes:

[0012] If the target container configuration group has been bound to the memory of the local NUMA node, ending the memory localization for the target container configuration group;

[0013] In a case where the target container configuration group is not bound to a memory of the local NUMA node, a step of determining target memory pages distributed on a remote NUMA node among the memory pages of the target container configuration group is performed.

[0014] In some embodiments, before determining the target memory pages in the target container configuration group that are distributed on the remote NUMA node, the method further includes:

[0015] Obtaining the policy configuration of the target container configuration group;

[0016] If the policy configuration indicates that memory localization is not effective, end the memory localization for the target container configuration group.

[0017] When the policy is configured to enable memory locality, a step of determining target memory pages distributed on a remote NUMA node among the memory pages of the target container configuration group is performed.

[0018] In some of these embodiments,

[0019] Determining a target container configuration group of a processor bound to a local NUMA node from a running container configuration group includes: sequentially traversing the target container configuration group of the processor bound to the local NUMA node in the container configuration group running on the local node according to a set time period;

[0020] Calling a kernel-mode page migration interface in user space to migrate the target memory page to the local NUMA node includes: when traversing to obtain a plurality of target container configuration groups, migrating the target memory page of the target container configuration group to the local NUMA node relative to the target container configuration group in the order in which the target container configuration groups are traversed.

[0021] In some embodiments, before determining the target memory pages in the target container configuration group that are distributed on the remote NUMA node, the method further includes:

[0022] Obtaining the proportion of memory pages distributed on the local NUMA node in the memory pages of the target container configuration group;

[0023] If the percentage is greater than the set threshold, end the memory localization for the target container configuration group, or wait for a preset time and then return to the step of obtaining the percentage of memory pages of the target container configuration group distributed on the local NUMA node;

[0024] When the proportion is not greater than the set threshold, a step of determining target memory pages distributed on a remote NUMA node among the memory pages of the target container configuration group is performed.

[0025] In some embodiments, before determining the target memory pages in the target container configuration group that are distributed on the remote NUMA node, the method further includes:

[0026] Obtain the time interval between the last memory localization time of the target container configuration group and the current time;

[0027] If the time interval is not greater than the set interval, the memory localization for the target container configuration group is terminated, or after waiting for a preset time, the process returns to the step of obtaining the time interval between the last memory localization time of the target container configuration group and the current time;

[0028] In a case where the time interval is greater than the set interval, a step of determining target memory pages distributed on a remote NUMA node among the memory pages of the target container configuration group is performed.

[0029] In some embodiments, determining target memory pages distributed on a remote NUMA node among the memory pages of the target container configuration group includes:

[0030] The NUMA node to which the target container configuration group is bound to the processor is determined to be a local NUMA node relative to the target container configuration group, and the NUMA node to which the target container configuration group is not bound to the processor is determined to be a remote NUMA node relative to the target container configuration group.

[0031] In some embodiments, determining target memory pages distributed on a remote NUMA node among the memory pages of the target container configuration group includes:

[0032] Target memory pages distributed on the remote NUMA node are determined from memory pages corresponding to processes of preset containers in the target container configuration group, where the preset containers include application containers.

[0033] In some embodiments, the kernel-mode page migration interface is a migrate_pages interface.

[0034] An electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor, wherein the memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the electronic device performs the above-mentioned memory localization method.

[0035] A non-transitory machine-readable 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 above-mentioned memory localization method.

[0036] A computer program product includes a computer program, wherein the computer program implements the above-mentioned memory localization method when executed by a processor of a computer.

[0037] The memory localization method and related devices provided by the embodiments of the present disclosure solve the problem of high average memory access time of applications that are not bound to NUMA nodes in a multi-NUMA node architecture by determining a target container configuration group for a processor bound to a local NUMA node from a running container configuration group; determining target memory pages distributed on remote NUMA nodes among the memory pages of the target container configuration group; and calling a kernel-mode page migration interface in user space to migrate the target memory pages to the local NUMA node, thereby improving the performance of application memory access.

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

[0039] To more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present disclosure, and those skilled in the art can derive other embodiments based on these drawings without inventive effort.

[0040] FIG1 is a schematic diagram of memory page distribution of Redis on a dual-NUMA node model when memory pages are not bound according to this embodiment.

[0041] FIG2 is a comparison chart of the QPS performance of Redis in this embodiment under the conditions of fully local distribution of memory pages, random distribution of memory pages, and fully remote distribution of memory pages.

[0042] FIG3 is a flow chart of the memory localization method according to this embodiment.

[0043] FIG4 is an optional flow chart of the memory localization method of this embodiment.

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

[0045] 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.

[0046] Non-Uniform Memory Access (NUMA) is a multi-processor computer architecture and also refers to the features based on this technology. In the NUMA technology architecture, memory and processors are assigned to different NUMA nodes, each with its own integrated memory controller (IMC). Communication between processors within a NUMA node occurs via the IMC bus, while communication between NUMA nodes occurs via the Quick Path Interconnect (QPI). QPI communication has higher latency than the IMC bus, meaning that processors can access memory at different distances, described by distances. Distances are also known as affinity. Processors accessing memory within a NUMA node have the shortest distance, resulting in the fastest access and the highest affinity. Affinity is represented by the value of distances, with higher affinity indicating lower affinity.

[0047] A container configuration group refers to multiple containers configured as a group. A container configuration group is also called a Pod. Each Pod contains multiple containers. Under the NUMA technology architecture, a container configuration group (i.e., a Pod) or a container can configure the cpuset.cpus file under cgroups to restrict the processes involved in these Pods or containers to be affinity only with the processors (CPUs) of some NUMA nodes, that is, they can only run on this group of processors. This is called processor binding of the Pod or container. Similarly, a Pod or a container can configure the cpuset.mems file under cgroups to restrict the subsequent newly written memory pages of the processes involved in these Pods or containers to be distributed only on the memory devices of some NUMA nodes. This is called memory binding of the Pod or container. Among them, the handling of the existing memory depends on the configuration of cpuset.memory_migrate.

[0048] In the embodiments of the present disclosure, local and remote are relative concepts. For example, local memory and remote memory, where local memory refers to the memory distributed within the NUMA node where the processor is located, and remote memory refers to the memory distributed outside the NUMA node where the processor is located. For another example, local NUMA nodes and remote NUMA nodes are relative to Pods or containers. For any Pod or container, the NUMA node where the processor running the Pod or container is located is generally referred to as the local NUMA node relative to this Pod or container; since after the Pod or container processor is bound, the Pod or container can only run on the bound processor, that is, on the NUMA node where the bound processor is located, therefore, the NUMA node where the processor bound to the Pod or container is located is also the local NUMA node relative to this Pod or container, and other NUMA nodes except the local NUMA node are remote NUMA nodes relative to this Pod or container.

[0049] In a multi-NUMA node architecture, when a process reads remote memory across NUMA nodes (the memory and processor are on different NUMA nodes), it needs to go through the QPI bus. Compared with local memory (the memory and processor are on the same NUMA node), memory access takes longer. The distribution of remote memory will reduce the application's local memory access hit rate, affecting the memory access performance of applications (especially memory-intensive container applications such as Redis).

[0050] Taking the memory-intensive Redis application as an example, when Redis has affinity for all CPUs, the process may switch NUMA nodes during execution, meaning that the memory pages generated by the process are switched to the memory of a remote NUMA node. In this case, testing was conducted on a dual-NUMA node model. The memory page distribution is shown in Figure 1, with some memory pages distributed on remote NUMA nodes. Compared to the random and all-remote memory page distributions, the full local access Redis server achieved a 10.52% and 26.12% improvement in queries per second (QPS) performance, respectively, in stress testing, as shown in Figure 2.

[0051] In some processor load-aware scheduling technologies, the Pod is bound to one or more processors by modifying the cgroups configuration. The Pod's memory pages are then bound to the memory of the NUMA node where the processor is located, and the cpuset.memory_migrate configuration is set to 1. With the above configuration, the Pod's process is only affinity to the bound CPU, and new memory pages are only written to the specified NUMA. When a new Pod is memory bound, or an already bound Pod is rebound to a new NUMA, migration of the existing memory will be triggered to meet the memory binding rules. Although the above method is relatively simple and does not require multiple memory migrations after binding, it is not flexible enough and does not take into account the memory usage of the corresponding NUMA node when binding the CPU. When memory-intensive applications are concentrated on the same NUMA node, the memory distribution of the entire machine is uneven and the memory water level of the entire machine is low.

[0052] Building on the above, some processor load-aware scheduling technologies consider both processor and memory resources when binding pods. They also consider the current machine's memory distribution when binding processors, selecting NUMA nodes with relatively idle processors and memory. This approach reduces the likelihood of memory imbalance across the machine by taking the current memory distribution into account during binding. However, it doesn't completely address memory imbalance caused by memory emergencies.

[0053] In situations such as storage hardware failure or memory hot-plugging, kernel-mode memory migration is triggered. To improve the local memory hit rate of tasks, that is, to increase the proportion of local memory pages, kernel-mode memory balancing is performed periodically using the kernel-mode page migration interface, migrate_pages. Kernel-mode memory balancing occurs in two scenarios: When the majority of a task's memory is remote, meaning it's not on the same NUMA node as the processor currently executing the task, memory balancing doesn't actually target the memory; instead, the task is migrated to the CPU on the NUMA node where the majority of the memory resides. When the majority of a task's memory is local, meaning it's on the same NUMA node as the processor currently executing the task, memory pages on other remote NUMA nodes are migrated to the local NUMA node. As can be seen, in the first scenario, processor drift can occur. Therefore, kernel-mode memory balancing is disabled for tasks bound to processors. This means that kernel-mode memory balancing cannot be triggered for pods or containers bound to processors (for example, those using features like processor load-aware scheduling).

[0054] To address the issue of high memory access time consumption for container configuration groups with processors bound to NUMA nodes and memory pages migrated to remote NUMA nodes, this embodiment provides a memory localization method. Figure 3 is a flow chart of the memory localization method of this embodiment. As shown in Figure 3, the process includes the following steps:

[0055] Step S301: Determine a target container configuration group bound to a processor of a local NUMA node from among the running container configuration groups.

[0056] Step S302: Determine target memory pages distributed on a remote NUMA node among the memory pages of the target container configuration group.

[0057] Step S303: calling a kernel-mode page migration interface in user space to migrate the target memory page to the local NUMA node.

[0058] One or more application containers are running in the above-mentioned container configuration group, and each application instance includes multiple processes. The memory pages generated by the processes are stored in the memory of the NUMA node. The above-mentioned steps realize the localization of the target memory pages on the remote NUMA node by calling the page migration interface provided by the kernel state in the user space (also called user state, relative to the kernel (OS) state) for the target container configuration group of the processor bound to the NUMA node, thereby increasing the proportion of the memory pages of the target container configuration group distributed on the local NUMA node. When accessing the memory page, the target container configuration group can have a greater probability of hitting the memory of the local NUMA node, thereby reducing the average access time of the memory. At the same time, the memory localization method provided by the above-mentioned steps also effectively supplements the memory balancing method provided by the kernel state. In a multi-NUMA node computing system that applies the kernel state memory balancing method, it is ensured that the container configuration groups of bound processors and unbound processors can increase the proportion of local memory pages, thereby improving the performance of accessing the memory.

[0059] In some embodiments, the cpuset.cpus file under cgroups is queried to determine whether the container configuration group is bound to a processor of a NUMA node, and to obtain identification information of the NUMA node to which the processor is bound. The NUMA node to which the processor is bound is the local NUMA node relative to the container configuration group.

[0060] In some of the embodiments, after memory localization is performed, since the memory pages of the container configuration group of the memory device that is not bound to the NUMA node will be migrated to the remote NUMA node again in many cases, the above-mentioned memory localization method can be run according to a set time period. When the set time period arrives, all the running container configuration groups are traversed one by one in a certain order (such as the alphabetical order of the container configuration group identifiers, the order of the storage space occupied by the container configuration group, the order of the processor memory resource size occupied by the container configuration group, or a random order, etc.), and memory localization processing is performed on one or more container configuration groups obtained by traversal. In the case of traversing to obtain multiple target container configuration groups, when performing target memory page migration, the target memory page of each target container configuration group will also be migrated to the local NUMA node relative to the target container configuration group in the order in which the target container configuration groups are traversed.

[0061] In some embodiments, before step S302, the memory localization method further includes: if the target container configuration group is bound to the memory of the local NUMA node, ending the memory localization for the target container configuration group; if the target container configuration group is not bound to the memory of the local NUMA node, executing step S302. In the above steps, whether the target container configuration group is bound to the memory of the NUMA node can be determined by querying the cpuset.mems file under cgroups.

[0062] On the one hand, the migration of memory pages has overhead, so configuring a memory localization policy for container configuration groups can more reasonably control the container configuration groups that need memory localization to avoid unexpected overhead or avoid service performance degradation caused by excessive memory page migration overhead. On the other hand, in the scenario of mixed deployment of container configuration groups with online and offline tasks (referred to as mixed deployment), different tasks have different priorities. For example, online tasks generally have higher priority than offline tasks, and the reduced memory access performance of offline tasks has less impact on the service than online tasks. Therefore, timely memory localization of container configuration groups that execute online tasks helps improve service quality.

[0063] For example, in some embodiments, the user marks the quality of service (QoS) priority of the task, or the system determines the priority of the task by identifying the task type. After the priority of the task is obtained by a predetermined component, the component will automatically configure the memory localization policy of the container configuration group that executes the task according to the priority. Among them, the memory localization policy of the container configuration group that executes high-priority tasks is configured to be valid, while the memory localization policy of the container configuration group that executes low-priority tasks is configured to be invalid (none), so that high-priority tasks can obtain better quality of service (QoS). For the user, direct configuration of the policy of the container configuration group is avoided, and only the tasks that need to obtain better quality of service need to be concerned. In the above embodiment, the memory localization policy of the container configuration group is initially configured to be invalid (none).

[0064] In some embodiments, before step S302, the policy configuration of the target container configuration group is obtained; if the policy configuration indicates that memory localization is not effective, the memory localization for the target container configuration group is terminated; if the policy configuration indicates that memory localization is effective, step S302 is executed.

[0065] As mentioned above, memory page migration will take up system overhead, so the frequency of memory page migration should be controlled to a degree that does not significantly affect service performance. To this end, in this embodiment, the frequency of memory page migration can also be controlled through two aspects.

[0066] On the one hand, the proportion of memory pages in the target container configuration group that are distributed on the local NUMA node can be obtained. If the proportion is greater than a set threshold, the memory localization process for the target container configuration group is terminated, or the proportion of memory pages in the target container configuration group that are distributed on the local NUMA node is obtained again after a preset time period. If the proportion is not greater than the set threshold, step S302 is executed.

[0067] Alternatively, the time interval between the last memory localization time of the target container configuration group and the current time can be obtained. If the time interval is not greater than the set interval, the memory localization for the target container configuration group is terminated, or the time interval between the last memory localization time of the target container configuration group and the current time is obtained again after a preset time interval. If the time interval is greater than the set interval, step S302 is executed.

[0068] In some embodiments, determining target memory pages distributed on remote NUMA nodes among the memory pages of the target container configuration group includes: determining the NUMA node to which the processor of the target container configuration group is bound as the local NUMA node relative to the target container configuration group, and determining the NUMA node to which the processor of the target container configuration group is not bound as the remote NUMA node relative to the target container configuration group. The memory pages of the target container configuration group distributed on the remote NUMA nodes are target memory pages, i.e., remote memory pages; and the memory pages of the target container configuration group distributed on the local NUMA node are local memory pages.

[0069] The container configuration group includes task-related containers and task-independent containers. For example, the application container is a task-related container, while the init container is a container related to the startup of the container configuration group and is not task-related. The process without task-independent containers does not affect the execution efficiency of the task. Therefore, in some embodiments, when determining the target memory pages distributed on the remote NUMA node in the memory pages of the target container configuration group, the memory pages corresponding to these task-independent containers are also excluded. For example, the target memory pages distributed on the remote NUMA node are determined from the memory pages corresponding to the processes of the preset containers in the target container configuration group, and the preset containers include application containers.

[0070] In the above embodiment, the kernel-mode page migration interface called by the migratepages instruction in user space is specifically the migrate_pages interface. The migratepages instruction actually calls the kernel function migrate_pages, which can ensure data security (first ensure the successful copying of the page copy and then remapping), and is also BestEffort (migration is carried out in batches, and if the target NUMA memory is insufficient, the migration will be stopped, but no error will be thrown). If migrate_pages does not throw an error, the memory localization is successful, the local memory page ratio is calculated again, and the relevant information before and after localization is displayed. If migrate_pages throws an error, the memory localization fails, and migrate_pages itself ensures the security of the data, and displays the cause of the failure and the specific failed process ID.

[0071] FIG4 is an optional flow chart of the memory localization method of this embodiment. As shown in FIG4 , the memory localization method includes the following steps:

[0072] Step S401: Process the Pods on all nodes sequentially. If there is no CPU binding, skip the Pod.

[0073] Step S402: Check whether the Pod is configured with a memory localization-related policy. If the policy is none (default), skip the Pod.

[0074] Step S403: Analyze the memory distribution of the Pod on each NUMA node and calculate the current local memory page ratio. If it is greater than the trigger threshold, skip the Pod. Otherwise, detect the time difference from the last time the Pod's memory was localized. If it is less than the threshold, do not perform memory localization for the time being.

[0075] Step S404: Analyze the CPU binding result to obtain the IDs of the local NUMA node and the remote NUMA node. The memory migration direction is from remote to local.

[0076] Step S405: If there is no remote NUMA node, that is, the task has CPU affinity for all NUMA nodes, then the Pod is skipped.

[0077] Step S406: Get the IDs of all processes of the app container in the Pod, and skip the remaining containers, such as the init container.

[0078] Step S407 , in user mode, sequentially migrate the memory pages of the process in step S406 through the migratepages instruction.

[0079] The above-mentioned embodiments of the present disclosure migrate memory pages on the remote NUMA node of the core-bound application to the local NUMA node in a data-safe manner, improving the local memory access hit rate and providing better memory access performance for memory-intensive workloads. Furthermore, the above-mentioned embodiments of the present disclosure do not require the container configuration group to be bound to the memory of the NUMA node, making the use of the entire machine memory more flexible, improving the overall machine memory usage level, and effectively reducing the risk of application out-of-memory (OOM) or unschedulable due to memory unevenness.

[0080] In tests, using a dual-NUMA node model running Redis as an example, after CPU core binding and memory localization, Redis achieved approximately 2-10% improvement in latency and 2-13% in stress testing. The latency reduction and throughput improvement were particularly significant for large, memory-intensive applications, especially those with more than 32GB of memory.

[0081] The present disclosure also provides an electronic device, including 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, and when executed by the at least one processor, the computer program causes the electronic device to perform the memory localization method of the present disclosure.

[0082] An embodiment of the present disclosure further provides a non-transitory machine-readable medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to enable the computer to execute the memory localization method of the embodiment of the present disclosure.

[0083] An embodiment of the present disclosure further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor of a computer, the above-mentioned memory localization method is implemented.

[0084] With reference to Figure 5, a block diagram of an electronic device that can serve as a server or client of an embodiment 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.

[0085] As shown in Figure 5, the electronic device 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. In the RAM 503, various programs and data required for the operation of the electronic device can also be stored. The 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 the bus 504.

[0086] Multiple components within the electronic device are connected to the I / O interface 505, including an input unit 506, an output unit 507, a storage unit 508, and a communication unit 509. The input unit 506 can be any type of device capable of inputting information into the electronic device. The input unit 506 can receive input numeric or character information and generate key signal inputs related to user settings and / or function control of the electronic device. The output unit 507 can be any type of device capable of presenting information and can include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 508 can include, but is not limited to, a magnetic disk or an optical disk. The communication unit 509 allows the electronic device to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks, and can 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.

[0087] 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 for running 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 method embodiments of the present disclosure may be implemented as a computer 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 an electronic device via a ROM 502 and / or a 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).

[0088] The computer programs for implementing the methods of the embodiments of the present disclosure may be written in any combination of one or more programming languages. These computer programs may 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 computer programs are executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer programs may 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.

[0089] In the context of the embodiments 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 signal 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.

[0090] It should be noted that the term "including" and its variations used in the embodiments of the present disclosure are open inclusions, that is, "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". The modifications of "one" and "multiple" mentioned in the embodiments of the present disclosure are illustrative and not restrictive. Those skilled in the art should understand that unless the context clearly indicates otherwise, it should be understood as "one or more".

[0091] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or refuse.

[0092] The various steps described in the method implementations provided in the embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method implementations may include additional steps and / or omit the steps shown. The scope of protection of the present disclosure is not limited in this respect.

[0093] The term "embodiment" in this specification refers to specific features, structures or characteristics described in conjunction with the embodiment that can be included in at least one embodiment of the present disclosure. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. The various embodiments in this specification are described in a related manner, and the same or similar parts between the various embodiments are referenced to each other. In particular, for the device, equipment, and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts refer to the partial description of the method embodiment.

[0094] The above-described embodiments merely represent several implementation methods of the present disclosure. 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 disclosure, all of which fall within the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure shall be determined by the appended claims.

Claims

1. A memory localization method, comprising: Determine a target container configuration group bound to a processor of a local NUMA node from the running container configuration groups; Determine a target memory page distributed on a remote NUMA node among the memory pages of the target container configuration group; A kernel-mode page migration interface is called in user space to migrate the target memory page to the local NUMA node.

2. The method according to claim 1, wherein: Before determining the target memory pages in the target container configuration group that are distributed on the remote NUMA node, the method further includes: When the target container configuration group has been bound to the memory of the local NUMA node, ending the memory localization for the target container configuration group; In a case where the target container configuration group is not bound to the memory of the local NUMA node, a step of determining target memory pages distributed on a remote NUMA node among the memory pages of the target container configuration group is performed.

3. The method according to claim 1 or 2, wherein: Before determining the target memory pages in the target container configuration group that are distributed on the remote NUMA node, the method further includes: Obtaining the policy configuration of the target container configuration group; If the policy configuration is that memory localization is not effective, end the memory localization for the target container configuration group; When the policy is configured so that memory locality is in effect, a step of determining target memory pages distributed on a remote NUMA node among the memory pages of the target container configuration group is performed.

4. The method according to any one of claims 1 to 3, wherein: Determining a target container configuration group of a processor bound to a local NUMA node from a running container configuration group includes: sequentially traversing the target container configuration group of the processor bound to the local NUMA node in the container configuration group running on the local node according to a set time period; Calling a kernel-mode page migration interface in user space to migrate the target memory page to the local NUMA node includes: in the case of traversing to obtain a plurality of the target container configuration groups, migrating the target memory page of the target container configuration group to the local NUMA node relative to the target container configuration group in the order in which the target container configuration groups are traversed.

5. The method according to any one of claims 1 to 4, wherein: Before determining the target memory pages in the target container configuration group that are distributed on the remote NUMA node, the method further includes: Obtaining the proportion of memory pages distributed on the local NUMA node in the memory pages of the target container configuration group; When the proportion is greater than the set threshold, the memory localization for the target container configuration group is terminated, or after waiting for a preset time, the step of returning to execute the step of obtaining the proportion of memory pages distributed on the local NUMA node in the memory pages of the target container configuration group; When the proportion is not greater than the set threshold, a step of determining target memory pages distributed on a remote NUMA node among the memory pages of the target container configuration group is performed.

6. The method according to any one of claims 1 to 5, wherein: Before determining the target memory pages in the target container configuration group that are distributed on the remote NUMA node, the method further includes: Obtain the time interval between the last memory localization time of the target container configuration group and the current time; If the time interval is not greater than the set interval, the memory localization for the target container configuration group is terminated, or after waiting for a preset time, the step of returning to the step of obtaining the time interval between the last memory localization time of the target container configuration group and the current time is executed; In a case where the time interval is greater than the set interval, a step of determining target memory pages distributed on a remote NUMA node among the memory pages of the target container configuration group is performed.

7. The method according to any one of claims 1 to 6, wherein: Determining the target memory pages distributed on the remote NUMA node among the memory pages of the target container configuration group includes: The NUMA node to which the target container configuration group is bound to the processor is determined to be a local NUMA node relative to the target container configuration group, and the NUMA node to which the target container configuration group is not bound to the processor is determined to be a remote NUMA node relative to the target container configuration group.

8. The method according to any one of claims 1 to 7, wherein: Determining the target memory pages distributed on the remote NUMA node among the memory pages of the target container configuration group includes: A target memory page distributed on the remote NUMA node is determined from memory pages corresponding to processes of a preset container in the target container configuration group, wherein the preset container includes an application container.

9. The method according to any one of claims 1 to 8, wherein: The kernel-mode page migration interface is the migrate_pages interface.

10. An electronic device, comprising: at least one processor; And a memory communicatively connected to at least one processor, the memory storing a computer program executable by the at least one processor, the computer program being used to enable an electronic device to perform the memory localization method described in any one of claims 1 to 9 when executed by the at least one processor.

11. A non-transitory machine-readable medium storing a computer program, wherein: When the computer program is executed by a processor of a computer, it is used to make the computer execute the memory localization method according to any one of claims 1 to 9.

12. A computer program product, wherein: The invention comprises a computer program, which implements the memory localization method according to any one of claims 1 to 9 when being executed by a processor of a computer.

Citation Information

Patent Citations

  • Memory data access method, device and system

    CN103744799A

  • Virtual machine migrating method and system based on NUMA architecture

    CN104123171A

  • NUMA system and method of migrating pages in the system

    CN112947851A

  • Process scheduling method and computing equipment

    CN114880097A

  • Opportunistic migration of memory pages in a unified virtual memory system

    US20140281299A1

Cited By

  • Memory resource processing method and electronic equipment

    CN121050891A