# Patent

## Title
Cluster-wide memory management using similarity-preserving signatures

## Abstract

A method includes, in a computing system that includes one or more compute nodes that run clients, defining memory chunks, each memory chunk including multiple memory pages accessed by a respective client. Respective similarity-preserving signatures are computed for one or more of the memory chunks. Based on the similarity-preserving signatures, an identification is made that first and second memory chunks differ in content in no more than a predefined number of memory pages with at least a predefined likelihood. Efficiency of access to the identified first and second memory chunks is improved.

## Background
CROSS-REFERENCE TO RELATED APPLICATIONS
This application claims the benefit of U.S. Provisional Patent Application 61/974,475, filed Apr. 3, 2014, whose disclosure is incorporated herein by reference.
FIELD OF THE INVENTION
The present invention relates generally to computing systems, and particularly to methods and systems for memory management in computing systems.
SUMMARY OF THE INVENTION
An embodiment of the present invention that is described herein provides a method including, in a computing system that includes one or more compute nodes that run clients, defining memory chunks, each memory chunk including multiple memory pages accessed by a respective client. Respective similarity-preserving signatures are computed for one or more of the memory chunks. Based on the similarity-preserving signatures, an identification is made that first and second memory chunks differ in content in no more than a predefined number of memory pages with at least a predefined likelihood. Efficiency of access to the identified first and second memory chunks is improved.
In some embodiments, computing a similarity-preserving signature for a memory chunk includes computing a set of page signatures over the respective memory pages of the memory chunk. Identifying that the first and second memory chunks differ in content in no more than a predefined number of memory pages with at least the predefined likelihood may include identifying that the similarity-preserving signatures of the first and second memory chunks differ in no more than a given number of page signatures.
In some embodiments, improving the efficiency of access includes finding in the first and second memory chunks respective first and second memory pages that have identical content, and deduplicating the first and second memory pages. Finding the first and second memory pages that have the identical content may include comparing respective first and second hash values computed over the first and second memory pages.
In an embodiment, improving the efficiency of access includes placing first and second clients, which respectively access the first and second memory chunks, on a same compute node. In an alternative embodiment, improving the efficiency of access includes placing first and second clients, which respectively access the first and second memory chunks, on first and second compute nodes that are topologically adjacent to one another in the computing system.
In another embodiment, improving the efficiency of access includes placing the first and second memory chunks on a same compute node or on first and second compute nodes that are topologically adjacent to one another in the computing system. In yet another embodiment, defining the memory chunks includes classifying the memory pages into active and inactive memory pages, and including in the memory chunks only the inactive memory pages.
There is additionally provided, in accordance with an embodiment of the present invention, a computing system including one or more compute nodes that include respective memories and respective processors. The processors are configured to run clients that access memory pages stored in the memories, to define memory chunks, each memory chunk including multiple memory pages accessed by a respective client, to compute respective similarity-preserving signatures for one or more of the memory chunks, to identify, based on the similarity-preserving signatures, that first and second memory chunks differ in content in no more than a predefined number of memory pages with at least a predefined likelihood, and to improve efficiency of access to the identified first and second memory chunks.
There is also provided, in accordance with an embodiment of the present invention, a computer software product, the product including a tangible non-transitory computer-readable medium in which program instructions are stored, which instructions, when read by one or more processors of respective compute nodes, cause the processors to run clients that access memory pages stored in memories of the compute nodes, to define memory chunks, each memory chunk including multiple memory pages accessed by a respective client, to compute respective similarity-preserving signatures for one or more of the memory chunks, to identify, based on the similarity-preserving signatures, that first and second memory chunks differ in content in no more than a predefined number of memory pages with at least a predefined likelihood, and to improve efficiency of access to the identified first and second memory chunks.
The present invention will be more fully understood from the following detailed description of the embodiments thereof, taken together with the drawings in which:



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a block diagram that schematically illustrates a computing system, in accordance with an embodiment of the present invention;
FIG. 2 is a diagram that schematically illustrates a memory-management data structure, in accordance with an embodiment of the present invention;
FIG. 3 is a flow chart that schematically illustrates a method for memory deduplication, in accordance with an embodiment of the present invention; and
FIG. 4 is a flow chart that schematically illustrates a method for virtual-machine placement, in accordance with an embodiment of the present invention.



DETAILED DESCRIPTION OF EMBODIMENTS
Overview
Embodiments of the present invention that are described herein provide improved methods and systems for managing memory resources in computing systems. In the disclosed embodiments, a computing system comprises one or more compute nodes that run clients, e.g., applications, Virtual Machines (VMs) or operating-system processes.
The memory space is typically split into equal-size units referred to as memory pages. The clients access content stored in memory by locating the appropriate memory page or pages and the accessing the content stored therein. Clients may access memory pages stored either on the same node or on other nodes.
The system identifies situations in which different clients access groups or ranges of memory pages, referred to herein as chunks, which are similar in content to one another. For example, the system may correlate various events and identify the patterns in which clients access groups or ranges of memory pages. By proper clustering, the system is able to improve storage efficiency and overall performance. For example, the system may de-duplicate memory pages that belong to different chunks but have identical content, or relocate clients that use similar memory chunks to the same compute node or to nearby nodes.
Each memory chunk comprises a plurality of memory pages, not necessarily contiguous, used by a certain client. Memory chunks are typically regarded as similar if they likely, with at least a certain likelihood, to differ in content by no more than a predefined number of memory pages. In order to identify similar memory chunks, the system computes and stores for each memory chunk a respective chunk signature that preserves the similarity property. In one embodiment, the chunk signature comprises a list of short page signatures that are computed over the respective memory pages of the chunk. Chunks are considered similar if their chunk signatures (page-signature lists) are likely to differ by no more than a given number of page signatures.
In a typical embodiment, the chunk similarity mechanism is implemented in addition to a mechanism for identifying exact matches between memory pages having the same content. For example, the system may compute and store a respective hash value over each memory page (not to be confused with the page signature that is part of the chunk signature). In an example deduplication process, the system may first identify similar memory chunks (using the chunk signatures), and then search within the similar chunks (using the hash values) for identical memory pages to be deduplicated.
In this deduplication process, the chunk similarity mechanism is used as a fast and computationally-efficient way of identifying memory ranges that are likely to contain large numbers of duplicate memory pages. The disclosed deduplication process is highly scalable and may be performed at various levels of the system, e.g., between applications or processes of a given VM, within VMs on a given compute node, or across an entire compute-node cluster.
As such, the methods and systems described herein are especially advantageous in large-scale compute-node clusters whose total memory size is on the order of hundreds of terabytes or more. Nevertheless, the disclosed techniques are applicable in small-scale computing systems, as well.
System Description
FIG. 1 is a block diagram that schematically illustrates a computing system 20, which comprises a cluster of multiple compute nodes 24, in accordance with an embodiment of the present invention. System 20 may comprise, for example, a data center, a cloud computing system, a High-Performance Computing (HPC) system or any other suitable system.
Compute nodes 24 (referred to simply as “nodes” for brevity) typically comprise servers, but may alternatively comprise any other suitable type of compute nodes. System 20 may comprise any suitable number of nodes, either of the same type or of different types. In some of the disclosed techniques, the system may even comprise a single compute node. Nodes 24 are connected by a communication network 28, typically a Local Area Network (LAN). Network 28 may operate in accordance with any suitable network protocol, such as Ethernet or Infiniband.
Each node 24 comprises a Central Processing Unit (CPU) 44, also referred to as a processor. Depending on the type of compute node, CPU 44 may comprise multiple processing cores and/or multiple Integrated Circuits (ICs). Regardless of the specific node configuration, the processing circuitry of the node as a whole is regarded herein as the node CPU. Each node 24 further comprises a memory 40, typically a volatile Random Access Memory (RAM), and a Network Interface Card (NIC) 48 for communicating with network 28. Some of nodes 24 may comprise non-volatile storage devices such as magnetic Hard Disk Drives—HDDs—or Solid State Drives—SSDs (not shown in the figure).
Typically, each node 24 runs one or more clients. In the present example, the clients comprise Virtual Machines (VMs) 32, which are assigned physical resources of the node (e.g., CPU, memory and networking resources) by a hypervisor 36. Alternatively, however, clients may comprise, for example, user applications, operating-system processes or containers, or any other suitable type of client. The description that follows refers to VMs, for the sake of clarity, but the disclosed techniques can be used in a similar manner with any other suitable types of clients.
The system and compute-node configurations shown in FIG. 1 are example configurations that are chosen purely for the sake of conceptual clarity. In alternative embodiments, any other suitable system and/or node configuration can be used. The various elements of system 20, and in particular the elements of nodes 24, may be implemented using hardware/firmware, such as in one or more Application-Specific Integrated Circuit (ASICs) or Field-Programmable Gate Array (FPGAs). Alternatively, some system or node elements, e.g., CPUs 44, may be implemented in software or using a combination of hardware/firmware and software elements. In some embodiments, CPUs 44 comprise general-purpose processors, which are programmed in software to carry out the functions described herein. The software may be downloaded to the processors in electronic form, over a network, for example, or it may, alternatively or additionally, be provided and/or stored on non-transitory tangible media, such as magnetic, optical, or electronic memory.
Memory Management Using Similarity-Preserving Signatures
In system 20, each VM accesses (e.g., reads and writes) memory pages that are stored in memory 40 of the node 24 that runs the VMs and/or in memory 40 of one or more other nodes 24. In some embodiments, system 20 runs a Node Page Manager (NPM) process that manages the memory resources of system 20, and in particular carries out the techniques described herein. The NPM process, or simply NPM for brevity, may be implemented in a distributed manner by CPUs 44 of nodes 24, by a selected CPU 44, or by some centralized management node (not shown in the figure).
In some embodiments, the NPM groups memory pages used by the VMs into memory chunks, computes for each chunk a respective similarity-preserving chunk signature, and uses the chunk signatures for improving the efficiency of accessing similar memory chunks. Each memory chunk comprises a plurality of memory pages, not necessarily contiguous, used by a certain VM 32. In one embodiment, each page is 4 KB in size and each memory chunk is 128 MB in size. Alternatively, any other suitable chunk size may be used. The chunk size need not necessarily be uniform or constant.
In some embodiments the NPM groups all the memory pages of a given VM into chunks. Alternatively, however, the NPM may group into chunks only some of the memory pages of a VM. For example, for deduplication purposes the NPM may classify the memory pages of a VM into active pages (that are accessed frequently) and inactive pages (that are accessed rarely if at all), and group into chunks only the inactive pages.
For each chunk, the NPM computes and stores a respective chunk signature. The chunk signature is also referred to as a similarity-preserving signature, because comparison between the chunk signatures of different chunks is indicative of the extent of similarity between the contents of the chunks. Typically, the NPM regards memory chunks as similar if they differ in content by no more than a predefined number of memory pages, with at least a predefined likelihood. In some embodiments the predefined likelihood is 1, i.e., the similarity is deterministic rather than statistical.
In different embodiments, the NPM may use various kinds of chunk signatures. The “similarity-preservation” property typically means that, if two chunks are similar, i.e., differ in content in no more than a predefined number of memory pages, their chunk signatures will be close to one another by at least a predefined amount with at least a predefined probability. In addition, if two chunks are dissimilar, i.e., differ in content in more than a given number of memory pages, their chunk signatures will be distant from one another by at least a given amount with at least a given probability. A good chunk signature is typically fast to compute and compare, and occupies a small amount of memory.
In one embodiment, the chunk signature comprises a list of short page signatures that are computed over the respective memory pages of the chunk. The NPM regards chunks as similar if their chunk signatures (page-signature lists) are likely to differ by no more than a given number of page signatures, and vice versa. Each page signature may comprise a short hash value computed over the respective page content.
Typically, the size of the page signature is smaller than the size of the hash values used for exact match detection of page content, because the former have less stringent accuracy requirements. The page hash values should represent the page content with very high probability, because they are used for actual deduplication decisions. The chunk signatures, on the other hand, are used for pointing the NPM to memory areas that are likely to contain a large number of duplicate pages (which will then be compared and de-duplicated using the accurate page hash values).
In an example embodiment, each page signature in the chunk signature is four bytes in size, while each page hash value is twenty bytes in size. Alternatively, however, any other suitable sizes can be used.
The NPM may compute the page signatures using any suitable computation scheme, for example using a sliding window and a rolling hash function. One possible example of a rolling hash function is the Karp-Rabin signature. Alternatively, however, any other suitable similarity-preserving hash function can be used. Example techniques are described, for example, by Martinez et al., in “State of the Art in Similarity Preserving Hashing Functions,” Proceedings of the 2014 International Conference on Security and Management, July, 2014; and by Yu et al., in “Error-Correcting Output Hashing in Fast Similarity Search,” Proceedings of the Second International Conference on Internet Multimedia Computing and Service, December, 2010, which are incorporated herein by reference.
FIG. 2 is a diagram that schematically illustrates a memory-management data structure 60, in accordance with an embodiment of the present invention. Data structure 60 is used by the NPM in performing various management processes that use the disclosed similarity-preserving chunk signatures.
For each VM 32, data structure 60 comprises one or more entries 62, each specifying a respective memory chunk. Each entry 62 comprises multiple page hash values 64 computed over the respective pages of the chunk, and a similarity-preserving chunk signature 68. In the present example, chunk signature 68 comprises a list of short page signatures.
Data structure 60 may be centralized or distributed over multiple nodes, depending on the implementation of the NPM process. In one embodiment, each node 24 computes page hash values 64 and chunk signature 68 for the memory pages and memory chunks used by its VMs. Each node shares this information with the cluster, so that the NPM process is able to access the entire data structure 60.
Example Memory Management Methods Using Similarity-Preserving Chunk Signatures
The NPM process may use the chunk signatures described herein for various management purposes. Typically, the chunk signatures are used as a fast and effective pre-screening tool that identifies memory regions that are likely to contain large numbers of duplicate memory pages.
FIG. 3 is a flow chart that schematically illustrates a method for memory deduplication using chunk signatures, in accordance with an embodiment of the present invention. The method begins with the NPM computing page hash values 64 and chunk signature 68, per VM, at a signature computation step 80.
At a similarity detection step 84, the NPM looks for memory chunks that are similar to one another, based on their respective chunk signatures 68. If similar chunks are found, the NPM proceeds to de-duplicate at least some of the memory pages in the similar chunks, at a deduplication step 88. Typically, the NPM finds duplicate memory pages, i.e., corresponding pages in the similar chunks that have identical content, using page hash values 64. When using this method, the NPM focuses its deduplication efforts on similar chunks, in which the likelihood of finding duplicate pages is high.
As noted above, the deduplication process of FIG. 3 can be performed within a node (“intra-node”) or across multiple nodes (“inter-node”). Inter-node deduplication can be performed, for example, using a distributed Bloom filter.
FIG. 4 is a flow chart that schematically illustrates a method for VM placement using chunk signatures, in accordance with another embodiment of the present invention. The method of FIG. 4 begins with the NPM computing page hash values 64 and chunk signature 68, per VM, at a signature calculation step 90.
At a VM checking step 94, the NPM identifies VMs that access similar memory chunks. If such VMs are found, the NPM migrates one or more of them so that, after migration, the VMs are located on the same compute node.
Locating VM that access similar memory chunks on the same node is advantageous for several reasons. For example, deduplication can be performed within the node and not between nodes. Moreover, locating more pages locally at the same node as the accessing VM reduces latency and communication overhead.
In an alternative embodiment, the NPM may not necessarily migrate the VMs (that access similar chunks) to the same node, but to nearby nodes. The term “nearby” in this context means that the nodes are topologically adjacent to one another in system 20, e.g., located less than a predefined number of network hops from one another.
In other embodiments, the NPM may migrate similar chunks to reside on the same node or at least on nearby nodes. Migration of chunks may be performed instead of or in addition to migration of VMs.
In alternative embodiments, the NPM may use the chunk signatures as a fast and memory-efficient means for producing a fingerprint or profile of the VM memory, e.g., using Bloom filters. VM memory fingerprints can be used for efficient comparison of VMs and identification of VMs that use similar content. Based on such identification, VMs can be placed and memory can be shared efficiently. VM placement based on such fingerprints can even be carried out without live VMs, by using fingerprints of previously-active VMs.
In some embodiments, the NPM may define a hierarchy, or nesting, of chunks. In such embodiments, chunks of a given size may be grouped into larger, higher-level chunks. Such a hierarchy enables the NPM to perform fast pruning of information.
Although the embodiments described herein mainly address management of volatile-memory resources, the methods and systems described herein can also be used in other applications, such as in managing persistent storage.
It will thus be appreciated that the embodiments described above are cited by way of example, and that the present invention is not limited to what has been particularly shown and described hereinabove. Rather, the scope of the present invention includes both combinations and sub-combinations of the various features described hereinabove, as well as variations and modifications thereof which would occur to persons skilled in the art upon reading the foregoing description and which are not disclosed in the prior art. Documents incorporated by reference in the present patent application are to be considered an integral part of the application except that to the extent any terms are defined in these incorporated documents in a manner that conflicts with the definitions made explicitly or implicitly in the present specification, only the definitions in the present specification should be considered.

## Claims

1. A method, comprising:
in a computing system that includes a plurality of compute nodes that run clients, defining memory chunks, each memory chunk comprising multiple memory pages accessed by a respective client;
computing respective similarity-preserving signatures for two or more of the memory chunks;
identifying, based on the similarity-preserving signatures, memory chunks that differ in content in no more than a predefined number of memory pages with at least a predefined likelihood, and noting first and second clients on different computing nodes, accessing the identified memory chunks; and
migrating the first client to the compute node hosting the second client or to a compute node topologically adjacent in the computing system to the compute node hosting the second client, responsively to identifying the memory chunks that differ in content in no more than a predefined number of memory pages with at least a predefined likelihood.

2. The method according to claim 1, wherein computing a similarity-preserving signature for a memory chunk comprises computing a set of page signatures over the respective memory pages of the memory chunk.

3. The method according to claim 2, wherein identifying memory chunks that differ in content in no more than a predefined number of memory pages with at least the predefined likelihood comprises identifying that the similarity-preserving signatures of the memory chunks differ in no more than a given number of page signatures.

4. The method according to claim 1, further comprising finding in the identified memory chunks respective first and second memory pages that have identical content, and deduplicating the first and second memory pages.

5. The method according to claim 4, wherein computing a similarity-preserving signature for a memory chunk comprises computing a set of page signatures over the respective memory pages of the memory chunk, and wherein finding the first and second memory pages that have the identical content comprises comparing respective first and second hash values, different from the page signatures, computed over the first and second memory pages.

6. The method according to claim 1, wherein defining the memory chunks comprises classifying the memory pages into active and inactive memory pages, and including in the memory chunks only the inactive memory pages.

7. A computing system, comprising a plurality of compute nodes that comprise respective memories and respective processors, wherein the processors are configured to run clients that access memory pages stored in the memories, to define memory chunks, each memory chunk comprising multiple memory pages accessed by a respective client, to compute respective similarity-preserving signatures for two or more of the memory chunks, to identify, based on the similarity-preserving signatures, memory chunks that differ in content in no more than a predefined number of memory pages with at least a predefined likelihood, and noting first and second clients on different computing nodes, accessing the identified memory chunks, and to migrate the first client to the compute node hosting the second client or to a compute node topologically adjacent in the computing system to the compute node hosting the second client, responsively to identifying the memory chunks that differ in content in no more than a predefined number of memory pages with at least a predefined likelihood.

8. The system according to claim 7, wherein the processors are configured to compute a similarity-preserving signature for a memory chunk by computing a set of page signatures over the respective memory pages of the memory chunk.

9. The system according to claim 8, wherein the processors are configured to identify that the memory chunks that differ in content in no more than a predefined number of memory pages with at least the predefined likelihood, by identifying that the similarity-preserving signatures of the memory chunks differ in no more than a given number of page signatures.

10. The system according to claim 7, wherein the processors are configured to find in the identified memory chunks respective first and second memory pages that have identical content, and to deduplicate the first and second memory pages.

11. The system according to claim 10, wherein the processors are configured to compute a similarity-preserving signature for a memory chunk by computing a set of page signatures over the respective memory pages of the memory chunk, and to find the first and second memory pages that have the identical content by comparing respective first and second hash values, different from the page signatures, computed over the first and second memory pages.

12. The system according to claim 7, wherein the processors are configured to classify the memory pages into active and inactive memory pages, and to include in the memory chunks only the inactive memory pages.

13. A computer software product, the product comprising a tangible non-transitory computer-readable medium in which program instructions are stored, which instructions, when read by a plurality of processors of respective compute nodes, cause the processors to run clients that access memory pages stored in memories of the compute nodes, to define memory chunks, each memory chunk comprising multiple memory pages accessed by a respective client, to compute respective similarity-preserving signatures for two or more of the memory chunks, to identify, based on the similarity-preserving signatures, memory chunks that differ in content in no more than a predefined number of memory pages with at least a predefined likelihood, and noting first and second clients on different computing nodes, accessing the identified memory chunks, and to migrate the first client to the compute node hosting the second client or to a compute node that are topologically adjacent in the computing system to the compute node hosting the second client, responsively to identifying the memory chunks that differ in content in no more than a predefined number of memory pages with at least a predefined likelihood.

14. The method according to claim 1, wherein migrating the first client comprises migrating the first client to the compute node hosting the second client.

15. The method according to claim 1, wherein migrating the first client comprises migrating the first client to a compute node topologically adjacent to the compute node hosting the second client.