Memory management method, computing system, and computer program product
By coordinating memory borrowing among compute nodes, the memory space of compute nodes is expanded, the problem of insufficient local memory is solved, and the IO acceleration effect is improved.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2025-12-30
- Publication Date
- 2026-07-09
Smart Images

Figure CN2025147585_09072026_PF_FP_ABST
Abstract
Description
Memory management methods, computing systems and computer program products
[0001] This application claims priority to Chinese Patent Application No. 202510016276.7, filed on January 2, 2025, entitled "Memory Management Method, Computing System and Computer Program Product", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of memory management technology, and in particular to a memory management method, computing system, and computer program product. Background Technology
[0003] Generally speaking, the access speed of persistent storage media (such as disks) is much lower than that of non-persistent storage media (such as memory). In order to speed up the reading speed of persistent storage media, the Linux kernel provides a page cache mechanism.
[0004] Specifically, the Linux kernel caches data read from the disk via the file system in memory to improve read and write performance and speed. The memory space occupied by caching this data is called the Page Cache. The Page Cache consists of one or more file pages, each corresponding to a portion of data on the disk. When an application needs to read previously read data again, it can directly retrieve the corresponding data from the Page Cache without having to read it from the disk, thus accelerating the application's input / output (IO).
[0005] As the Page Cache mechanism described above shows, there is a significant difference in read and write speeds between disk and memory. The more data cached from disk into the Page Cache, the higher the probability of a hit within the Page Cache, resulting in a more significant I / O acceleration effect. However, the local memory of a compute node is limited, and the memory space that can be allocated for the Page Cache is even more limited. When the remaining amount of local memory falls below the set reclamation threshold, the memory space occupied by the Page Cache will be reclaimed, and the next time the corresponding data is read, it needs to be read from the disk, resulting in a less than ideal I / O acceleration effect. Summary of the Invention
[0006] This application provides a memory management method, a computing system, and a computer program product that can expand the memory space of a computing node, enabling applications on that computing node to achieve better I / O acceleration.
[0007] In a first aspect, this application provides a memory management method applied to a computing system. The computing system includes a management node and multiple computing nodes connected via a bus. The method includes: a first computing node sending a memory borrowing request to a management node; the management node requesting a first memory space from a second computing node that meets the memory borrowing request; the management node sending a first physical address of the first memory space to the first computing node; the first computing node mapping the first physical address to the memory management space of its operating system, wherein the first memory space and the first computing node's local memory space constitute the first computing node's memory space; and the first computing node's operating system accessing the first memory space based on the above mapping.
[0008] In the above scheme, when the first compute node needs to expand its memory space, it can send a memory borrowing request to the management node. The management node then requests the first memory space from the second compute node to meet the memory borrowing request, and then sends the first physical address of the first memory space to the first compute node. The first compute node maps the first physical address to the memory management space of its operating system. Based on this mapping, the operating system of the first compute node can access the first memory space. At this time, the memory space of the first compute node is expanded on top of its local memory space, realizing the expansion of the first compute node's memory space. Therefore, the first compute node can use more memory space as a page cache to cache more data on the disk, thereby improving the data hit rate of the application in the first compute node's memory space and thus improving the application's performance.
[0009] Based on the first aspect, in a possible implementation, the management node stores node metadata reported by each of the multiple computing nodes. The management node can determine the second computing node as the computing node that satisfies the memory borrowing requirement based on this node metadata. That is, each computing node in the computing system can report its own node metadata to the management node. Based on the node metadata reported by each computing node, the management node determines whether one or more computing nodes can satisfy the memory borrowing requirement of the first computing node. The second computing node is one of the computing nodes that can satisfy this memory borrowing requirement, and then the management node requests a first memory space from the second computing node to satisfy the memory borrowing requirement of the first computing node.
[0010] Based on the first aspect, in possible implementations, node metadata includes the remaining local memory space of each compute node and / or the distance between each compute node and the first compute node. That is, the management node can determine the second compute node capable of meeting the memory borrowing needs of the first compute node based on one or more factors, such as the remaining local memory space of each compute node and the distance between each compute node and the first compute node. For example, the management node first determines which compute nodes can meet the memory borrowing needs of the first compute node, and then, among the compute nodes that meet the memory borrowing needs, determines the compute node with the largest remaining local memory space as the second compute node, or determines the compute node closest to the first compute node as the second compute node, in order to minimize the access latency of the first compute node to the borrowed memory space.
[0011] Based on the first aspect, in a possible implementation, the first memory space is used as a page cache. That is, the first compute node can use the first memory space in the second compute node as a page cache to cache file pages from the disk of the first compute node to the first memory space.
[0012] Based on the first aspect, in a possible implementation, the memory management space of the operating system of the first computing node includes a first management space mapped to the local memory space of the first computing node and a reserved second management space. When the first computing node records the mapping relationship between the second management space and the first physical address, the mapping between the first physical address of the first memory space and the memory management space of the first computing node is realized. Thus, the operating node of the first computing node can use the first memory space as if it were its local memory space. The size of the reserved second management space may need to be configured, and this application does not specifically limit it.
[0013] Based on the first aspect, in a possible implementation, when the remaining local memory space of the first compute node falls below the first watermark, it indicates that the local memory space of the first compute node is insufficient (local memory usage is tight), and memory space needs to be expanded. Therefore, the first compute node sends a memory borrowing request to the management node. When the first compute node receives the first physical address of the first memory space sent by the management node and maps the first physical address to the memory management space of the first compute node's operating system, the operating system of the first compute node can migrate file pages from the first compute node's local memory space to the first memory space through mapping, so that the remaining local memory space of the first compute node is greater than or equal to the first watermark.
[0014] Based on the first aspect, in a possible implementation, the first computing node counts the popularity of file pages in its local memory space. When the proportion of file pages with popularity higher than a first threshold in the first computing node's local memory space is greater than or equal to a second threshold, it indicates that the first computing node needs to use more memory space as a Page Cache to cache more data on the disk. However, at this time, the remaining local memory space is insufficient, so the first computing node needs to expand its memory space and sends a memory borrowing request to the management node. The first and second thresholds mentioned above can be set according to usage needs, and this application does not limit them. After the first computing node receives the first physical address of the first memory space sent by the management node and maps the first physical address to the memory management space of the first computing node's operating system, the operating system of the first computing node migrates file pages with popularity lower than a preset value in the first computing node's local memory space to the first memory space based on the mapping. In other words, by analyzing the popularity of file pages, file pages with relatively low popularity (in this case, popularity less than a preset value) can be migrated from the local memory space of the first compute node to the first memory space of the second compute node. Only file pages with relatively high popularity (in this case, popularity greater than or equal to a preset value) are retained in the first memory space, thus increasing the available space in the first memory space. Then, more frequently accessed file pages can be cached in the local memory space, thereby improving the data hit rate of the application in the local memory space of the first compute node and ultimately improving application performance.
[0015] Based on the first aspect, in a possible implementation, the operating system of the first computing node prefetches data from the first memory space according to the above mapping. In this scheme, the first computing node can not only prefetch data from the local disk to the local memory space, but also prefetch data from the first memory space to the local memory space, thereby improving the data hit rate of the application in the first computing node in the local memory space and thus accelerating the application's I / O operations.
[0016] Based on the first aspect, in a possible implementation, when the remaining local memory space of the first computing node is greater than or equal to the second watermark, the management node sends a first instruction to the first computing node. The first computing node, according to the first instruction, unmaps the first physical address from the memory management space of its operating system. Then, the first computing node sends a notification to the management node that the unmapping is complete. Upon receiving this notification, the management node sends a second instruction to the second computing node, which then releases the first memory space according to the second instruction. In this scheme, when the remaining local memory space of the first computing node is greater than or equal to the second watermark, it is considered that the usage of the first computing node's local memory space is no longer critical, and the right to use the first memory space borrowed by the first computing node can be returned to the second computing node. The return process includes: the first computing node first unmaps the first physical address of the first memory space from the memory management space according to the first instruction from the management node, preventing the second computing node's operating system from accessing the first memory space; then, the second computing node releases the first memory space according to the second instruction from the management node, allowing the first memory space to be reallocated.
[0017] Based on the first aspect, in a possible implementation, when the first value is greater than or equal to the second threshold, the management node sends a first instruction to the first computing node, where the first value is the sum of the remaining space in the first computing node's local memory and the data volume of file pages in the first computing node's local memory with a popularity less than or equal to a third threshold; the first computing node releases the mapping between the first physical address and the memory management space according to the first instruction and sends a notification of release completion to the management node; after receiving the notification, the management node sends a second instruction to the second computing node; the second computing node releases the first memory space according to the second instruction.
[0018] In the above scheme, the remaining local memory space of the first computing node is calculated as the sum of the data volume of file pages in that local memory space whose popularity is less than or equal to the third threshold. If the sum of this data volume is greater than or equal to the second threshold, it indicates that the local memory space usage of the first computing node is no longer strained, and the right to use the first memory space borrowed by the first computing node can be returned to the second computing node. The third threshold can be set according to usage needs, and this application does not impose specific limitations.
[0019] In a second aspect, this application also provides a computing system including a management node and multiple computing nodes connected via a bus, the computing system being specifically used to execute the method of any possible implementation of the first aspect.
[0020] Thirdly, this application also provides a computer-readable storage medium including instructions that, when executed on a computing system, cause the computing system to perform the method as described in any possible embodiment of the first aspect. The computing node includes a management node and multiple computing nodes connected via a bus.
[0021] Fourthly, this application also provides a computer program product containing instructions. When the aforementioned instructions are executed by a computing system, the computing system performs a method as described in any possible embodiment of the first aspect. The computing node includes a management node and multiple computing nodes connected via a bus. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments are briefly introduced below.
[0023] Figure 1 is an architecture diagram of a computing system provided in an embodiment of this application;
[0024] Figure 2 is an interaction flowchart between a computing node and a management node provided in an embodiment of this application;
[0025] Figure 3 is a schematic diagram of a Page Cache pool provided in an embodiment of this application;
[0026] Figure 4 is a schematic diagram of the relationship between various waterlines provided in the embodiments of this application;
[0027] Figure 5 is a schematic diagram of a memory borrowing and file page migration process provided in an embodiment of this application;
[0028] Figure 6 is a schematic diagram of the active LRU list and the inactive LRU list provided in the embodiments of this application;
[0029] Figure 7 is a schematic diagram of a prefetching process provided in an embodiment of this application;
[0030] Figure 8 is a schematic diagram of a sequential reading scenario provided in an embodiment of this application;
[0031] Figure 9 is a schematic diagram of a memory return process provided in an embodiment of this application;
[0032] Figure 10 is a flowchart illustrating a memory management method provided in an embodiment of this application;
[0033] Figure 11 is a schematic diagram of the structure of a computing node provided in an embodiment of this application. Detailed Implementation
[0034] To facilitate understanding of the technical solution of this application, a computing system involved in this application will be introduced first.
[0035] Please refer to Figure 1, which is an architecture diagram of a computing system provided in an embodiment of this application. This computing system can also be called a supernode cluster, including a management node and multiple computing nodes. The computing nodes are connected via a bus, and the management node has a connection to each computing node.
[0036] The aforementioned computing nodes can be physical computing devices such as servers and desktop computers. Each computing node includes a physical memory space (i.e., the local memory space of the computing node). This application does not impose specific limitations on the number, type, location, or size of the local memory space of computing nodes.
[0037] The aforementioned bus can provide direct links or indirect connections (such as forwarding via a switch) between computing nodes, and this application does not specifically limit its use. Optionally, the aforementioned bus can be a high-speed interconnect bus, which features high bandwidth and low latency, enabling efficient data transmission between computing nodes. The high-speed interconnect bus can be a Compute Express Link (CXL), NVIDIA Link (NVLink), high-speed Ethernet, or other buses, and this application does not specifically limit its use either.
[0038] The aforementioned management node can be a device other than the aforementioned multiple computing nodes, or it can be one of the aforementioned multiple computing nodes, or it can be jointly served by some of the aforementioned multiple computing nodes. This application does not make any specific limitations in this regard.
[0039] Since each compute node has a certain amount of local memory space, and this local memory space may contain some free memory (i.e., unallocated memory), when a compute node in the computing system needs to expand its memory space, it can request to borrow free memory space from other compute nodes from the management node. The management node then requests a segment of free memory space from a suitable compute node and sends the physical address of the requested memory space to the compute node requesting the expansion. Thus, the compute node can use the memory space from other compute nodes, achieving memory space expansion and helping to improve the I / O speed and performance of applications on that compute node. The memory space borrowing process and the subsequent memory space return process are described in stages below, including stages one through four.
[0040] Phase 1: Cluster initialization.
[0041] Specifically, a management node is first designated, and then each compute node reports its local memory space specifications (including capacity, type, and other information) to the management node. The management node can also obtain the access address (such as Internet Protocol (IP) address), number, and location information of each compute node in the computing system, in order to control the memory space borrowing and returning logic between compute nodes.
[0042] For example, Figure 2 is an interaction flowchart between a computing node and a management node provided in an embodiment of this application, including steps 1 to 5.
[0043] Step 1. Management Node Initialization. For example, a specific computing node in the computing system can be designated as the management node, and the functions of the management node can be configured on that computing node to complete the initialization of the management node. In addition, multiple computing nodes or other devices besides computing nodes can also be configured as management nodes, and this application does not make specific limitations on this.
[0044] Step 2. The compute node sends the specifications of its local memory space to the management node.
[0045] It should be noted that, for simplicity, Figure 2 only shows one compute node. In reality, each compute node in the computing system interacts with the management node in the manner shown in Figure 2. That is, each compute node establishes a connection with the management node and reports its local memory space specifications. The management node records the local memory space specifications reported by the compute nodes, and subsequently controls the borrowing and returning of memory space among all compute nodes that have reported their local memory space specifications.
[0046] Step 3. Configure compute nodes with reserved memory addresses for expanding memory space.
[0047] Specifically, the operating system (OS) of a compute node has a corresponding memory management space, which includes a first management space mapped to the compute node's local memory space and a reserved second management space. The first management space is the same size as the local memory space. The range of the second management space can be configured by the operations and maintenance personnel. For example, the operations and maintenance personnel can configure a reserved memory address for the compute node's operating system. The reserved memory address is the address used by the second management space, and the range of the reserved memory address determines the range of the second management space. This allows the insertion of memory space from other compute nodes into the reserved memory address to expand the compute node's memory space. In other words, by mapping the physical address of the memory space lent to this compute node by other compute nodes to the reserved memory address configured on this compute node, the mapping between the borrowed memory space and the operating system's second management space is realized. This allows the compute node's memory space to be expanded from its local memory space by adding the memory space borrowed from other compute nodes. Subsequently, the compute node's operating system can read and write the borrowed memory space as if it were local memory space. How to map and use the borrowed memory space in detail will be introduced later.
[0048] Step 4. The compute node sends node metadata to the management node.
[0049] Each compute node can periodically report its own node metadata to the management node. Correspondingly, the management node stores the node metadata reported by each compute node. This node metadata may include information such as the remaining local memory space of the compute node, the size of the memory space allocated for Page Cache in the local memory space, and the proportion of file pages with a popularity below a preset value in the Page Cache. This application does not impose specific limitations on these details. Compute nodes can implement periodic reporting of node metadata based on a heartbeat mechanism or other methods. For example, each compute node can start a timer to periodically send heartbeat packets to the management node so that the management node can confirm the liveness status of each compute node. The heartbeat packets can carry the corresponding compute node's node metadata, thereby achieving periodic metadata reporting. This application does not impose specific limitations on the reporting period of node metadata; it can be set according to usage needs.
[0050] Optionally, an agent module for the management node can be deployed in the compute nodes. The agent module can obtain the node metadata of the compute nodes and then send the node metadata to the management node.
[0051] Step 5. The compute node parses the user configuration.
[0052] Optionally, users can configure migration watermarks, memory pooling ratios, prefetching algorithms, etc., on compute nodes according to their needs. The migration watermark controls when a compute node migrates file pages from its local memory cache to borrowed memory (located on other compute nodes). When the remaining (estimated or actual) memory in a compute node's local memory is less than or equal to the migration watermark, the compute node is triggered to perform the migration. The specific migration process will be described later. The memory pooling ratio limits the proportion of memory a compute node lends to other compute nodes. The proportion of memory borrowed by a compute node within its local memory cannot exceed this pooling ratio, reserving a certain amount of memory for the compute node's operating system and minimizing the performance impact on applications on that compute node. The prefetching algorithm controls how a compute node pre-fetches data from its local disk and borrowed memory into its local memory (described in detail later) to improve the data hit rate in local memory. Users can configure appropriate prefetching algorithms as needed; this application does not impose specific limitations on this.
[0053] Phase 2: Compute nodes request memory space from management nodes to borrow from other compute nodes.
[0054] Specifically, when a computing node in the computing system (denoted as the first computing node) needs to expand its memory space, the first computing node can send a memory borrowing request to the management node to request free memory space from other computing nodes. The first computing node can be any or a specific computing node in the computing system. The memory borrowing request can include the amount of memory the first computing node needs, and may also include latency requirements (i.e., the first computing node expects the access latency of the borrowed memory space to not exceed this latency requirement), memory type, etc.
[0055] This application does not specify the method for determining whether memory space needs to be expanded or the method for calculating memory requirements.
[0056] In the first possible implementation, a first waterline can be set in the first compute node. When the actual value of the remaining local memory space of the first compute node is less than or equal to the first waterline, it is considered that the local memory space of the first compute node is insufficient and needs to be expanded. This application does not impose a specific limitation on the size of the first waterline, and users can set it according to their needs.
[0057] In the second possible implementation, the memory requirements of the first compute node in the future can be estimated based on the I / O status of the applications in the first compute node. Specifically, this estimates how much data needs to be read from the local disk of the first compute node into its memory space in the future. The I / O status can include factors such as the access bandwidth of the local disk; this application does not specifically limit the estimation method. Then, the difference between the remaining local memory space of the first compute node and the estimated memory requirements is used as an estimate of the remaining local memory space of the first compute node in the future. If this estimate is less than or equal to a first threshold, the local memory space of the first compute node is considered insufficient, and memory expansion is required.
[0058] The first waterline can be set to a value higher than the local memory reclamation waterline (also known as the low waterline). Setting the first waterline higher than the reclamation waterline allows for timely borrowing of free memory from other compute nodes to expand the first compute node's memory space before memory reclamation is triggered. This prevents premature reclamation of data in the page cache of the first compute node's local memory, ensuring that data that might be read or written in the local memory page cache is not reclaimed. Furthermore, more data can be cached from the local disk into the first compute node's memory space (including both local and borrowed memory), thereby increasing the data hit rate in memory, reducing the number of direct disk reads, and ultimately improving the I / O speed and performance of applications on the first compute node.
[0059] In the third possible implementation, the first compute node calculates the popularity of file pages in its local memory Page Cache. When the proportion of file pages with popularity exceeding a first threshold in the local memory space is greater than or equal to a second threshold, it indicates that the first compute node needs more memory space for its Page Cache, but its local memory space is insufficient. Therefore, the first compute node needs to expand its memory space and sends a memory borrowing request to the management node. The first and second thresholds can be set according to usage needs, and this application does not limit them.
[0060] Optionally, the agent module of the management node in the first computing node can determine whether the first computing node needs to expand its memory space. When it is determined that the first computing node needs to expand its memory space, the agent module sends the memory borrowing request of the first computing node to the management node.
[0061] When the management node receives a memory borrowing request from the first compute node, the management node can select a compute node that meets the memory borrowing request from the computing system as the lending node (denoted as the second compute node). There may be one or more compute nodes that meet the memory borrowing request, and the second compute node can be any one or a specific one of these one or more.
[0062] Optionally, the management node can select the compute node with the largest local memory space as the second compute node; alternatively, the management node can determine the second compute node based on the distance between each compute node and the first compute node, selecting the compute node with local memory space greater than or equal to the memory borrowing requirement and the closest distance to the first compute node. This satisfies the memory borrowing requirement of the first compute node and minimizes the latency of the first compute node accessing the borrowed memory space (located on the second compute node). It also aims to ensure that the local memory space usage of each compute node is consistent (so that the local memory space of each compute node is used evenly). This application does not impose specific limitations on this.
[0063] Optionally, for each compute node, the remaining local memory space refers to the size of the unallocated memory space within that compute node's local memory space. The leasable memory space of that compute node may include unallocated memory space, and may also include the space occupied by file pages with a popularity less than or equal to a third threshold within its local memory space. The management node can determine the capacity of each compute node's leasable memory space based on the node metadata reported by each compute node, and then ensure that the capacity of the leasable memory space meets (greater than or equal to) the following conditions.
[0064] The computing node whose memory requirements match those of the first computing node is designated as the second computing node. For example, the management node can designate the computing node with the largest available memory space as the second computing node, or, among all computing nodes whose available memory space meets the memory requirements of the first computing node, determine the computing node that is closest to the first computing node as the second computing node.
[0065] Then, the management node sends the memory borrowing request of the first computing node to the determined second computing node, in order to request memory space in the second computing node to meet the memory borrowing request.
[0066] When the second compute node receives a memory borrowing request from the first compute node sent by the management node, if the second compute node's local memory space is sufficient to meet the memory requirement, then a first memory space that meets the memory requirement can be determined from the unallocated memory space within the second compute node. If the second compute node's local memory space is insufficient to meet the memory requirement, then the second compute node can reclaim the space occupied by file pages with a popularity level less than or equal to a third threshold. This reclaimed space becomes unallocated memory space, increasing the second compute node's local memory space to be greater than or equal to the memory requirement. In other words, although the second compute node's current local memory space is insufficient to meet the first compute node's memory requirement, the second compute node can increase its unallocated memory space by reclaiming the space occupied by file pages with a popularity level less than or equal to the third threshold, thus increasing the second compute node's local memory space and ultimately enabling it to meet the first compute node's memory requirement.
[0067] The operating system of the second computing node sets the determined first memory space to an occupied state, thus preventing other processes on the second computing node from using the first memory space to avoid simultaneous read and write operations. The second computing node then sends the global address of the first memory space to the management node. This global address of the first memory space is obtained by globally addressing the local memory spaces of all computing nodes in the computing system. This global addressing ensures that each computing node's local memory space has a corresponding global address. This application does not specifically limit the implementation method of global addressing; for example, it can be performed by the bus controller of the bus between computing nodes, which can determine the location of a specific memory space in the computing system based on the global address.
[0068] Optionally, a proxy module of the management node is deployed on the second compute node. This proxy module receives the memory borrowing request of the first compute node sent by the management node. Then, the proxy module requests memory space from the operating system of the second compute node to meet the memory borrowing request. The operating system of the second compute node allocates the first memory space that meets the memory borrowing request to the proxy module. At this time, the first memory space is occupied. Then, the proxy module sends the global address of the first memory space to the management node.
[0069] When the management node receives the global address (denoted as the first physical address) of the first memory space sent by the second compute node, it adds the first memory space to the Page Cache pool. This means recording the corresponding borrow-in relationship of the first memory space. This relationship indicates that the first memory space in the second compute node, with a global address of the first physical address, has been borrowed by the first compute node, and the first memory space can be used as a Page Cache in the first compute node. Following the same method, the management node can also add more memory space to the Page Cache pool. The Page Cache pool is a logical concept; the memory space in the Page Cache pool actually resides on the corresponding compute nodes.
[0070] For example, as shown in Figure 3, suppose the computing system includes multiple computing nodes such as computing node A and computing node B. Each computing node includes its own local memory space and local disk. Each computing node can cache some data from its local disk into its own local memory space. Therefore, when an application (APP) on that computing node needs to access (read / write) this data on the local disk, it can directly access the local memory space, avoiding direct read / write operations on the local disk, thereby improving the application's I / O speed and performance.
[0071] Suppose compute node A has some free memory space. When compute node A receives a memory borrowing request from another compute node sent by the management node, compute node A's operating system can set a segment of free memory in its local memory space that meets the memory borrowing request to be occupied (i.e., the operating system allocates a segment of free memory space that meets the memory borrowing request). Then, compute node A sends the global address of this free memory space to the management node. The management node adds this free memory space to the Page Cache pool, that is, it records which specific compute node in compute node A has borrowed this free memory space and the corresponding global address of this free memory space. Similarly, compute node B or other compute nodes can also report some free memory space in their local memory space as available for borrowing to the management node, and the management node then adds the corresponding free memory space to the Page Cache pool.
[0072] It should be noted that the number and names of the computing nodes in Figure 3 are just examples and do not constitute a specific limitation; there can be more computing nodes.
[0073] After the management node adds the first memory space in the second compute node to the Page Cache pool, the management node sends the global address of the first memory space (hereinafter referred to as the first physical address) to the first compute node to indicate that the first compute node can use the first memory space on the second compute node.
[0074] When the first compute node receives the first physical address of the first memory space sent by the management node, it maps the first physical address to the memory management space of the first compute node's operating system. Specifically, the first compute node can map the first physical address to a reserved memory address configured on the first compute node (see the relevant introduction in Phase 1), that is, map the first physical address to the second management space managed by the first compute node's operating system. This results in the first compute node's memory space being expanded by adding the first memory space of the second compute node to the first compute node's local memory space. The first compute node's operating system perceives that the second management space has been mapped to the corresponding memory space (here, the first memory space), and then the first compute node's operating system can use the first memory space as if it were its local memory space (accessing the first memory space with memory access semantics). For the specific usage process, please refer to the introduction in Phase 3. The first compute node's operating system can present the borrowed first memory space to the user in some way, such as reporting the first memory space as a Non-Uniform Memory Access (NUMA) node. This application does not impose specific limitations on this.
[0075] Phase 3: Accessing borrowed memory space.
[0076] Following the description in Phase Two, the borrowing process is completed when the first compute node obtains the first physical address of the first memory space on the second compute node and maps the first physical address to the memory management space of the first compute node's operating system. The first compute node can then access the borrowed first memory space as if it were using its local memory space. Scenarios for accessing the first memory space include scenarios 1 through 5, which will be described below.
[0077] Scenario 1: Reading and writing data from borrowed memory space.
[0078] When the operating system of the first compute node requests to write data to the corresponding memory space in the second management space, the bus controller in the first compute node determines the first physical address of the first memory space according to the above mapping. Then, the first compute node writes the data to the first memory space corresponding to the first physical address through the bus between the first and second compute nodes. The data to be written can be file pages, each file page corresponding to a portion of data in the first compute node's local disk. That is, the first compute node can not only cache data from its local disk in its local memory space, but also cache data from its local disk in the borrowed first memory space. Since the access speed of the first memory space is higher than that of the local disk, the corresponding data can be read from the first memory space subsequently, without having to read from the local disk, thereby speeding up the I / O.
[0079] When the operating system of the first compute node requests to read data from the corresponding memory space of the second management space, the bus controller in the first compute node determines the first physical address of the first memory space according to the above mapping. Then, the first compute node reads the required data from the first memory space corresponding to the first physical address through the bus between the first compute node and the second compute node, thereby enabling the operating system of the first compute node to obtain the data.
[0080] Scenario 2: Migrate file pages from the local memory space of the first computing node to the borrowed memory space.
[0081] It should be understood that the first compute node has a reclamation waterline (also called the low waterline) and a high waterline. The low waterline value is lower than the high waterline value. When the remaining local memory space of the first compute node is less than or equal to the reclamation waterline, the first compute node will be triggered to reclam the used memory space in its local memory space. As a result, the memory space allocated for Page Cache in the local memory space will be gradually reclaimed, and file pages in the Page Cache will be gradually cleared until the remaining local memory space of the compute node rises to the high waterline, at which point memory reclamation will stop. To avoid premature memory reclamation affecting the data hit rate in the local memory space, some file pages in the first compute node's local memory space can be migrated to the first memory space while there is still remaining space in the borrowed first memory space. This increases the remaining local memory space of the first compute node, allowing more file pages to be cached in the first compute node's memory space (including both local and borrowed first memory spaces), thereby improving the file page hit rate in memory and I / O speed.
[0082] Since applications on the first compute node access the memory space (including local memory space and borrowed first memory space) of the first compute node at a higher speed than they access the local disk, and applications on the first compute node access the local memory space at a higher speed than they access the first memory space, when the remaining (estimated or actual) amount of local memory space on the first compute node is less than or equal to the migration waterline, infrequently used (inactive / low-heat) file pages in the local memory space can be migrated to the first memory space. This increases the remaining amount of local memory space on the first compute node, avoids premature memory reclamation, and thus prevents file pages that may be accessed in the local memory space from being cleared.
[0083] For example, Figure 4 is a schematic diagram of the relationship between various watermarks provided in the embodiments of this application. There are four watermarks in total, which are arranged in descending order of value as High Watermark, Migrate Watermark, Low Watermark and Min Watermark. The specific values of these four watermarks can be set according to the usage needs, and this application does not make any specific limitations.
[0084] The low watermark controls when the first compute node reclaims used memory from its local memory space. When the remaining local memory space of the first compute node (i.e., the remaining memory space in Figure 4, i.e., unallocated memory space) is less than or equal to the reclamation watermark, the first compute node is triggered to perform the above-mentioned memory reclamation (asynchronous reclamation). Memory space allocated for Page Cache in the local memory space is gradually reclaimed, and corresponding file pages are gradually cleared (lear-usage file pages can be reclaimed first), until the remaining local memory space of the first compute node rises to the high watermark, at which point memory reclamation stops. If the remaining local memory space is below the minimum watermark, it indicates that the available memory for the processes of the first compute node is exhausted (severe memory shortage), and blocking memory reclamation is performed.
[0085] The migration waterline controls when the first compute node sends a memory borrowing request to the management node and / or when it migrates file pages from its local memory space to borrowed memory space (located on other compute nodes). When the first compute node's local memory space (estimated or actual) is less than or equal to the migration waterline, and if the first compute node has not yet borrowed memory space from other compute nodes, it can send a memory borrowing request to the management node. If the first compute node has already borrowed some memory space from other compute nodes, but the remaining borrowed memory space is insufficient to meet its memory borrowing request, it can request to borrow memory space from other compute nodes again to further expand its memory space. Specific borrowing methods can be found in Phase Two and will not be elaborated here. If the first compute node has already borrowed some memory space from other compute nodes, and the remaining borrowed memory space is sufficient to meet its memory borrowing request, it can migrate some file pages from its local memory space to the borrowed memory space to increase its local memory space.
[0086] Optionally, the first computing node can count the popularity of file pages in its local memory space. Then, the operating system of the first computing node will migrate file pages with popularity less than a preset value to the first memory space based on mapping. The preset value can be set as needed; this application does not impose specific limitations on it. The mapping mentioned above refers to the mapping between the first physical address of the first memory space and the memory management space of the operating system of the first computing node. For details, please refer to the introduction in Phase Two; it will not be repeated here.
[0087] This application does not specify a particular method for determining whether a file page is frequently used (active / high-popularity). Optionally, it can be based on the Least Recently Used (LRU) list maintained by the Linux kernel. Compute nodes typically maintain active LRU lists and inactive LRU lists. The active LRU list indicates active file pages in the local memory space (i.e., recently used frequently / high-popularity file pages), and the inactive LRU list indicates inactive file pages in the local memory space (i.e., recently used less frequently / low-popularity file pages). Thus, the first compute node can migrate some file pages from the inactive LRU list from its local memory space to the borrowed first memory space.
[0088] This application does not impose a specific limit on the number of file pages to be migrated to the first memory space. The number of file pages to be migrated to the first memory space can be determined based on the remaining space of the first memory space. The amount of data in the file pages to be migrated to the first memory space cannot exceed the remaining space of the first memory space.
[0089] The following example, referring to Figure 5, illustrates the process of a compute node sending a memory borrowing request and performing file page migration.
[0090] Please refer to Figure 5, which is a schematic flowchart of a memory borrowing and file page migration provided in an embodiment of this application, including steps 1 to 11.
[0091] Step 1. The first compute node determines whether the estimated value of the remaining local memory space has reached the migration watershed. If so, proceed to Step 2.
[0092] Step 2. Check if the remaining memory space meets the memory requirements. If yes, proceed to Step 3; otherwise, proceed to Step 4.
[0093] Step 3. The first compute node migrates file pages from its local memory space to the borrowed memory space. The process ends.
[0094] The current first compute node may have already borrowed memory space from other compute nodes, and the remaining borrowed memory space may or may not meet the memory requirement. The memory requirement can be calculated using the method described earlier, and will not be repeated here. Alternatively, the current first compute node may not have borrowed memory space from any compute node, in which case the remaining borrowed memory space is 0.
[0095] If the remaining amount of borrowed memory space (unallocated memory space) of the first compute node can meet the memory demand, there is no need to borrow again. At this time, the first compute node is triggered to migrate file pages in local memory space to borrowed memory space. The amount of data in the migrated file pages does not exceed the remaining amount of borrowed memory space. For example, one or more file pages with a total data amount less than the remaining amount can be migrated to borrowed memory space.
[0096] Step 4. The first compute node sends a memory borrowing request to the management node.
[0097] Specifically, if the remaining borrowed memory space of the first computing node cannot meet the memory demand, the first computing node needs to borrow more memory to expand its memory space. Therefore, the first computing node sends a memory borrowing request to the management node. The memory borrowing request includes the memory demand of the first computing node and may also include latency requirements.
[0098] Step 5. The management node determines whether there are neighboring compute nodes that meet the memory borrowing requirements. If not, proceed to step 6; if yes, proceed to step 7.
[0099] Step 6. The management node refuses to borrow memory for the first compute node. End the process.
[0100] Step 7. The management node requests memory space from the second compute node that meets the memory borrowing requirements.
[0101] The aforementioned neighboring compute nodes refer to compute nodes connected to the first compute node via a bus. There may be one or more, or zero, neighboring compute nodes whose available memory space capacity meets (is greater than or equal to) the first compute node's memory borrowing requirement. The management node can determine this based on the node metadata periodically reported by each compute node. If no neighboring compute node has available memory space capacity to meet the memory borrowing requirement, the management node refuses to lend memory to the first compute node, effectively notifying the first compute node that there are currently no other compute nodes capable of lending memory space. When the first compute node's local memory space balance drops to the reclamation threshold, the first compute node triggers memory reclamation, thereby increasing its local memory space balance.
[0102] If there are one or more neighboring compute nodes with sufficient borrowable memory space to meet the memory borrowing requirement, the management node can determine a borrowing node from these neighboring compute nodes. The selection of the borrowing node can be based on factors such as the distance between the neighboring compute node and the first compute node, and the remaining local memory space of the neighboring compute node; this application does not impose specific limitations. Here, it is assumed that the borrowing node determined by the management node is the second compute node, and the management node requests memory space from the second compute node that meets the memory borrowing requirement.
[0103] Step 8. The second computing node sets the first memory space that meets the memory borrowing requirements to an occupied state.
[0104] When the second compute node receives a request from the management node, it can set the first memory space in the available memory space in its local memory space to be occupied, so that other processes in the second compute node cannot use the first memory space, thus avoiding the first memory space being read and written at the same time.
[0105] Step 9. The second compute node sends the first physical address of the first memory space to the management node.
[0106] Step 10. The management node sends the first physical address to the first compute node.
[0107] Specifically, when the management node receives the first physical address of the first memory space sent by the second compute node, it determines that the second compute node has used the first memory space in its local memory space as borrowable memory space. Therefore, the management node adds the first memory space to the Page Cache pool, recording that the first memory space in the second compute node has been lent to the first compute node along with its first physical address. Then, the management node sends the first physical address of the first memory space to the first compute node, instructing it to use the first memory space in the second compute node to expand its own memory space.
[0108] Step 11. The first compute node maps the first physical address to the memory management space of the first compute node's operating system.
[0109] As described in step 5 of Figure 2, the memory management space of the operating system of the first compute node includes a first management space mapped to the local memory space of the first compute node and a reserved second management space. Reserved memory addresses can be configured on the first compute node to indicate the range of the second management space. When the first compute node receives the first physical address of the first memory space sent by the management node, it can map it to the reserved memory address, which is also mapped to the second management space managed by the operating system. Therefore, the operating system of the first compute node can use the first memory space in the second compute node as if it were its local memory space.
[0110] Scenario 3: Swap local memory space and borrow file pages from memory space based on the popularity of file pages.
[0111] In addition to triggering the first compute node to migrate file pages from its local memory space to the borrowed first memory space when the remaining local memory space drops to the migration waterline (see the description of Scenario 2), the first compute node can also periodically migrate some low-frequency file pages from its local memory space to the first memory space, and some high-frequency file pages from the first memory space to its local memory space, based on the popularity of the file pages. Popularity is used to indicate the recent usage frequency of a file page, and this application does not specifically limit the statistical method for file page popularity. The number of file pages migrated from local memory space to the first memory space can be equal to the number of file pages migrated from the first memory space to local memory space, that is, an equal number of file pages are swapped between the local memory space and the first memory space of the first compute node to ensure that the remaining space of each local memory space and the first memory space does not change significantly before and after the migration. This application also does not specifically limit the time period for performing the above swaps, and it can be set according to the usage needs. This application also does not specifically limit the number of file pages swapped in each period.
[0112] Optionally, the popularity of a file page can be determined based on its position in the LRU list. File pages in the local memory space of the first compute node can be divided into an active LRU list and an inactive LRU list corresponding to that local memory space. The active LRU list indicates file pages that have been used most recently (active file pages / high-popularity file pages), while the inactive LRU list indicates file pages that have been used very infrequently (inactive file pages / low-popularity file pages). Similarly, the first compute node can also maintain an active LRU list and an inactive LRU list corresponding to the first memory space to indicate the recent usage of file pages in the first memory space. Based on the local memory space of the first compute node and the position of file pages in the corresponding LRU list within that first memory space, the first compute node can swap file pages between its local memory space and the borrowed first memory space. This allows frequently accessed file pages to be migrated from the first memory space to the local memory space, improving the data hit rate of application IO requests in the local memory space and reducing the average memory access latency. Conversely, some less frequently accessed file pages are migrated from the local memory space of the first compute node to the first memory space, reducing the local memory space usage of the first compute node. Although these less frequently accessed file pages are migrated to the first memory space of the second compute node, reading these file pages from the first memory space is faster than reading them from the local disk of the first compute node, still improving the IO speed of applications on the first compute node to some extent.
[0113] For example, Figure 6 is a schematic diagram of the active LRU list and the inactive LRU list provided in the embodiment of this application. Before exchanging file pages, the local memory space of the first computing node includes file pages Page[0], Page[1], Page[2], Page[3], Page[6], and Page[7]. Among them, Page[0], Page[1], Page[2], and Page[3] belong to the active LRU list, and Page[6] and Page[7] belong to the inactive LRU list. It is assumed that the file pages in the active LRU list are more popular than the file pages in the inactive LRU list. The first memory space borrowed by the first computing node from the second computing node includes file pages Page[4], Page[5], and Page[8]. Among them, Page[4] and Page[5] belong to the active LRU list, and Page[8] belongs to the inactive LRU list. The first computing node can identify the file pages with higher popularity and the file pages with lower popularity according to the LRU list to which the file pages belong.
[0114] Then, the first compute node can perform file page swapping, moving the less popular file pages Page[6] and Page[7] in the local memory space to the first memory space, and moving the more popular file pages Page[4] and Page[5] in the first memory space to the local memory space of the first compute node. Specifically, the first compute node removes Page[6] and Page[7] from the inactive LRU list corresponding to their original local memory space (the file pages in the dashed box in Figure 6 are removed), stores Page[6] and Page[7] in the first memory space corresponding to the first physical address through the bus between the first compute node and the second compute node, and adds Page[6] and Page[7] to the inactive LRU list corresponding to the first memory space, which is equivalent to reallocating the positions of these file pages. The first computing node migrates file pages Page[4] and Page[5] in the first memory space to the local memory space of the first computing node via the bus. The first computing node removes Page[4] and Page[5] from the active LRU list corresponding to the original first memory space and adds Page[4] and Page[5] to the active LRU list corresponding to the local memory space.
[0115] It should be noted that the number of LRU lists, the number of file pages, their order, and their identifiers in Figure 6 are merely examples and do not constitute specific limitations. In practical applications, the local memory space of the first computing node can have one or more active LRU lists, and the local memory space of the first computing node can also have one or more inactive LRU lists. Each LRU list can contain more or fewer file pages. Besides borrowing memory space from the second computing node, the first computing node may also borrow memory space from other computing nodes. In this case, the first computing node can also maintain active and inactive LRU lists corresponding to the memory space borrowed from other computing nodes; this application does not impose specific limitations on this.
[0116] Scenario 4: Prefetch file pages from borrowed memory space to local memory space.
[0117] To address scenarios involving sequential reads and reduce the number of consecutive disk I / O operations, a prefetching mechanism can be configured in the first compute node. Specifically, when an application in the first compute node initiates a read request, the operating system of the first compute node writes the corresponding file page from the local disk to the memory space of the first compute node. It also reads some subsequent file pages from the disk into the memory space of the first compute node, setting prefetch flags on some of these file pages. When the application's next read operation hits a file page with the Read Ahead flag in memory, file page prefetching is triggered. The prefetching algorithm determines the file pages that need to be prefetched and the file pages for which the Read Ahead flag needs to be added. This application does not specify the particular prefetching algorithm to be used; users can configure a suitable prefetching algorithm as needed (see step 5 in Figure 2).
[0118] If the file page to be prefetched already exists in the local memory space of the first compute node, it can be directly hit in the local memory space without needing to be prefetched repeatedly. If the file page to be prefetched exists in the memory space borrowed by the first compute node from other compute nodes, the file page can be moved from the borrowed memory space to the local memory space of the first compute node, and then the file page can be hit in the local memory space. If the file page to be prefetched exists neither in the local memory space of the first compute node nor in the borrowed memory space, the first compute node needs to prefetch the corresponding file page from the local disk to the local memory space.
[0119] For example, Figure 7 is a schematic diagram of a prefetching process provided in an embodiment of this application. When the application on the first computing node reads a file page with a prefetch flag in the memory space (including local memory space and borrowed memory space), it calls the prefetching algorithm. The prefetching algorithm can process the information of the file page with the prefetch flag and return the information of the file page to be prefetched and the information of the file page to which the prefetch flag needs to be set. There may be one or more file pages to be prefetched. Then, the first computing node determines whether the file page to be prefetched can be found in the local memory space. If so, it does not need to be read into the local memory space again, and the file page is set with the prefetch flag as needed. If the file page to be prefetched cannot be found in the local memory space, it continues to determine whether the file page to be prefetched can be found in the borrowed memory space: if so, it is prefetched from the borrowed memory space, that is, the file page is moved from the borrowed memory space to the local memory space, and the prefetch flag is set as needed; if not, it is prefetched from the disk, that is, the file page is read from the disk into the local memory space of the first computing node, and the prefetch flag is set as needed. Finally, update the node metadata of the first compute node, including updating the remaining local memory space of the first compute node, the size of the memory space used as Page Cache in the local memory space (i.e., the amount of data of file pages in the local memory space), the proportion of file pages with a popularity greater than the first threshold in the Page Cache, and the remaining borrowed memory space, and end the prefetch process.
[0120] For example, Figure 8 is a schematic diagram of a sequential read scenario provided by an embodiment of this application. Assume that the application in the first computing node reads file page Page[0] from the local memory space, and Page[0] is set with a prefetch flag (Read Ahead Mark), thus triggering the prefetch mechanism. The first computing node calls the prefetch algorithm to determine that the current IO mode of the application is sequential read, and it needs to prefetch the subsequent file pages Page[1] to Page[7]. Since Page[1], Page[4] and Page[5] already exist in the local memory space of the first computing node, these three file pages can be cached in the memory space, so it is not necessary to prefetch these file pages repeatedly.
[0121] Page[6] and Page[7], which need to be prefetched, exist in the first memory space (On Remote) of the second computing node borrowed by the first computing node, and these two file pages can be hit in the memory space. In order to speed up the access, Page[6] and Page[7] can be pre-migrated to the local memory space of the first computing node, that is, Page[6] and Page[7] are migrated from the first memory space to the local memory space through the bus between the first computing node and the second computing node.
[0122] Page[2] and Page[3] that need to be prefetched do not exist in the local memory space of the first computing node, nor in the borrowed first memory space. These two file pages cannot be hit (Miss) in the memory space. Therefore, the data of these two file pages can only be read from the local disk of the first computing node into the local memory space of the first computing node, thereby completing the prefetching process.
[0123] At this point, Page[1] to Page[7] already exist in the local memory space of the first computing node. When the application's next read request needs to read these file pages, it can directly hit the local memory space, thereby improving the access speed.
[0124] Scenario 5: When the remaining local memory space is higher than the migration backflow limit, migrate the file pages in the borrowed memory space to the local memory space.
[0125] When the remaining local memory space of the first compute node is higher than the migration back waterline, the first compute node can migrate file pages from the borrowed memory space to its local memory space to shorten the access latency of the application on the first compute node to that file page. The migration back waterline is higher than the migration waterline described above, and the migration waterline is higher than the recycling waterline. The specific value of the migration back waterline can be set according to usage needs, and this application does not limit it.
[0126] Phase 4: Returning borrowed memory space.
[0127] Following the previous description, the first compute node borrows a first memory space from the second compute node. When the first compute node's local memory space is not under strain, the management node can send a first instruction to the first compute node. This first instruction includes information about the first memory space, instructing the first compute node to unmap the first physical address of the first memory space from the memory management space of the first compute node's operating system. After the first compute node completes processing according to the first instruction, the management node sends a second instruction to the second compute node. This second instruction includes information about the first memory space, instructing the second compute node to release the first memory space, thereby returning the right to use the first memory space to the second compute node, allowing applications on the second compute node to use the first memory space.
[0128] This application does not specify the method for determining whether local memory space usage is tight.
[0129] In the first possible implementation, a second waterline can be set in the first compute node. This second waterline is higher than the recycling waterline. When the actual value of the remaining local memory space of the first compute node is greater than or equal to the second waterline, it is considered that the local memory space usage of the first compute node is not strained, and thus the first compute node can return the memory space previously borrowed from other compute nodes. This application does not specifically limit the size of the second waterline; users can set it according to their needs.
[0130] In the second possible implementation, the memory requirements of the first compute node in the future can be estimated based on the I / O status of the applications in the first compute node. Specifically, this estimates how much data needs to be read from the local disk of the first compute node into memory during the future. The I / O status can include local disk access bandwidth, etc., and this application does not limit the specific estimation method. Then, the remaining local memory space of the first compute node in the future is predicted based on the memory requirements. The remaining local memory space of the first compute node in the future is calculated as: the current remaining local memory space of the first compute node - the memory requirements - the amount of data borrowed from the memory space. If the remaining local memory space of the first compute node in the future is greater than or equal to the second watermark, then the usage of the local memory space of the first compute node is considered not strained, and the first compute node can return the memory space previously borrowed from other compute nodes.
[0131] In the third possible implementation, the amount of data in file pages with a popularity less than or equal to the third threshold in the local memory space of the first computing node is counted. When the sum of this data amount and the remaining space in the local memory space of the first computing node is greater than or equal to the second waterline, it indicates that the local memory space of the first computing node is not under strain. Therefore, the first computing node can return the memory space previously borrowed from other computing nodes. That is, the first computing node first unmaps the first physical address of the first memory space from the memory management space of the operating system, and then the management node notifies the second computing node to release the first memory space so that the operating system of the second computing node can reallocate the first memory space. The third threshold and the second waterline can both be set according to usage requirements, and this application does not impose specific limitations.
[0132] For example, Figure 9 is a schematic diagram of a memory return process provided in an embodiment of this application, including the following steps 1 to 8. This example assumes that the first computing node borrows the first memory space in the second computing node, and the first memory space is the borrowed memory space of the first computing node.
[0133] Step 1. The first compute node sends its node metadata to the management node.
[0134] Optionally, node metadata may include one or more of the following: the remaining local memory of the first compute node, the size of the memory space used as Page Cache in the local memory space of the first compute node, and the proportion of file pages with a popularity less than or equal to a third threshold in the Page Cache.
[0135] Step 2. The management node determines whether the local memory space usage of the first compute node is strained. If so, proceed to step 3.
[0136] Based on the aforementioned node metadata, the management node can determine whether the local memory space usage of the first compute node is strained. The determination method can be found in the previously described possible implementations. If it is determined that the local memory space usage of the first compute node is not strained, the right to use the borrowed memory space can be returned to the corresponding lending node. Therefore, the management node can notify the first compute node to return the borrowed memory space.
[0137] Step 3. The management node sends the first instruction to the first computing node.
[0138] Specifically, when the management node determines that the local memory space of the first computing node is not scarce, it sends a first instruction to the first computing node. The first instruction includes information about the first memory space and is used to instruct the first computing node to access the mapping between the first physical address and the memory management space of the first computing node's operating system.
[0139] Step 4. The first compute node migrates the file pages in the first memory space from the second compute node to the local memory space of the first compute node.
[0140] Step 5. The first computing node unmaps the first physical address of the first memory space from the memory management space of the operating system.
[0141] Step 6. The first computing node notifies the management node that processing is complete.
[0142] Specifically, when the first compute node receives the first instruction from the management node, it can first migrate file pages from the first memory space back to its local memory space. The first compute node can also add the migrated file pages to the LRU list corresponding to its local memory space based on their frequency of use, and then delete the LRU list corresponding to the first memory space maintained by the first compute node. Subsequently, the first compute node unmaps the first physical address of the first memory space from the memory management space of its operating system, thus preventing the operating system from accessing the first memory space based on this mapping. After completing the above operations according to the management node's first instruction, the first compute node sends a notification to the management node confirming the completion of the unmapping process.
[0143] Step 7. The management node sends a second instruction to the second computing node.
[0144] Specifically, once the management node determines that the first compute node has completed its processing based on the aforementioned notification, the management node removes the first memory space from the Page Cache pool, that is, it deletes the corresponding borrow-in relationship of the first memory space recorded on the management node (the first memory space in the second compute node was borrowed from the first compute node). Furthermore, the management node sends a second instruction to the second compute node, which includes information about the first memory space. This second instruction instructs the agent module in the second compute node to release the first memory space requested from the second compute node's operating system.
[0145] Step 8. The second compute node releases the first memory space.
[0146] The agent module in the second compute node releases the first memory space according to the second instruction, so the first memory space becomes unallocated memory space again. After that, the operating system of the second compute node can reallocate the right to use the first memory space, which can be used by applications on the second compute node, or can continue to be lent to other compute nodes as needed, or can be used as a page cage for the second compute node to cache data in the local disk of the second compute node.
[0147] Based on the computing system described above, the following section introduces a memory management method provided in this application.
[0148] Please refer to Figure 10. Figure 10 is a flowchart illustrating a memory management method provided in an embodiment of this application. The method is applied to the computing system shown in Figure 1. The computing system includes multiple computing nodes connected via a bus. The method includes the following steps S1001 to S1005.
[0149] S1001, The first computing node among multiple computing nodes sends a memory borrowing request to the management node.
[0150] The first computing node can be any or a specific computing node in the computing system; this application does not impose any specific restrictions. Regarding the memory borrowing requirements of the first computing node, please refer to the preceding description; it will not be repeated here.
[0151] Optionally, the first compute node may send a memory borrowing request to the management node after the remaining local memory space of the first compute node is less than the first waterline. The first waterline can refer to the migration waterline introduced above.
[0152] Optionally, the first computing node can statistically analyze the popularity of file pages in its local memory space. If the proportion of file pages with popularity exceeding a first threshold in the first computing node's local memory space is greater than or equal to a second threshold, the node sends a memory borrowing request to the management node. The first and second thresholds can be set according to usage requirements, and this application does not impose specific limitations on them.
[0153] S1002. The management node requests the first memory space in the second computing node that meets the memory borrowing requirement from multiple computing nodes based on the memory borrowing requirement.
[0154] Optionally, the management node stores node metadata reported by each of the multiple compute nodes. Based on this node metadata, the management node can determine that the second compute node is the one that satisfies the aforementioned memory borrowing requirement, and then request a first memory space from the second compute node to meet this requirement. The first memory space can be contiguous or non-contiguous, and its physical address can be contiguous or non-contiguous. It should be understood that there may be one or more compute nodes in the computing system that satisfy the aforementioned memory borrowing requirement, and the second compute node can be any one of these nodes or a specific compute node.
[0155] Optionally, the aforementioned node metadata includes the remaining local memory space of each compute node and / or the distance between each compute node and the first compute node. In other words, the management node can consider one or more factors, such as the remaining local memory space of each compute node and its distance from the first compute node, to select which compute node to request memory space from. For example, the management node can designate a compute node whose remaining local memory space meets the memory requirements of the first compute node as the second compute node; or, it can designate a compute node whose remaining local memory space meets the memory requirements of the first compute node and whose distance from the first compute node is less than a distance threshold (to meet access latency requirements) as the second compute node.
[0156] Optionally, the node metadata may also include the proportion / data volume of file pages with a popularity less than or equal to the third threshold in the local memory space of each compute node. The third threshold can be set according to usage needs, and this application does not impose specific limitations. For example, for any compute node, the management node can calculate the remaining local memory space of the compute node and the total number of file pages with a popularity less than the third threshold in the local memory space of the compute node based on the node metadata. This total amount is the capacity of the available memory space of the compute node. Then, the management node determines the compute node whose available memory space capacity meets the memory requirements of the first compute node as the second compute node.
[0157] S1003, The management node sends the first physical address of the first memory space to the first computing node.
[0158] The aforementioned first memory space is located in the second computing node. The first memory space has a corresponding physical address within the second computing node, and it can satisfy the memory borrowing needs of the first computing node. The first physical address is the global address of the first memory space. When the management node requests the first memory space from the second computing node, the second computing node sends the first physical address of the first memory space to the management node. The management node then sends the first physical address of the first memory space to the first computing node, instructing the first computing node to use the first memory space in the second computing node according to the first physical address.
[0159] S1004. The first computing node maps the first physical address to the memory management space of the operating system of the first computing node. The first memory space and the local memory space of the first computing node constitute the memory space of the first computing node.
[0160] The memory space of the first compute node includes a page cache. This first memory space is used as a page cache.
[0161] Optionally, the memory management space of the operating system of the first compute node includes a first management space mapped to the local memory space of the first compute node and a reserved second management space. When the first compute node receives the first physical address of the first memory space sent by the management node, the first compute node maps the first physical address to the second management space. Thus, the first memory space becomes part of the memory space of the first compute node, allowing the operating system of the first compute node to use the first memory space in the second compute node as if it were its local memory space.
[0162] S1005. The operating system of the first computing node accesses the first memory space according to the above mapping.
[0163] Optionally, in step S1001, the first compute node may send a memory borrowing request to the management node after the remaining space in its local memory space falls below the first waterline. The first waterline can refer to the migration waterline described above. Then, in step S1005, the operating system of the first compute node migrates the file pages in its local memory space to the first memory space through the above mapping, so that the remaining space in the first compute node's local memory space is greater than or equal to the first waterline. For details, please refer to scenario 2 described above, which will not be repeated here.
[0164] Optionally, the first computing node can count the popularity of file pages in its local memory space, and then migrate file pages with popularity less than a preset value in its local memory space to the first memory space based on the above mapping relationship. For details, please refer to Scenario 3 described above, which will not be repeated here.
[0165] Optionally, the operating system of the first computing node prefetches data from the first memory space according to the above mapping. See Scenario 4 described above for details, which will not be repeated here.
[0166] Optionally, when the remaining local memory space of the first compute node is greater than or equal to the second waterline, the management node sends a first instruction to the first compute node, the first instruction including information about the first memory space. The first compute node, according to the first instruction, unmaps the physical address of the first memory space from the memory management space of its operating system, and then sends a notification to the management node indicating that the unmapping is complete. Upon receiving this notification, the management node sends a second instruction to the second compute node, the second instruction including information about the second memory space. The second compute node releases the first memory space according to the second instruction. For details, please refer to stage four described above; it will not be repeated here.
[0167] Optionally, when the first value is greater than or equal to the second threshold, the management node sends a first instruction to the first compute node. The first compute node, according to the first instruction, unmaps the physical address of the first memory space from the memory management space of its operating system, and then sends a notification to the management node indicating that the unmapping is complete. Upon receiving this notification, the management node sends a second instruction to the second compute node. Here, the first value is the sum of the remaining space in the first compute node's local memory and the data volume of file pages in the first compute node's local memory with a heat level less than or equal to a third threshold.
[0168] For example, the management node can obtain the node metadata reported by the first compute node, and then determine the remaining amount of local memory space of the first compute node and the sum of the data volume of file pages with a popularity of less than or equal to the third threshold in the local memory space of the first compute node. If the sum of this data volume is greater than or equal to the second threshold, it indicates that the local memory space of the first compute node is not under pressure. At this time, the management node sends a first instruction to the first compute node, and the first compute node, according to the first instruction, unmaps the first physical address of the first memory space from the memory management space of the first compute node's operating system. As a result, the operating system of the first compute node can no longer access the first memory space. Then, the management node sends a second instruction to the second compute node, and the second compute node, according to the second instruction, releases the first memory space, allowing the operating system of the second compute node to reallocate the first memory space.
[0169] In summary, the memory management method provided in this application controls the memory borrowing and return logic between computing nodes through a management node. This allows computing nodes to utilize the memory space of other computing nodes, expanding the memory space of a single computing node. Consequently, computing nodes can cache more data from the disk into memory space (including local memory space and borrowed memory space), improving the data hit rate in memory space and significantly reducing the time spent directly accessing the local disk. This, in turn, improves the I / O speed and performance of applications on the computing node. Data transmission between computing nodes can be performed via a high-speed interconnect bus. Based on the high bandwidth and low latency characteristics of the high-speed interconnect bus, the latency for computing nodes to access borrowed memory space on other computing nodes is short. Since this method can fully utilize the fragmented memory space resources of each computing node without additional memory overhead, it helps to improve the memory resource utilization of the entire computing system.
[0170] This application also provides a computing system, including a management node and multiple computing nodes connected via a bus, as detailed in Figure 1. This computing system is used to execute the operation steps of the memory management method shown in Figure 10.
[0171] Specifically, the first computing node among the aforementioned multiple computing nodes is used to: send a memory borrowing request to the management node.
[0172] The management node is used to request a first memory space from a second computing node among multiple computing nodes to meet the memory borrowing requirements. The management node is also used to send the first physical address of the first memory space to the first computing node.
[0173] The first computing node is also used to: map the first physical address to the memory management space of the operating system of the first computing node, wherein the first memory space and the local memory space of the first computing node constitute the memory space of the first computing node.
[0174] The operating system of the first compute node is used to: access the first memory space based on mapping.
[0175] Optionally, the management node stores the node metadata of each of the above-mentioned computing nodes reported by each computing node. The management node is also used to: determine the second computing node as the computing node that meets the memory borrowing requirement based on the above-mentioned node metadata.
[0176] Optionally, the node metadata mentioned above includes the remaining local memory space of each compute node and / or the distance between each compute node and the first compute node.
[0177] Optionally, the first memory space can be used as a page cache.
[0178] Optionally, the memory management space of the operating system of the first computing node includes a first management space mapped to the local memory space of the first computing node and a reserved second management space. The first computing node is specifically used to: record the mapping relationship between the second management space and the first physical address.
[0179] Optionally, the first compute node is specifically configured to: send a memory borrowing request to the management node after the remaining space in the first compute node's local memory space falls below the first waterline. The operating system of the first compute node is specifically configured to: migrate file pages in the first compute node's local memory space to the first memory space through the aforementioned mapping, so that the remaining space in the first compute node's local memory space is greater than or equal to the first waterline.
[0180] Optionally, the first compute node is also used to: count the popularity of file pages in its local memory space. Specifically, the first compute node is used to: send a memory borrowing request to the management node when the proportion of file pages with popularity higher than a first threshold in the first compute node's local memory space is greater than or equal to a second threshold. The operating system of the first compute node is specifically used to: migrate file pages with popularity lower than a preset value in the first compute node's local memory space to the first memory space based on the above mapping.
[0181] Optionally, the operating system of the first computing node is specifically used to: prefetch data from the first memory space according to the above mapping.
[0182] Optionally, the management node is further configured to: send a first instruction to the first computing node when the remaining space in the local memory space of the first computing node is greater than or equal to the second waterline. The first computing node is further configured to: unmap the first physical address to the memory management space according to the first instruction and send a notification of unmapping completion to the management node. The management node is further configured to: send a second instruction to the second computing node after receiving the above notification. The second computing node is further configured to: release the first memory space according to the second instruction.
[0183] Optionally, the management node is further configured to: send a first instruction to the first computing node when the first value is greater than or equal to the second threshold, wherein the first value is the sum of the remaining space in the first computing node's local memory and the amount of data in file pages in the first computing node's local memory with a popularity less than or equal to a third threshold. The first computing node is further configured to: unmap the first physical address from the memory management space according to the first instruction and send a notification of completion to the management node. The management node is further configured to: send a second instruction to the second computing node after receiving the above notification. The second computing node is further configured to: release the first memory space according to the second instruction.
[0184] The structure of computing nodes in a computing system will be explained below using Figure 11 as an example.
[0185] Please refer to Figure 11, which is a schematic diagram of a computing node structure provided in an embodiment of this application, including a bus 1102, a processor 1104, a memory 1106, and a communication interface 1108. The processor 1104, the memory 1106, and the communication interface 1108 communicate with each other via the bus 1102. The computing node 1100 can be a server, laptop, tablet, desktop computer, edge device, smartphone, smart screen, etc., and this application does not specifically limit it. This application also does not limit the number and type of processors and memory in the computing node 1100.
[0186] Bus 1102 can be a Peripheral Component Interconnect Express (PCIe) bus, or an Extended Industry Standard Architecture (EISA) bus, a Unified Bus (Ubus or UB), a Compute Express Link (CXL), a Cache Coherent Interconnect for Accelerators (CCIX), etc. Bus 1102 can be divided into address bus, data bus, control bus, etc. In addition to the data bus, bus 1102 can also include a power bus, control bus, and status signal bus. However, for clarity, all buses are labeled as bus 1102 in the diagram.
[0187] The processor 1104 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0188] Memory 1106 may include volatile memory, such as random access memory (RAM). Memory 1106 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD). Memory 1106 includes the local memory space of the computing node described above.
[0189] The memory 1106 stores executable program code. The processor 1104 executes the executable program code to implement the operation steps involved in the first computing node or the second computing node in the memory management method of FIG10, respectively.
[0190] The communication interface 1108 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing node 1100 and other devices or communication networks.
[0191] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computing device can store, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that, when executed on a computing system, cause the computing system to perform the operation steps in the memory management method of Figure 10. The computing system is described above and will not be repeated here.
[0192] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions, capable of running on a computing device or stored on any available medium. When the computer program product runs on a computing system, it causes the computing system to perform the operational steps in the memory management method of Figure 10. The computing system is described above and will not be repeated here.
[0193] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of this application.
Claims
1. A memory management method, characterized in that, The method is applied to a computing system, which includes a management node and multiple computing nodes connected via a bus. The first computing node among the plurality of computing nodes sends a memory borrowing request to the management node; The management node requests a first memory space from the second computing node among the plurality of computing nodes to satisfy the memory borrowing requirement; The management node sends the first physical address of the first memory space to the first computing node; The first computing node maps the first physical address to the memory management space of the operating system of the first computing node, and the first memory space and the local memory space of the first computing node constitute the memory space of the first computing node. The operating system of the first computing node accesses the first memory space based on the mapping.
2. The method according to claim 1, characterized in that, The management node stores the node metadata of each of the plurality of computing nodes, reported by each computing node. Before the management node requests a first memory space from the second computing node among the plurality of computing nodes to satisfy the memory borrowing requirement, the method further includes: The management node determines the second computing node as the computing node that meets the memory borrowing requirement based on the node metadata.
3. The method according to claim 2, characterized in that, The node metadata includes the remaining local memory space of each compute node and / or the distance between each compute node and the first compute node.
4. The method according to any one of claims 1 to 3, characterized in that, The first memory space is used as a page cache.
5. The method according to any one of claims 1 to 4, characterized in that, The memory management space of the operating system of the first computing node includes a first management space mapped to the local memory space of the first computing node and a reserved second management space. The first computing node maps the first physical address to the memory management space of the first computing node's operating system, including: The first computing node records the mapping relationship between the second management space and the first physical address.
6. The method according to any one of claims 1 to 5, characterized in that, The first compute node sends a memory borrowing request to the management node, including: When the remaining local memory space of the first computing node is less than the first waterline, the first computing node sends a memory borrowing request to the management node. The operating system of the first computing node accesses the first memory space based on the mapping, including: The operating system of the first computing node migrates file pages in the local memory space of the first computing node to the first memory space through the mapping, so that the remaining space in the local memory space of the first computing node is greater than or equal to the first waterline.
7. The method according to any one of claims 1 to 5, characterized in that, The method further includes: The first computing node counts the popularity of file pages in its local memory space; The first computing node sends a memory borrowing request to the management node as follows: when the proportion of file pages with a popularity higher than a first threshold in the local memory space of the first computing node is greater than or equal to a second threshold, the first computing node sends a memory borrowing request to the management node. The operating system of the first computing node accesses the first memory space based on the mapping, including: The operating system of the first computing node migrates file pages with a popularity lower than a preset value in the local memory space of the first computing node to the first memory space based on the mapping.
8. The method according to any one of claims 1 to 7, characterized in that, The operating system of the first computing node accesses the first memory space based on the mapping, including: The operating system of the first computing node prefetches data from the first memory space according to the mapping.
9. The method according to any one of claims 1 to 8, characterized in that, The method further includes: When the remaining local memory space of the first computing node is greater than or equal to the second waterline, the management node sends a first instruction to the first computing node. The first computing node releases the mapping between the first physical address and the memory management space according to the first instruction, and sends a notification that the release is complete to the management node; Upon receiving the notification, the management node sends a second instruction to the second computing node; The second computing node releases the first memory space according to the second instruction.
10. The method according to any one of claims 1 to 8, characterized in that, The method further includes: When the first value is greater than or equal to the second waterline, the management node sends a first instruction to the first computing node. The first value is the sum of the remaining amount of the local memory space of the first computing node and the amount of data in the file pages in the local memory space of the first computing node whose heat is less than or equal to the third threshold. The first computing node releases the mapping between the first physical address and the memory management space according to the first instruction, and sends a notification that the release is complete to the management node; Upon receiving the notification, the management node sends a second instruction to the second computing node; The second computing node releases the first memory space according to the second instruction.
11. A computing system, characterized in that, It includes a management node and multiple computing nodes connected via a bus. The first computing node among the multiple computing nodes is used to send a memory borrowing request to the management node. The management node is used to: request a first memory space from a second computing node among the plurality of computing nodes to satisfy the memory borrowing requirement, based on the memory borrowing requirement; The management node is also configured to: send the first physical address of the first memory space to the first computing node; The first computing node is further configured to: map the first physical address to the memory management space of the operating system of the first computing node, wherein the first memory space and the local memory space of the first computing node constitute the memory space of the first computing node; The operating system of the first computing node is used to access the first memory space based on the mapping.
12. The computing system according to claim 11, characterized in that, The management node stores node metadata reported by each of the plurality of computing nodes, and the management node is also used for: Based on the node metadata, the second computing node is determined to be the computing node that meets the memory borrowing requirement.
13. The computing system according to claim 12, characterized in that, The node metadata includes the remaining local memory space of each compute node and / or the distance between each compute node and the first compute node.
14. The computing system according to any one of claims 11 to 13, characterized in that, The first memory space is used as a page cache.
15. The computing system according to any one of claims 11 to 14, characterized in that, The memory management space of the operating system of the first computing node includes a first management space mapped to the local memory space of the first computing node and a reserved second management space. The first computing node is specifically used for: Record the mapping relationship between the second management space and the first physical address.
16. The computing system according to any one of claims 11 to 15, characterized in that, The first computing node is specifically used to: count the popularity of file pages in the local memory space of the first computing node; when the proportion of file pages with popularity higher than a first threshold in the local memory space of the first computing node is greater than or equal to a second threshold, send a memory borrowing request to the management node; The operating system of the first computing node is specifically used to: migrate file pages with a popularity less than a preset value in the local memory space of the first computing node to the first memory space based on the mapping.
17. The computing system according to any one of claims 11 to 16, characterized in that, The operating system of the first computing node is specifically used to: prefetch data from the first memory space according to the mapping.
18. The computing system according to any one of claims 11 to 17, characterized in that, The management node is also used for: When the first value is greater than or equal to the second waterline, a first instruction is sent to the first computing node. The first value is the sum of the remaining amount of the local memory space of the first computing node and the amount of data in the file pages in the local memory space of the first computing node whose heat is less than or equal to the third threshold. The first computing node is further configured to: unmap the first physical address from the memory management space according to the first instruction, and send a notification to the management node that the unmapping is complete; The management node is also configured to: send a second instruction to the second computing node after receiving the notification; The second computing node is also configured to: release the first memory space according to the second instruction.
19. A computer-readable storage medium, characterized in that, The system includes instructions that, when executed on a computing system, cause the computing system to perform the method as described in any one of claims 1 to 10, wherein the computing system includes a management node and a plurality of computing nodes connected via a bus.
20. A computer program product, characterized in that, The system includes instructions that, when executed on a computing system, cause the computing system to perform the method as described in any one of claims 1 to 10, wherein the computing system includes a management node and a plurality of computing nodes connected via a bus.