A memory allocation method, device and equipment

By dynamically migrating application instances between DRAM and NVM memory and prioritizing the allocation of fast memory based on importance, the problem of low memory resource utilization is solved, thereby improving memory resource utilization and processing efficiency.

CN115421924BActive Publication Date: 2026-03-31ALIBABA (CHINA) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-29
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

In existing technologies, when both DRAM and NVM memory storage are installed in the device, the memory resource utilization rate is low, and the two types of storage resources are not effectively and rationally utilized.

Method used

By determining the importance of application instances, and based on memory access activity, application priority, and workload, instances are dynamically migrated to DRAM or NVM storage with faster data read and write speeds, prioritizing the allocation of fast memory to important instances.

Benefits of technology

It improves the utilization of memory resources, ensures the processing efficiency of important instances, and meets the processing needs of applications with high real-time requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115421924B_ABST
    Figure CN115421924B_ABST
Patent Text Reader

Abstract

Embodiments of the present specification provide a memory allocation method, device and equipment. The importance of an instance of an application program running in the current device can be determined based on one or more of the memory access activity of the instance, the priority of the application program to which the instance belongs, and the traffic volume of the application program to which the instance belongs. The instance of the application program can then be migrated between a first memory storage and a second memory storage based on the importance, so that instances with high importance are preferentially stored in the first memory storage, which has a faster data read-write speed. In this way, the utilization of memory resources can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments in this specification relate to the field of computer technology, and in particular to a memory allocation method, apparatus, and device. Background Technology

[0002] In memory-intensive scenarios where memory resources are scarce and demanding, hybrid memory technology can be employed. This involves using both traditional memory storage, such as DRAM (Dynamic Random Access Memory), and nonvolatile memory (NVM), as the device's main memory to increase storage capacity. However, current practices for devices that integrate both DRAM and NVM do not effectively utilize these two types of storage resources, and memory utilization needs improvement. Summary of the Invention

[0003] To overcome the problems existing in related technologies, this specification provides a memory allocation method, apparatus, and device.

[0004] According to a first aspect of the embodiments of this specification, a memory allocation method is provided, applicable to a target device, the target device including a first memory memory and a second memory memory, wherein the data read / write speed of the first memory memory is greater than the data read / write speed of the second memory memory, the method comprising:

[0005] Retrieves instances of one or more applications currently running on the target device;

[0006] The importance of application instances is determined, and application instances are migrated between a first memory storage and a second memory storage based on the importance, so that instances with higher importance are preferentially stored in the first memory storage. The importance is positively correlated with one or more of the following information: the memory access activity of the instance, the priority of the application to which the instance belongs, and the traffic volume of the application to which the instance belongs.

[0007] In some embodiments, determining the importance of an application instance and migrating the application instance between a first memory storage and a second memory storage based on the importance includes:

[0008] For all instances running on the target device, the importance of each instance is determined, wherein the importance of each instance is positively correlated with one or more of the following information: the memory access activity of the instance, the priority of the application to which the instance belongs, and the traffic volume of the application to which the instance belongs;

[0009] Based on the importance of each instance, target storage space is allocated to each instance in either the first memory storage or the second memory storage, wherein storage space in the first memory storage is preferentially allocated to instances with higher importance.

[0010] Based on the storage space currently occupied by each instance and the target storage space, at least one instance is migrated between the first memory storage and the second memory storage.

[0011] In some embodiments, determining the importance of an application instance and migrating the application instance between the first memory storage and the second memory storage based on the importance includes:

[0012] For each application currently running on the target device, perform the following operations in descending order of priority:

[0013] For the current application, determine the number of instances required for the current business processing of that application;

[0014] When the number of instances required for the current business processing is less than the number of instances of the current application stored in the first memory storage, the importance of each instance of the current application stored in the first memory storage is determined, and instances to be migrated are determined from each instance based on the importance and migrated to the second memory storage.

[0015] When the number of instances required for the current business processing is greater than the number of instances of the current application stored in the first memory storage, the importance of each instance of the current application stored in the second memory storage is determined, and instances to be migrated are determined from each instance based on the importance and migrated to the first memory storage; wherein, the importance is positively correlated with the memory access activity of the instance.

[0016] In some embodiments, before determining the instances to be migrated from each instance based on the importance level and migrating them to the first memory storage, the method further includes:

[0017] Determine whether the current available storage space of the first memory storage is less than the storage space occupied by the determined instance to be migrated;

[0018] If so, one or more instances of the target application stored in the first memory storage are moved to the second memory storage to free up storage space in the first memory storage, wherein the priority of the target application is lower than the priority of the current application, and the one or more instances are determined based on the importance.

[0019] In some embodiments, the target device includes multiple non-uniform memory access NUMA nodes, the first memory memory includes multiple first memory memories distributed across the multiple non-uniform memory access NUMA nodes, each non-uniform memory access NUMA node includes at least one first memory memory, and the migration of application instances between the first memory memory and the second memory memory based on the importance includes:

[0020] If it is determined, based on the importance level, that an instance of the application should be migrated from the second memory storage to the first memory storage, then the instance of the application should be migrated from the second memory storage to the first memory storage on the same non-uniform memory access NUMA node.

[0021] In some embodiments, the target device includes multiple non-uniform memory access NUMA nodes, the first memory storage includes multiple first memory storages distributed across the multiple non-uniform memory access NUMA nodes, each non-uniform memory access NUMA node includes at least one first memory storage, and the importance is negatively correlated with the degree of dispersion of the memory currently occupied by the instance across the non-uniform memory access NUMA nodes.

[0022] In some embodiments, the memory access activity of an instance is determined based on the ratio of the size of the instance's cold memory to the total memory size occupied by the instance, wherein the cold memory is a memory page that is hit less than a set number of times within a preset time period.

[0023] In some embodiments, migrating application instances between the first memory storage and the second memory storage based on the importance level includes:

[0024] For the memory pages corresponding to the instances to be migrated based on the importance level, target memory pages with a usage frequency higher than a set frequency are selected from the memory pages, and the data stored in the target memory pages is migrated between the first memory storage and the second memory storage.

[0025] In some embodiments, prior to migrating an instance of the application between the first memory storage and the second memory storage based on the importance, the method further includes:

[0026] For the processes corresponding to the instances to be migrated based on the importance level, the state of the processes is switched to a frozen state;

[0027] After migrating the application instance between the first memory storage and the second memory storage, the method further includes:

[0028] Switch the state of the process from frozen to awake.

[0029] In some embodiments, migrating application instances between the first memory storage and the second memory storage based on the importance level includes:

[0030] For instances to be migrated based on their importance, multiple threads are obtained from a pre-set thread pool, and the multiple threads are used to migrate the instances in parallel.

[0031] In some embodiments, the first memory is a dynamic random access memory (DRAM), and the second memory is a non-volatile memory (NVM).

[0032] According to a second aspect of the embodiments of this specification, a memory allocation apparatus is provided, suitable for a target device, the target device including a first memory memory and a second memory memory, wherein the data read / write speed of the first memory memory is greater than the data read / write speed of the second memory memory, the apparatus comprising:

[0033] The acquisition module is used to acquire instances of one or more applications currently running on the target device;

[0034] A migration module is used to determine the importance of an application instance and migrate the application instance between a first memory storage and a second memory storage based on the importance, so that the first memory storage preferentially stores the instance with the higher importance, the importance being positively correlated with one or more of the following information: the memory access activity of the instance, the priority of the application to which the instance belongs, and the traffic volume of the application to which the instance belongs.

[0035] According to a third aspect of the embodiments of this specification, an apparatus is provided, the apparatus comprising a plurality of non-uniform memory access NUMA nodes and a second memory storage, each non-uniform memory access NUMA node including a first memory storage, the data read / write speed of the first memory storage being greater than the data read / write speed of the second memory storage, the non-uniform memory access NUMA node being used to perform the method mentioned in the first aspect above.

[0036] The beneficial effects of the embodiments in this specification are as follows: For scenarios where a device has a first memory storage and a second memory storage, and the data read / write speed of the first memory storage is greater than that of the second memory storage, the importance of the application instances currently running on the device can be determined. Specifically, the importance of an instance can be determined based on one or more of the following: the instance's memory access activity, the priority of the application to which the instance belongs, and the workload of the application to which the instance belongs. Higher memory access activity, higher application priority, and greater current workload of the application to which the instance belongs indicate higher instance importance. Then, application instances can be migrated between the first and second memory storage based on this importance, ensuring that instances with higher importance are preferentially stored in the first memory storage. By dynamically migrating instances between the first and second memory storage based on their importance, memory with faster data read / write speeds can be preferentially allocated to instances with higher importance, ensuring the processing efficiency of these instances and improving the utilization of memory resources.

[0037] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit the embodiments of this specification. Attached Figure Description

[0038] The accompanying drawings, which are incorporated herein by reference and form part of the embodiments thereof, illustrate embodiments consistent with those described herein and, together with the description, serve to explain the principles of those embodiments.

[0039] Figure 1 This is a schematic diagram illustrating a memory allocation method as an exemplary embodiment of this specification;

[0040] Figure 2 A flowchart illustrating a memory allocation method as shown in an exemplary embodiment of this specification;

[0041] Figure 3 This is a schematic diagram illustrating an exemplary embodiment of this specification for determining an instance to be migrated;

[0042] Figure 4 This is a schematic diagram illustrating an exemplary NUMA architecture as shown in this specification.

[0043] Figure 5(a) is a schematic diagram of a target device based on a NUMA architecture, as shown in an exemplary embodiment of this specification;

[0044] Figure 5(b) is a schematic diagram illustrating concurrent migration of an instance to be migrated, as shown in an exemplary embodiment of this specification;

[0045] Figures 6(a) and 6(b) are schematic diagrams illustrating examples of migration between DRAM and NVM as shown in exemplary embodiments of this specification;

[0046] Figure 7 A logic block diagram of a memory allocation device is shown for an exemplary embodiment of this specification. Detailed Implementation

[0047] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with those described in this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the embodiments described in this specification as detailed in the appended claims.

[0048] The terminology used in the embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the embodiments of this specification. The singular forms “a,” “described,” and “the” as used in the embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0049] It should be understood that although the terms first, second, third, etc., may be used to describe various information in the embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of the embodiments of this specification, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."

[0050] In memory-intensive scenarios, such as those running online inference, in-memory databases, and search engines, which consume significant memory resources, multiple instances of the application need to be created to handle the numerous concurrent requests received. Therefore, these applications require substantial memory allocation to store these instances. Memory resources are scarce in such scenarios, especially when multiple applications are running on the device. Therefore, it is crucial to allocate memory resources efficiently, improve memory utilization, and ensure the processing efficiency of applications with high real-time requirements.

[0051] For memory-intensive scenarios, hybrid memory technology can be employed, which utilizes both traditional memory storage, such as DRAM, and nonvolatile memory (NVM) as the device's main memory to increase storage capacity. NVM's performance falls between that of DRAM and solid-state drives (SSDs). Its storage capacity is typically several times that of DRAM, and its data read speed is slightly lower than DRAM but higher than SSDs and hard disks. Adding NVM as main memory in a device can significantly increase its storage capacity while maintaining relatively fast data read speeds.

[0052] However, current methods for setting up both traditional memory storage such as DRAM and NVM in devices only increase storage space and do not make good use of the two types of storage resources. The utilization rate of memory resources still needs to be improved.

[0053] Based on this, embodiments of this specification provide a memory allocation method. For scenarios where a device has a first memory storage and a second memory storage, and the data read / write speed of the first memory storage is greater than that of the second memory storage, the importance of application instances currently running on the device can be periodically determined. When determining instance importance, it can be based on one or more of the following: the instance's memory access activity, the priority of the application to which the instance belongs, and the workload of the application to which the instance belongs. The higher the instance's memory access activity, the higher the priority of the application to which the instance belongs, and the greater the current workload of the application to which the instance belongs, the higher the instance's importance. Then, application instances can be migrated between the first and second memory storage based on this importance, so that instances with higher importance are preferentially stored in the first memory storage. By dynamically migrating instances between the first and second memory storage based on their importance, memory with faster data read / write speeds can be preferentially allocated to instances with higher importance, ensuring the processing efficiency of these instances and improving the utilization of memory resources.

[0054] The target device in the embodiments of this specification can be various electronic devices, such as mobile phones, computers, servers, or a computing node in a distributed system. The target device includes one or more first memory memories and one or more second memory memories. Of course, the target device can also be configured with one or more processors based on actual needs, wherein the data read / write speed of the first memory memory is greater than the data read / write speed of the second memory memory, that is, the processor's access speed to the first memory memory is higher than the processor's access speed to the second memory memory.

[0055] In some scenarios, the primary memory can be DRAM, SRAM, or other memory with fast data read / write speeds but small storage space, while the secondary memory can be NVM (non-volatile memory), or other memory with slightly slower data read / write speeds but larger storage space. By using a combination of DRAM and NVM, the device's storage capacity can be increased.

[0056] like Figure 1 The diagram shown is a schematic representation of a memory allocation method according to an embodiment of this specification. Figure 2 The diagram shows a flowchart of a memory allocation method according to an embodiment of this specification. When one or more applications are running on a target device, steps S202-S204 can be executed periodically to dynamically reallocate memory for each application instance running on the target device. For example, an instance migration operation can be performed at preset time intervals to reallocate memory. Alternatively, an instance migration operation can be performed when a significant change in the number of instances running on the target device is detected. For example, an instance migration operation can be performed whenever a new application starts or an application closes. Alternatively, an instance migration operation can be performed when a significant change in the application's workload is detected; the specific settings can be configured according to actual needs.

[0057] This memory allocation method may specifically include the following steps:

[0058] S202. Obtain instances of one or more applications currently running on the target device;

[0059] Each application may receive a large number of business requests at the same time. To process these requests more quickly, the same application can include multiple replicas, which are instances of the application. For example... Figure 1 As shown, application A may include instances 1-4, and application B may include instances 1-5. Each instance corresponds to a process on the operating system. Multiple received business requests can then be distributed to these multiple instances for processing. By processing these business requests in parallel, processing efficiency can be improved.

[0060] In step S202, instances of one or more applications currently running on the target device can be obtained.

[0061] S204. Determine the importance of application instances and migrate application instances between a first memory storage and a second memory storage based on the importance, so that instances with higher importance are preferentially stored in the first memory storage, the importance being positively correlated with one or more of the following information: the memory access activity of the instance, the priority of the application to which the instance belongs, and the traffic volume of the application to which the instance belongs.

[0062] In step S204, after obtaining instances of one or more applications currently running on the target device, the importance of the application instances can be determined. This importance can be determined based on one or more of the following: the instance's memory access activity, the priority of the application to which the instance belongs, and the workload of the application to which the instance belongs.

[0063] The higher the memory access activity of an instance, the more active the instance is. Such instances are usually important instances or instances with good performance, meaning they are of higher importance.

[0064] Typically, multiple applications run on the same device, and these applications have varying degrees of importance and real-time requirements for the business processes they serve. Therefore, application priorities can be determined based on the real-time requirements and importance of the business processes they serve. Higher real-time requirements and greater importance of the business processes necessitate higher application priorities. For high-priority applications, their corresponding business requests should be processed first to ensure processing efficiency. Therefore, the higher the application priority of an instance, the more important the application within that instance is.

[0065] Furthermore, the workload of each application varies at different times. For example, when an application has a high workload, it's desirable to store more instances of that application in the faster primary memory to ensure timely processing of requests. Conversely, when the workload is low, fewer instances are needed in the primary memory, freeing up storage space for other application instances that require it. Therefore, the higher the workload of the application to which an instance belongs, the more important that instance becomes. Workload can be measured by the number of requests received by the application over a period of time, such as using QPS (Queries Per Second) or TPS (Transactions Per Second).

[0066] When migrating application instances, you can compare all application instances running on the target device to determine their importance, and then perform memory allocation and instance migration accordingly. Alternatively, you can prioritize each application instance, determining its importance before allocating memory and migrating. For example, you can migrate each application instance one by one, in descending order of application priority. The factors considered when determining instance importance vary depending on the scenario. For instance, in some scenarios, only the instance's memory access activity needs to be considered. In other scenarios, it's necessary to consider the instance's memory access activity, the priority of the application to which the instance belongs, and the workload of the application.

[0067] Once the importance of application instances is determined, they can be migrated between the first and second memory storage devices based on this importance, prioritizing the storage of more important instances in the first memory storage device. This ensures that memory with faster data read / write speeds is allocated to more important instances, guaranteeing that high-priority tasks are processed first, high-volume tasks are handled promptly, and faster memory is allocated to high-performance, more active instances, thus improving memory utilization and processing efficiency.

[0068] In some embodiments, when migrating instances of an application on a target device, all instances running on the target device can be retrieved periodically, ranked by importance, and then the storage space in the first memory storage can be preferentially allocated to instances with higher importance. After the storage space in the first memory storage is allocated, the storage space in the second memory storage can be allocated. For example, the importance of each instance running on the target device can be determined individually. In this scenario, the importance of each instance can be determined based on one or more of the following: the instance's memory access activity, the priority of the application to which the instance belongs, and the workload of the application to which the instance belongs. For example, the importance of an instance can be positively correlated with one or more of the following: the instance's memory access activity, the priority of the application to which the instance belongs, and the workload of the application to which the instance belongs. After determining the importance of each instance, the storage space in the first memory storage and the second memory storage can be allocated to each instance in descending order of importance, that is, the storage space in the first memory storage can be preferentially allocated to instances with higher importance, thereby determining the target storage space for each instance. Then, based on the storage space currently occupied by each instance and the determined target storage space, each instance can be migrated between the first memory storage and the second memory storage.

[0069] For example, the instances currently running on the target device include: 3 instances of APP1 (APP1-1, APP1-2, APP1-3), 3 instances of APP2 (APP2-1, APP2-2, APP2-3), and 3 instances of APP3 (APP3-1, APP3-2, APP3-3). Then, the importance of these 9 instances can be determined based on their access activity, the priority of the application to which the instance belongs, and the current workload of the application. The storage space in the first memory is then preferentially allocated to the more important instances, assuming they are APP1-1, APP1-2, APP1-3, and APP2-1. If APP1-3 is currently stored in the second memory, it will be migrated from the second memory to the first memory according to the allocation result. Similarly, if APP3-3 is currently stored in the first memory, it will be migrated from the first memory to the second memory according to the allocation result. By periodically reallocating the memory of all instances running on the target device, it is possible to ensure that high-importance instances are in memory with fast data read and write speeds.

[0070] In some embodiments, when migrating application instances on a target device, the migration can be performed sequentially according to the application's priority from high to low, based on the current workload of each application, to prioritize meeting the business needs of applications with high priority and high workload. For example, for applications currently running on the target device, the following operations can be performed on each application sequentially according to its priority from high to low:

[0071] For the current application, the number of instances required for its current business processing can be determined. For example, the number of instances needed can be determined based on traffic volume; the higher the traffic, the more instances are required. Therefore, the required number of instances can be automatically adjusted based on traffic volume. For instance, using QPS (Queries Per Second) to measure traffic volume, for a specific application, the user can pre-set the ratio of QPS to the number of instances. For example, one instance might correspond to every 800 QPS. Therefore, if the average QPS over a certain period is 4000, it means that the current business processing requires 5 instances of that application.

[0072] After determining the number of instances required for the current business process, the instances to be migrated and their migration direction can be determined from the application's instances based on the required number of instances and the number of instances currently stored in the first memory storage. Since the first memory storage has a faster data read / write speed, instances that are currently needed should be stored there as much as possible. Instances that are not currently used can be stored in the second memory storage for later use, and then migrated from the second memory storage to the first memory storage when needed. Based on this principle, it can be determined how many instances need to be migrated from the second memory storage to the first memory storage, or vice versa, to meet the current business process's instance requirements.

[0073] Furthermore, when migrating instances, the memory access patterns of each instance can be analyzed to determine which instances are more suitable for migration. For example, instances with better performance and more active memory access should be prioritized for storage in the primary memory storage to ensure their processing efficiency. Conversely, instances with lower performance should be prioritized for storage in the secondary memory storage. Therefore, the memory resource access patterns of each instance can be further analyzed to select instances to be migrated from all instances of the application.

[0074] like Figure 3 As shown, the number of instances required for current business processing can be determined based on the application's business volume. Then, the importance of each instance can be determined based on the memory access activity of each application instance. Then, based on the number of application instances currently stored in the first memory storage, the number of instances currently required, and the importance of each instance, the instances to be migrated and the migration direction can be determined, and then the instances to be migrated can be migrated.

[0075] For example, in some scenarios, if the number of instances required for the current business processing is less than the number of instances of the current application stored in the first memory storage, it indicates that the number of instances stored in the first memory storage is excessive. Therefore, the importance of each instance of the current application stored in the first memory storage can be determined. In this scenario, the importance of an instance only needs to be determined based on its memory access activity. Then, instances to be migrated can be selected from these instances based on their importance. For example, one or more instances with lower importance can be selected as instances to be migrated and moved to the second memory storage.

[0076] For example, suppose the application's current workload determines that the current business process requires 3 instances. Therefore, running 3 instances simultaneously would meet the current business needs, and to ensure processing efficiency, these 3 instances can be stored in the faster first memory storage. However, if 5 instances are currently stored in the first memory storage, it means there are redundant instances. Therefore, the 2 least important instances can be identified from the 5 instances in the first memory storage and migrated to the second memory storage, freeing up storage space in the first memory storage for other applications that require it.

[0077] In some scenarios, if the number of instances required for the current business processing is less than the number of instances of the current application stored in the first memory storage, it means that the number of instances stored in the first memory storage cannot meet the current business needs. Therefore, the importance of each instance of the current application stored in the second memory storage can be determined based on the memory access activity of the instances. Based on the importance, the instances with high importance to be migrated are determined from each instance and migrated to the first memory storage.

[0078] For example, suppose the application's current workload determines that 5 instances are needed for processing the current business logic. Therefore, 5 instances need to run simultaneously to meet the current business logic requirements. Considering that the processor accesses the first memory storage faster, to improve the processing speed, all 5 instances should ideally be stored in the first memory storage. If only the data corresponding to 3 instances is currently stored in the first memory storage, then based on the importance of the instances, the 2 most important instances stored in the second memory storage can be selected and migrated from the second memory storage to the first memory storage to ensure the application's efficiency in processing business requests.

[0079] According to the application priority from high to low, for each application, the above method can be used to migrate the instance of the application until the storage space of the first memory storage is exhausted and there is no application with a lower priority than the current application in the first memory storage.

[0080] Of course, since the storage space of the first memory storage is often relatively small, in most scenarios, it cannot accommodate all the instances required for application business processing. Therefore, it is necessary to prioritize the business processing efficiency of high-priority applications. Thus, in some embodiments, when migrating instances of each application sequentially according to priority, if it is determined that an instance of a certain application to be migrated needs to be moved from the second memory storage to the first memory storage, before migration, it can be determined whether the current available storage space of the first memory storage is less than the storage space occupied by the determined instance to be migrated. If so, one or more instances of the target application stored in the first memory storage are moved to the second memory storage to free up storage space in the first memory storage. The priority of the target application is lower than that of the current application, and the one or more instances can also be determined based on the importance of each instance of the target application stored in the first memory storage.

[0081] When the workload of high-priority applications is large, migrating instances of low-priority applications from the first memory storage to the second memory storage can free up storage space for the high-priority applications and ensure the processing efficiency of the business corresponding to the high-priority applications.

[0082] For example, suppose the target device is currently running the following applications: Application A, Application B, Application C, and Application D; the priority order of the four applications is as follows: Application A > Application B > Application C > Application D. At regular time intervals, the following operations can be performed:

[0083] For application A, the number of instances required for current business processing is determined based on its workload, assuming it's 3. If the first memory storage currently holds 5 instances of application A, the importance of each application is determined based on the memory access activity of these 5 instances. Then, the 2 instances with the lowest importance are selected and migrated to the second memory storage. If the first memory storage currently holds 1 instance of application A, it can be determined whether the second memory storage holds any instances of application A, and how many (if less than 2, 2 new instances are created). Assuming the second memory storage holds 3 instances of application A, the importance of each application is determined based on the memory access activity of these 3 applications. Then, the 2 instances with the highest importance are selected and migrated to the first memory storage. Before migration, the available storage space in the first memory storage can be determined. If there is enough storage space, migration proceeds directly. If there is insufficient storage space, the lowest priority application with the lowest importance instance is selected and migrated to the second memory storage in ascending order of priority to free up space. For example, we can first check if there is an instance of application D in the first memory storage. If there is, we can migrate the instance of application D. If it is still not enough after migration, we can then consider migrating instances of application C and application B to free up storage space.

[0084] After migrating the instance of application A, perform the same operation for application B, migrating the instance of application B. Then, perform the same operation for applications C and D in turn. Of course, if after processing an application there is no storage space left in the first memory storage, and there is no instance of an application with a lower priority than that application in the first memory storage (i.e., there is no free storage space), then there is no need to continue the process.

[0085] In some embodiments, when migrating application instances on the target device, only one or more applications with higher priority may be considered. For example, for these high-priority applications, instances can be migrated based on traffic volume. For the remaining low-priority applications, migration can be based on the current device load. For instance, suppose that among the multiple applications running on the target device, application A is a high-real-time, critical application, while the others are less demanding. Therefore, the traffic volume of application A can be monitored at regular intervals. When its traffic volume is low, excess instances of application A in the first memory storage can be migrated to the second memory storage, freeing up storage space for other applications (e.g., one or more instances of other applications can be randomly selected and migrated to the first memory storage), improving the processing efficiency of the services corresponding to other applications and maximizing the utilization of memory resources. Similarly, when its traffic volume is high, one or more instances to be migrated are determined from the second memory storage based on their importance and migrated to the first memory storage. Of course, if the current storage space of the first memory storage is insufficient, one or more instances of other applications stored in the first memory storage can be randomly selected and migrated to the second memory storage to free up storage space in the first memory storage.

[0086] For large servers that handle a large number of business requests and have heavy processing tasks, they often adopt a NUMA architecture, such as... Figure 4 The diagram illustrates a NUMA-based device. This device can include multiple NUMA nodes (e.g., NUMA node 1, NUMA node 2), each containing multiple processors (cores). Each NUMA node also includes shared memory for these processors. Each processor within a NUMA node can access its own node's memory to read data, and can also access the memory of other NUMA nodes (i.e., cross-node access) to read data from other nodes' memory. However, the speed at which a processor accesses the memory within its own NUMA node is greater than the speed at which it accesses the memory of other NUMA nodes.

[0087] In some embodiments, the target device of this specification can also be a NUMA-based device, as shown in FIG5(a). The target device may include multiple NUMA nodes, multiple processors, and multiple first memory memories distributed across multiple NUMA nodes. Each NUMA node includes at least one processor and at least one first memory memory. Since storage space can be allocated to application instances without passing through the first memory memory on the NUMA node, and considering the faster access speed of processors to the first memory memory of their own NUMA node, when it is necessary to migrate instances determined by importance from the second memory memory to the first memory memory to meet current business processing needs, the instances should be migrated to the first memory memory on the same NUMA node as much as possible. This allows subsequent applications to reduce cross-NUMA node access tasks and improve processing efficiency during business processing.

[0088] In some embodiments, if the target device is a NUMA-based device, the importance of an instance can be determined based on the distribution of its current memory usage across NUMA nodes. A greater distribution indicates lower instance importance. Since processors on each NUMA node can access memory on neighboring NUMA nodes, the memory occupied by an instance may be distributed across multiple NUMA nodes. Because processors on a NUMA node can access their own memory faster than they can access memory on other NUMA nodes, instances with memory distributed across the same NUMA node will have higher processing efficiency, meaning they are more important and should be preferentially stored in the first memory storage. Conversely, if an instance's memory is distributed across multiple NUMA nodes, its processing efficiency will be significantly reduced, indicating a lower-performing instance with lower importance, and it should be preferentially stored in the second memory storage.

[0089] In some embodiments, the memory access activity of each instance of an application can be determined based on the ratio of the size of the cold memory of each instance to the total memory occupied by each instance. Cold memory refers to memory pages that are hit less than a set number of times within a preset time period. For example, assuming the user defines a memory page hit less than 100 times in 1 minute as cold memory, if a memory page is monitored to be hit 80 times in 1 minute, then that memory page is considered cold memory. The higher the proportion of cold memory for an instance, the less active it is, and therefore such instances should be preferentially migrated to a secondary memory storage.

[0090] Of course, since the memory pages allocated to each instance are virtual memory, their virtual memory addresses are very large. However, many virtual memory addresses (i.e., memory pages) are rarely used. Therefore, in some embodiments, to improve migration efficiency, when migrating the instance to be migrated between the first memory storage and the second memory storage, for the memory pages corresponding to the instance to be migrated, target memory pages with a usage frequency higher than a set frequency can be selected from the memory pages. The data stored in the target memory pages is then migrated from the first memory storage to the second memory storage, or from the second memory storage to the first memory storage. In this way, when migrating the instance to be migrated, some unused memory pages can be skipped, improving migration efficiency.

[0091] In some embodiments, if the instance to be migrated and the migration direction are determined based on importance, before migrating the instance between the first memory storage and the second memory storage, the state of the process corresponding to the instance to be migrated can be switched to a frozen state. When a process is in a frozen state, it will stop running. After the migration of the instance to be migrated between the first memory storage and the second memory storage is completed, the state of the process can be switched from the frozen state to the awakened state so that the process can resume running.

[0092] In some embodiments, when migrating instances between a first memory storage and a second memory storage, a thread pool can be pre-set to improve processing efficiency. Threads in this thread pool can be dedicated to migrating the data corresponding to the instance. When instance migration is required, multiple threads can be obtained from the pre-set thread pool and used to migrate the instances in parallel, thereby improving migration efficiency.

[0093] For example, as shown in Figure 5(b), after determining the instance to be migrated, the memory pages corresponding to the instance to be migrated can be determined. Then, unused memory pages are filtered out from the memory pages, and multiple threads are obtained from the thread pool to perform concurrent migration of the filtered memory pages.

[0094] To further explain the memory allocation method provided in the embodiments of this specification, the following explanation is based on a specific embodiment.

[0095] Figure 6(a) or 6(b) shows a schematic diagram of a server structure, which includes multiple NUMA nodes, each containing multiple cores and DRAM. Additionally, the server includes one or more non-volatile memory (NVMs).

[0096] A server can run multiple applications simultaneously, such as APP1, APP2, APP3, etc. Each application can include multiple instances; for example, APP1 can include instances APP1-1, APP1-2, APP1-3, APP1-4, etc. To improve the utilization of DRAM and NVM on the server, allowing multiple applications to run concurrently and increasing deployment density, during application execution, instances can be migrated between DRAM and NVM based on application priority, current application processing traffic, and memory access status of each application instance, thereby improving memory resource utilization.

[0097] (1) Monitor the memory access of each instance of the application to determine the portability of each instance.

[0098] The portability of each instance can be determined using formula (1):

[0099] B=a*Mem.cold / Mem+b*N formula (1)

[0100] Where B represents the portability of the application; Mem.cold represents the size of the instance's cold memory, where cold memory is the memory page that is hit less than a set number of times within a predetermined time; Mem represents the size of the memory occupied by the instance; N represents the degree of dispersion of the instance's memory across NUMA nodes, and the more NUMA nodes the instance's memory is distributed across, the greater the dispersion; coefficients a and b are pre-set coefficients that can be used to adjust the weight of cold memory size and the weight of memory dispersion.

[0101] (2) For high-priority applications, instance migration can be triggered based on the application's workload.

[0102] For high-priority applications, the application's traffic can be monitored to determine the number of instances to be migrated and the migration direction (migration direction includes migration from DRAM to NVM, or from NVM to DRAM). Then, the instances to be migrated can be determined based on the number of instances to be migrated, the migration direction, and the portability of each instance in the application.

[0103] For example, as shown in Figure 6(a), for APP1, we can monitor the business requests of APP1 in a recent period (e.g., 5 minutes). Then, based on the number of business requests received by APP1, we can determine the number of instances required for APP1 to perform business processing, assuming it is 2. Assuming that the number of APP1 instances currently located in DRAM is 4, namely APP1-1, APP1-2, APP1-3, and APP1-4, it means that the instances stored in DRAM are excessive, exceeding the number of instances required for current business processing. Therefore, based on the portability, we can determine 2 instances to be migrated from the above 4 instances, namely APP1-3 and APP1-4, and migrate these 2 instances from DRAM to NVM to free up memory in DRAM for other low-priority applications that need it.

[0104] Of course, as shown in Figure 6(b), if based on the number of service requests received by APP1, it is determined that the number of instances required for APP1 to perform service processing is 4, while the number of instances of APP1 currently located in DRAM is 2 (assuming APP1-1 and APP1-2), it means that the instances currently stored in DRAM cannot meet the needs of current service processing. Therefore, the two instances of APP1 (assuming APP1-3 and APP1-4) can be migrated from NVM to DRAM in order to meet the needs of current service processing and improve processing efficiency.

[0105] (2) For low-priority applications, instance migration can be triggered based on the current load of the NUMA node.

[0106] For example, as shown in Figure 6(a), when the current workload of the high-priority APP1 is relatively small, two instances of APP1 (APP1-3, APP1-4) can be migrated from DRAM to NVM. Since some instances are migrated from DRAM, storage space is freed up in DRAM. At this time, the load on the NUMA node is reduced. Therefore, one or more instances of the lower-priority APP2 stored in NVM, such as APP2-1 and APP2-2 (the specific number can be determined based on the available storage space in DRAM), can be selected and migrated to DRAM. In this way, the utilization of memory resources can be maximized and the resource utilization rate can be improved.

[0107] When the high-priority APP1 has a large workload, as shown in Figure 6(b), two instances of APP1 need to be migrated from NVM to DRAM to meet the business requirements. At this time, if the NUMA node is heavily loaded and the storage space in DRAM is insufficient, one or more instances of the low-priority APP2 (the specific number can be determined based on the storage space required by the instances to be migrated from APP1) can be migrated from DRAM to NVM to free up storage space in DRAM for the instances of APP1. In this way, the processing efficiency and real-time performance of the high-priority APP1 can be guaranteed.

[0108] (3) When migrating instances of APP1 or APP2 from NVM back to DRAM, instances should be migrated to the same NUMA node as much as possible to avoid cross-node access after migration and improve instance processing efficiency. Once one or more instances to be migrated and the migration direction are determined, the process corresponding to that instance can be frozen, and the process's `cpu freeze_state` can be set to frozen or woken up. Additionally, during the migration process, information stored in ` / proc / pid / maps` can be used for filtering, only migrating memory pages in `maps`. This method can skip unused memory pages, increasing migration efficiency. During migration, multiple threads can be used for concurrent migration to accelerate the overall migration speed.

[0109] The method provided in this embodiment can quickly wake up new application instances from NVM when the workload is high, providing the fastest service, ensuring application processing efficiency, avoiding the problem of low processing efficiency when retrieving data from disk or other slow media, and minimizing cross-NUMA memory accesses. When the workload is low, application instances can be migrated to NVM, freeing up memory resources for other applications that need them, thus increasing deployment density exponentially and improving resource utilization.

[0110] Corresponding to the memory allocation method embodiments provided in this specification, this specification also provides a memory allocation apparatus suitable for a target device. The target device includes a first memory storage and a second memory storage, wherein the data read / write speed of the first memory storage is greater than the data read / write speed of the second memory storage. Figure 7 As shown, the device 70 includes:

[0111] The acquisition module 72 is used to acquire instances of one or more applications currently running on the target device;

[0112] Migration module 74 is used to determine the importance of an application instance and migrate the application instance between a first memory storage and a second memory storage based on the importance, so that the first memory storage preferentially stores the instance with the higher importance, the importance being positively correlated with one or more of the following information: the memory access activity of the instance, the priority of the application to which the instance belongs, and the traffic volume of the application to which the instance belongs.

[0113] In some embodiments, the migration module 74 is used to determine the importance of an application instance and, when migrating the application instance between the first memory storage and the second memory storage based on the importance, specifically for:

[0114] For all instances running on the target device, the importance of each instance is determined, wherein the importance of each instance is positively correlated with one or more of the following information: the memory access activity of the instance, the priority of the application to which the instance belongs, and the traffic volume of the application to which the instance belongs;

[0115] Based on the importance of each instance, target storage space is allocated to each instance in either the first memory storage or the second memory storage, wherein storage space in the first memory storage is preferentially allocated to instances with higher importance.

[0116] Based on the storage space currently occupied by each instance and the target storage space, at least one instance is migrated between the first memory storage and the second memory storage.

[0117] In some embodiments, when the migration module 74 determines the importance of an application instance and migrates the application instance between the first memory storage and the second memory storage based on the importance, it is specifically used for:

[0118] For each application currently running on the target device, perform the following operations in descending order of priority:

[0119] For the current application, determine the number of instances required for the current business processing of that application;

[0120] When the number of instances required for the current business processing is less than the number of instances of the current application stored in the first memory storage, the importance of each instance of the current application stored in the first memory storage is determined, and instances to be migrated are determined from each instance based on the importance and migrated to the second memory storage.

[0121] When the number of instances required for the current business processing is greater than the number of instances of the current application stored in the first memory storage, the importance of each instance of the current application stored in the second memory storage is determined, and instances to be migrated are determined from each instance based on the importance and migrated to the first memory storage; wherein, the importance is positively correlated with the memory access activity of the instance.

[0122] In some embodiments, before the migration module 74 determines the instance to be migrated from the instances based on the importance level and migrates it to the first memory storage, it is further configured to:

[0123] Determine whether the current available storage space of the first memory storage is less than the storage space occupied by the determined instance to be migrated;

[0124] If so, one or more instances of the target application stored in the first memory storage are moved to the second memory storage to free up storage space in the first memory storage, wherein the priority of the target application is lower than the priority of the current application, and the one or more instances are determined based on the importance.

[0125] In some embodiments, the target device includes multiple non-uniform memory access NUMA nodes, and the first memory memory includes multiple instances distributed across the multiple non-uniform memory access NUMA nodes. Each non-uniform memory access NUMA node includes at least one first memory memory. The migration module 74, when migrating application instances between the first memory memory and the second memory memory based on the importance level, is specifically used for:

[0126] If it is determined, based on the importance level, that an instance of the application should be migrated from the second memory storage to the first memory storage, then the instance of the application should be migrated from the second memory storage to the first memory storage on the same non-uniform memory access NUMA node.

[0127] In some embodiments, the target device includes multiple non-uniform memory access NUMA nodes, the first memory storage includes multiple first memory storages distributed across the multiple non-uniform memory access NUMA nodes, each non-uniform memory access NUMA node includes at least one first memory storage, and the importance is negatively correlated with the degree of dispersion of the memory currently occupied by the instance across the non-uniform memory access NUMA nodes.

[0128] In some embodiments, the memory access activity of an instance is determined based on the ratio of the size of the instance's cold memory to the total memory size occupied by the instance, wherein the cold memory is a memory page that is hit less than a set number of times within a preset time period.

[0129] In some embodiments, when the migration module 74 is used to migrate an application instance between the first memory storage and the second memory storage based on the importance level, it is specifically used for:

[0130] For the memory pages corresponding to the instances to be migrated based on the importance level, target memory pages with a usage frequency higher than a set frequency are selected from the memory pages, and the data stored in the target memory pages is migrated between the first memory storage and the second memory storage.

[0131] In some embodiments, before migrating an instance of the application between the first memory storage and the second memory storage based on the importance level, the migration module 74 is further configured to:

[0132] For the processes corresponding to the instances to be migrated based on the importance level, the state of the processes is switched to a frozen state;

[0133] After migrating the application instance between the first memory storage and the second memory storage, the method further includes:

[0134] Switch the state of the process from frozen to awake.

[0135] In some embodiments, when the migration module 74 is used to migrate an application instance between the first memory storage and the second memory storage based on the importance level, it is specifically used for:

[0136] For instances to be migrated based on their importance, multiple threads are obtained from a pre-set thread pool, and the multiple threads are used to migrate the instances in parallel.

[0137] In some embodiments, the first memory memory is a dynamic random access memory (DRAM), and the second memory memory is a non-volatile memory (NVM). The specific implementation process of the functions and roles of each unit in the above device is detailed in the implementation process of the corresponding steps in the memory allocation method described above, and will not be repeated here.

[0138] For the apparatus embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The apparatus embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the embodiments in this specification, depending on actual needs. Those skilled in the art can understand and implement this without creative effort.

[0139] This specification also provides an electronic device, as shown in FIG5. The electronic device includes multiple NUMA nodes and a second memory storage. Each NUMA node includes at least one first memory storage. The data read / write speed of the first memory storage is greater than that of the second memory storage. The NUMA node is used to execute the memory allocation method provided in the above embodiments.

[0140] This specification also provides a computer program product that, when executed by a processor, can implement the above-described memory allocation method.

[0141] This specification also provides a computer-readable storage medium on which a computer program is stored, which, when executed by a processor, can implement the above-described memory allocation method.

[0142] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which can take the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending and receiving device, game console, tablet computer, wearable device, or any combination of these devices.

[0143] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0144] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0145] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0146] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0147] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0148] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this specification. The singular forms “a,” “described,” and “the” used in one or more embodiments of this specification and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0149] It should be understood that although the terms first, second, third, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of one or more embodiments of this specification, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "in response to a determination," or "when," or "in the event of a determination."

[0150] The above description is merely a preferred embodiment of one or more embodiments of this specification and is not intended to limit the scope of one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of one or more embodiments of this specification should be included within the protection scope of one or more embodiments of this specification.

Claims

1. A memory allocation method for a target device, the target device comprising a first memory storage and a second memory storage, the first memory storage having a higher data read-write speed than the second memory storage, the method comprising: obtaining instances of one or more applications currently running on the target device; determining importance levels of the instances of the applications, and migrating the instances of the applications between the first memory storage and the second memory storage based on the importance levels, so that the instances with higher importance levels are preferentially stored in the first memory storage, wherein each application comprises multiple instances, and the importance level of each instance is positively correlated with one or more of the following: memory access activity of the instance, priority of an application to which the instance belongs, and traffic volume of the application to which the instance belongs; wherein, in the process of migrating the instances of the applications, all the instances of the applications are compared to determine the importance levels of the instances, and the instances of the applications are migrated based on the importance levels of the instances; or, the importance levels of the instances of each application are determined in order of priority of the application from high to low, and the instances of each application are migrated based on the importance levels; and in the process of migrating the instances to be migrated determined based on the importance levels, target memory pages with a usage frequency higher than a set frequency are selected from memory pages of the instances to be migrated, and data stored in the target memory pages are migrated between the first memory storage and the second memory storage. 2.The method of claim 1, wherein, in the process of migrating the instances of the applications, all the instances of the applications are compared to determine the importance levels of the instances, and the instances of the applications are migrated based on the importance levels of the instances, comprising: determining the importance level of each instance for all the instances running on the target device, wherein the importance level of each instance is positively correlated with one or more of the following: memory access activity of the instance, priority of an application to which the instance belongs, and traffic volume of the application to which the instance belongs; allocating target storage space for each instance in the first memory storage or the second memory storage based on the importance level of each instance, wherein storage space in the first memory storage is preferentially allocated to instances with higher importance levels; and migrating at least one instance between the first memory storage and the second memory storage based on the target storage space and storage space currently occupied by each instance. 3.The method of claim 1, wherein, the importance levels of the instances of each application are determined in order of priority of the application from high to low, and the instances of each application are migrated based on the importance levels, comprising: for each application currently running on the target device, the following operations are performed on the application in order of priority from high to low: determining a number of instances required by the current application for current traffic processing; and migrating the instances of the current application between the first memory storage and the second memory storage based on the number of instances required by the current application for current traffic processing. ​ ​ ​ ​ ​ ​ ​ ​ ​ determining the importance of each instance of the current application stored in the first memory storage when the number of instances required for current business processing is less than the number of instances of the current application stored in the first memory storage, determining the instance to be migrated from each instance based on the importance, and migrating to the second memory storage; determining the importance of each instance of the current application stored in the second memory storage when the number of instances required for current business processing is greater than the number of instances of the current application stored in the first memory storage, determining the instance to be migrated from each instance based on the importance, and migrating to the first memory storage; wherein the importance is positively correlated with the memory access activity of the instance.

4. The method of claim 3, before determining the instance to be migrated from each instance based on the importance and migrating to the first memory storage, further comprising: determining whether the current available storage space of the first memory storage is less than the determined storage space occupied by the instance to be migrated; if yes, migrating one or more instances of a target application stored in the first memory storage to the second memory storage to free up storage space in the first memory storage, wherein the priority of the target application is lower than the priority of the current application, and the one or more instances are determined based on the importance.

5. The method of any one of claims 1-4, wherein the target device comprises a plurality of non-uniform memory access (NUMA) nodes, the first memory storage comprises a plurality of first memory storages, and the plurality of first memory storages are distributed on the plurality of NUMA nodes, each NUMA node comprising at least one first memory storage, and wherein the migrating the instance of the application between the first memory storage and the second memory storage based on the importance comprises: when it is determined based on the importance that the instance of the application is to be migrated from the second memory storage to the first memory storage, migrating the instance of the application from the second memory storage to the first memory storage on the same NUMA node.

6. The method of any one of claims 1-4, wherein the target device comprises a plurality of non-uniform memory access (NUMA) nodes, the first memory storage comprises a plurality of first memory storages, and the plurality of first memory storages are distributed on the plurality of NUMA nodes, each NUMA node comprising at least one first memory storage, and wherein the importance is negatively correlated with the degree of dispersion of the currently occupied memory of the instance on the NUMA node.

7. The method of any of claims 1-4, the memory access activity of the instance is determined based on a ratio of a size of a cold memory of the instance to a total memory size occupied by the instance, wherein, The cold memory is a memory page that is hit less than a set number of times within a preset time.

8. The method of any one of claims 1-4, before the migrating the instance of the application between the first memory storage and the second memory storage based on the importance, the method further comprises: switch a state of the process to a frozen state for the instance to be migrated determined based on the importance degree; after migrating the instance of the application between the first memory storage and the second memory storage, the method further comprises: switching the state of the process from the frozen state to a woken-up state.

9. The method of any one of claims 1-4, wherein migrating the instance of the application between the first memory storage and the second memory storage based on the importance degree comprises: for the instance to be migrated determined based on the importance degree, acquiring a plurality of threads from a preset thread pool, and migrating the instance to be migrated in parallel using the plurality of threads.

10. The method of any one of claims 1-4, wherein the first memory storage is a dynamic random access memory (DRAM), and the second memory storage is a non-volatile memory (NVM).

11. A memory allocation apparatus suitable for a target device, the target device comprising a first memory storage and a second memory storage, a data read-write speed of the first memory storage being greater than a data read-write speed of the second memory storage, the apparatus comprising: an acquisition module configured to acquire instances of one or more applications currently running on the target device; a migration module configured to determine an importance degree of the instances of the applications, and migrate the instances of the applications between the first memory storage and the second memory storage based on the importance degree, so that the instances with high importance degrees are preferentially stored in the first memory storage, wherein the same application comprises a plurality of instances, and the importance degree of each instance is positively correlated with one or more of the following information: a memory access activity of the instance, a priority of an application to which the instance belongs, and a traffic volume of the application to which the instance belongs; wherein, in the process of migrating the instances of the applications, all the instances of the applications are compared to determine the importance degrees of the instances, and the instances of the applications are migrated based on the importance degrees of the instances; or, the importance degrees of the instances of each application are determined in a descending order of application priority, and the instances of each application are migrated based on the importance degrees of the instances of the application; in the process of migrating the instance to be migrated determined based on the importance degree, a target memory page with a usage frequency higher than a set frequency is filtered out from memory pages of the instance to be migrated, and data stored in the target memory page is migrated between the first memory storage and the second memory storage.

12. An electronic device comprising a plurality of NUMA nodes and a second memory storage, each NUMA node comprising a first memory storage, a data read-write speed of the first memory storage being greater than a data read-write speed of the second memory storage, the NUMA nodes being configured to execute the method of any one of claims 1-10.

13. A computer storage medium having stored thereon a computer program, the computer program, when executed by a processor, implementing the method of any one of claims 1-10.

Citation Information

Patent Citations

  • Cache management method and device

    CN104156322A

  • Mapping unclassified memory accesses to classified memory accesses

    CN114402306A

  • User interface-based page migration for performance enhancement

    CN114730252A