A multi-layer buffer management method and system based on separated memory
By allocating buffer pools to compute nodes and memory nodes in a separate memory architecture, and using pointer conversion technology and state machine to manage page status, the problem of large buffer management overhead in a separate memory architecture is solved, and efficient buffer management and resource utilization are achieved.
Patent Information
- Application Number
- CN202411564325.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-11-05
AI Technical Summary
In a separate memory architecture, communication delay between computing nodes and memory nodes leads to high computational overhead in concurrent scenarios, reducing system performance.
By allocating independent buffer pools in the computing node and memory node, using pointer conversion technology and state machine to manage page status, bypassing hash table address translation, efficient positioning and data access across node pages are achieved.
It significantly improves the buffer management efficiency of database systems under the separate memory architecture, reduces buffer management overhead, and improves the overall performance and resource utilization of the system.
Smart Images

Figure CN119149448B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer storage technology, and in particular to a multi-layer buffer management method and system based on separate memory. Background Art
[0002] Separated memory architecture has become an important design direction for modern data centers and cloud database systems. This architecture physically separates compute nodes and memory nodes and connects them through high-speed networks (e.g., RDMA, translated as Remote Direct Memory Access), allowing compute nodes to flexibly access a shared memory pool. Compared with traditional tightly coupled architectures, separated memory architectures have higher resource utilization, scalability, and flexibility because compute resources and memory resources can be independently expanded as needed. This architecture is particularly suitable for application scenarios that process large-scale data and have frequently changing memory requirements, such as real-time analysis, big data processing, and high-performance computing.
[0003] However, this separation of computing and memory also brings new challenges, especially in terms of buffer management in database systems. In a separated memory architecture, since there is still a certain delay in the communication between computing nodes and memory nodes, although it is faster than traditional disk IO (input and output), it is still much slower than local memory access. Therefore, it is necessary to introduce hierarchical buffer management on computing nodes and memory nodes.
[0004] In traditional database systems, buffer management strategies usually reside in the local memory of the computing node, using hash tables and complex data structures to optimize access between local memory and disk to improve cache hit rates. These buffer management strategies rely on maintaining complex data structures, such as hash tables and LRU (Least Recently Used) linked lists, for fast search, insertion, and deletion of cached data. Although these data structures can effectively improve the access efficiency between local memory and disk, they also bring significant computational overhead, especially when the data size and access concurrency increase. This will not only lead to additional overhead for buffer management, but may also reduce the overall performance of the system, thereby affecting the efficiency of the database system. Therefore, it is necessary to design a new hierarchical buffering scheme to reduce buffer management overhead.
[0005] In view of this, the present invention is proposed. Summary of the invention
[0006] The purpose of the present invention is to provide a multi-layer buffer management method and system based on separated memory, in which a virtual memory pointer is used to replace the page identifier used in the traditional buffer in the buffer management, bypassing the overhead of the hash table for address translation. In this way, efficient management of the buffer memory page (fast positioning and data access) is achieved, avoiding the scalability problem of the centralized data structure in concurrent scenarios.
[0007] The objective of the present invention is achieved through the following technical solutions:
[0008] A multi-layer buffer management method based on a separated memory includes: allocating independent buffer pools in computing nodes and memory nodes respectively, and collaboratively implementing a buffer management module under a separated memory architecture;
[0009] Among them, the buffer management module: uses pointer conversion technology to record the location of pages in combination with a set data structure; manages page state changes through a state machine to achieve page state flow and update the information in the set data structure; allocates pages in computing nodes and memory nodes in combination with the location of pages recorded in the set data structure; and recycles pages in computing nodes and memory nodes according to the page status and state changes.
[0010] A multi-layer buffer management system based on a separated memory is implemented based on the above method, and the system comprises: a buffer management module under a separated memory architecture; the buffer management module under the separated memory architecture is implemented by independent buffer pools respectively allocated to computing nodes and memory nodes;
[0011] Among them, the buffer management module: uses pointer conversion technology to record the location of pages in combination with a set data structure; manages page state changes through a state machine to achieve page state flow and update the information in the set data structure; allocates pages in computing nodes and memory nodes in combination with the location of pages recorded in the set data structure; and recycles pages in computing nodes and memory nodes according to the page status and state changes.
[0012] It can be seen from the technical solution provided by the present invention that the present invention is suitable for managing cache and persistent storage resources between computing nodes and memory nodes in a separated memory architecture. The introduced pointer conversion technology replaces the traditional page identifier with a virtual memory address, bypasses the address translation process of the hash table, and realizes efficient cross-node page positioning and data access; the introduced state synchronization mechanism can track the distribution of pages in different storage layers, optimize the process of page migration between different levels, and reduce the overhead of the special case of re-applying for pages after being evicted; the introduced page allocation mechanism can efficiently manage page resources between computing nodes, memory nodes and persistent storage devices, ensuring fast response and resource optimization in different scenarios; the introduced page recycling mechanism can recycle invalid pages in time to ensure the resource utilization of the buffer and the stability of the system. In general, the multi-layer buffer management solution provided by the present invention significantly improves the buffer management efficiency of the database system under the separated memory architecture, and provides a better solution for high-performance distributed databases. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0014] Figure 1 A schematic diagram of a complete page state flow in a multi-layer buffer management method based on a separate memory provided by an embodiment of the present invention;
[0015] Figure 2 A schematic diagram of a Swip structure provided in an embodiment of the present invention and a buffer page indexed to a computing node and a memory node through a Swip;
[0016] Figure 3 A schematic diagram of a buffer management solution on a computing node provided by an embodiment of the present invention;
[0017] Figure 4 A schematic diagram of a buffer management solution on a memory node provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0018] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of the present invention.
[0019] First, the terms that may be used in this article are explained as follows:
[0020] The term “and / or” means that either or both of them can be realized at the same time. For example, X and / or Y means both “X” or “Y” and “X and Y”.
[0021] The terms "include", "comprises", "contains", "has" or other descriptions with similar semantics should be interpreted as non-exclusive inclusion. For example, including certain technical feature elements (such as raw materials, components, ingredients, carriers, dosage forms, materials, dimensions, parts, components, mechanisms, devices, steps, procedures, methods, reaction conditions, processing conditions, parameters, algorithms, signals, data, products or products, etc.) should be interpreted as including not only certain technical feature elements explicitly listed, but also other technical feature elements known in the art that are not explicitly listed.
[0022] The term "consisting of..." means excluding any technical feature elements not explicitly listed. If this term is used in a claim, it will make the claim closed, so that it does not contain technical feature elements other than the technical feature elements explicitly listed, except for the conventional impurities related to them. If this term only appears in a clause of a claim, it only limits the elements explicitly listed in the clause, and the elements recorded in other clauses are not excluded from the overall claim.
[0023] The following is a detailed description of a multi-layer buffer management method and system based on a separated memory provided by the present invention. The contents not described in detail in the embodiments of the present invention belong to the prior art known to professional and technical personnel in the field. If no specific conditions are specified in the embodiments of the present invention, the conventional conditions in the field or the conditions recommended by the manufacturer are followed. The reagents or instruments used in the embodiments of the present invention, if the manufacturer is not specified, are all conventional products that can be purchased commercially.
[0024] Embodiment 1
[0025] The embodiment of the present invention provides a multi-layer buffer management method based on separated memory, which mainly includes: configuring a buffer management module in the computing node and the memory node respectively, the buffer management module has pointer conversion, state synchronization, page allocation, and page recycling functions, and the computing node and the memory node both implement page scheduling based on the buffer management module configured by themselves. Specifically: the buffer management module: uses pointer conversion technology to record the location of the page in combination with a set data structure; manages the state change of the page through a state machine, realizes the state flow of the page and updates the information in the set data structure; allocates pages in the computing node and the memory node in combination with the location of the page recorded in the set data structure; recycles pages in the computing node and the memory node according to the state of the page and the state change.
[0026] The solution provided by the embodiment of the present invention is applicable to the separated memory architecture, and can manage the cache and persistent storage resources between the computing nodes and the memory nodes. The introduced pointer conversion technology replaces the traditional page identifier with a virtual memory address, bypasses the address translation process of the hash table, and realizes efficient positioning and data access of pages across nodes; the introduced state synchronization mechanism can track the distribution of pages in different storage layers, optimize the process of page migration between different levels, and reduce the overhead of the special case of re-applying for pages after being evicted; the introduced page allocation mechanism can efficiently manage the page resources between the computing nodes, memory nodes and persistent storage devices, and ensure fast response and resource optimization in different scenarios; the introduced page recycling mechanism can recycle invalid pages in time to ensure the resource utilization of the buffer and the stability of the system. In general, the multi-layer buffer management solution provided by the present invention significantly improves the buffer management efficiency of the database system under the separated memory architecture, and provides a better solution for high-performance distributed databases.
[0027] In order to more clearly demonstrate the technical solution and technical effects provided by the present invention, the method provided by the embodiment of the present invention is described in detail with reference to specific embodiments below.
[0028] 1. Detailed introduction of the plan.
[0029] The embodiment of the present invention provides a multi-layer buffer management method based on pointer conversion technology in a separated memory architecture, in which a virtual memory pointer is used to replace the page identifier used in the traditional buffer, bypassing the overhead of address translation in the hash table. In this way, efficient management of buffer memory pages is achieved, avoiding the scalability problem of centralized data structure in concurrent scenarios.
[0030] In the embodiment of the present invention, independent buffer pools are allocated in the computing nodes and memory nodes respectively. The two types of buffer pools are combined to collaboratively implement complete buffer management under the separated memory architecture, supporting functions such as page allocation, state synchronization, page replacement, pointer conversion and page recycling. In the embodiment of the present invention, a buffer module for a separated memory database can be obtained by adaptively modifying the relevant modules of the existing database to provide mutually exclusive page access to the upper application layer. The computing nodes and memory nodes configured with the buffer management module are linked to achieve the following: Figure 1 The complete page state flow shown reduces the maintenance overhead of complex data structures and improves the scalability of buffer management, thereby significantly improving the overall system performance. Figure 1 The page state transfer logic involved will be introduced later.
[0031] In addition, the introduction of the Offload mechanism further optimizes system performance. The Offload mechanism offloads some computing tasks to memory nodes for execution, reducing the resource usage of computing nodes and network transmission overhead, effectively improving the overall efficiency of the system, especially in high-concurrency scenarios, significantly reducing latency and reducing resource consumption.
[0032] As mentioned before, the buffer pools of compute nodes and memory nodes jointly support the buffer management of the separated memory scenario, involving functions such as page allocation, state synchronization, page replacement, pointer conversion, and page recycling. Among them, the compute node plays a leading role in most module functions in buffer management. Correspondingly, the memory node mainly provides memory resources, responds to compute node resource requests and offload mechanisms. The following mainly introduces the important functions of the buffer management module.
[0033] 1. Pointer conversion.
[0034] Pointer conversion is an intrusive address translation technology. Its core is to use virtual memory addresses to replace the page identifiers inside the buffer data structure. Through pointer conversion technology, the location of the page (i.e., buffer page) is recorded in combination with the set data structure. Specifically: By embedding the pointer directly into the buffer data structure, pointer conversion avoids the performance overhead of traditional hash table search and achieves faster page positioning and data access. In addition, an auxiliary flag bit (i.e., status bit) is introduced to indicate the location of the current page, such as whether the page is located in a computing node, a memory node, or a persistent storage device, so that the page status can be quickly determined during the pointer conversion process, memory resources can be reasonably scheduled, and data consistency can be ensured.
[0035] In order to extend pointer conversion to a separate memory architecture, the data structure set by the present invention includes three parts of information: the first part of the information is a flag bit, which is used to indicate the location of the page; the second part of the information is a remote information storage bit, which is used to store the index of the remote memory address information array of the page; the third part is a local information storage bit, which is used to store the page in the local memory address; wherein, the remote memory address information array contains relevant information of the memory node buffer pool page, and the local memory address is the memory address of the buffer pool in the computing node.
[0036] like Figure 2 As shown, an example of the data structure of the setting is provided, and the data structure is called the Swip data structure. The following text is introduced in conjunction with the Swip data structure and is directly referred to as Swip. Two flag bits (State) are used to identify the location of the page referenced by Swip: whether it exists in both the computing node (CN) and the memory node (MN), or only in the memory node, or only in the persistent storage device. In addition to the flag bit, 14 bits are used to store the index of the remote address information array (Remote Addr Info Array, RAI) to quickly locate the data in the remote memory. This situation is only for the computing node. When it is necessary to find a page on the memory node, an index is obtained through these 14 bits, and the corresponding data information is found on the remote memory address information array of the memory node using the index, and then the corresponding page (MN Buffer Pages) on the memory node buffer pool is found through the corresponding data information. The remaining 48 bits are used to store the local memory address, which can be converted into a pointer to the buffer pool page (CN Buffer Pages) in the computing node. In this example, the characteristics of the modern 64-bit x86 microarchitecture are utilized, that is, the 64-bit address space is not fully implemented, so that these free bits can be effectively used for pointer conversion and address storage. Through this Swip-based design, efficient pointer conversion can be achieved in a separated memory architecture, and pages can be quickly located and accessed regardless of whether they are located in local memory or remote memory.
[0037] In order to obtain the distribution of pages in the multi-layer buffer, the following flags can be used to quickly determine the page status. The multi-layer buffer described here mainly includes three storage layers, namely computing nodes, memory nodes, and persistent storage devices (for example, disks).
[0038] (1) LSwizzled (11): When the flag is 11, it indicates that the page exists in the buffer pool of both the compute node and the memory node. At this time, the local memory address in the Swip points to the buffer pool page in the compute node, and the system can directly use this address for fast access. Although the Swip also contains relevant information on the remote memory, in the LSwizzled state, the address information in the compute node is used for access first.
[0039] (2) RSwizzled (01): When the flag is 01, it means that the page is only cached in the memory node, or is in the buffer pool of both the compute node and the memory node, but is a candidate for eviction in the compute node buffer pool. Swip contains the index of the remote address information array. Based on this index, the specific address and status information of the page in the memory node can be found in the remote address information array, and this information can be used to perform read and write operations on the remote memory.
[0040] (3) UnSwizzled (00): When the flag is 00, it indicates that the page is only in the persistent storage device, that is, the page is not in any buffer pool, or is only cached in the memory node, but is already a candidate for eviction in the memory node buffer pool. At this time, the remaining bits of Swip (that is, the second and third parts) are used to represent the page identifier. Through the page identifier, the mapping structure retained in the computing node can be used to find the storage location of the page on the persistent storage device, and perform page loading and data operations.
[0041] The above LSwizzled, RSwizzled and UnSwizzled are identification names given to the three states for ease of understanding.
[0042] In addition, no matter what state the page is in, it will be stored in the persistent storage device. The main difference is that in the first two states, the page is not only stored in the persistent storage device, but also stored in the memory node, or stored in both types of nodes at the same time.
[0043] Based on the flag design in the above Swip, it is possible to quickly determine and locate the distribution of pages in the three-tier storage, achieve optimized access to computing nodes, memory nodes, and persistent storage devices, and improve data access performance and system resource utilization efficiency.
[0044] In addition, in order to support concurrent access, it is necessary to ensure that the data structure of Swip can be modified mutually exclusively. Since the data part of Swip occupies 64 bits, the most basic CAS (Compare And Swap) atomic operation can be used to ensure synchronization and mutual exclusive access to Swip data. Through the CAS atomic operation, the identification bits and address information in Swip can be safely modified in a multi-threaded environment to ensure that no race conditions occur during the pointer conversion process. When the distribution of the page pointed to by Swip changes in the three-tier storage system, the Swip content (flag bits and addresses) in the parent page can be modified to express this change. In this way, multiple threads can safely perform Swip read and write operations, thereby maintaining data consistency and system stability.
[0045] 2. Status synchronization.
[0046] In order to extend the pointer conversion technology to the split memory architecture, the present invention designs a complex finite state machine to manage the state changes of pages in the buffer pool. The state machine not only tracks the distribution of pages in different storage layers, but also optimizes the process of page migration between different layers by introducing intermediate states, reducing the overhead of re-applying for the special case of a page being evicted.
[0047] (1) The finite state machine (abbreviated as state machine) contains three basic states: Hot state, Normal state, and Cold state; the above states are the states of the pages managed by the state machine.
[0048] (1.1) The Hot state indicates that the page exists in the buffer pools of both the compute node and the memory node. In this state, the parent page Swip (also in the Hot state) of the corresponding page retains the reference information of the page in the compute node buffer pool. The reference information of the page is reflected by the second and third parts of the Swip. The second part of the information is related to the memory node and reflects the reference information of the page in the memory node buffer pool. The third part is related to the compute node and reflects the reference information of the page in the compute node buffer pool.
[0049] (1.2) The Normal state indicates that the page only exists in the buffer pool of the memory node; at this time, the parent page of the corresponding page can find the reference information of the page in the memory node.
[0050] (1.3) The Cold state means that the page is not in any buffer pool and is only stored in the persistent storage device.
[0051] Those skilled in the art can understand that the commonly used index structure of the database is a tree structure (B-tree). The locations of other pages may be retained in a page. This relationship of retaining references to other pages is called a parent-child relationship. For the tree structure, each page has only one father (a father can have multiple child pages).
[0052] (2) In order to optimize the impact of pages being evicted from the buffer pool and then reloaded, two intermediate states are introduced: Warm state and Cool state, to alleviate the performance impact of pages being evicted to the next level of storage but then immediately retrieved.
[0053] (2.1) The Warm state represents the process of a page being evicted from a compute node to a memory node; at this point, the page exists in both the compute node and the memory node buffer pool, but the Swip structure no longer retains the reference in the compute node. Pages in the Warm state are in a first-in-first-out queue (FIFO) and are candidates for being evicted to a memory node.
[0054] (2.2) The Cool state indicates the process of a page being evicted from a memory node to a persistent storage device. At this point, the page is still in the memory node buffer pool, but the reference to the memory node is no longer retained in Swip. Pages in the Cool state are also placed in a FIFO queue as candidates to be evicted to disk.
[0055] By introducing the above intermediate states, the migration of pages between different storage layers can be smoothly processed, reducing the performance overhead of reloading after page eviction. The state synchronization mechanism effectively maintains the performance and resource utilization of the buffer pool by tracking the distribution of pages in each layer and their state transitions.
[0056] (3) The present invention provides all possible states of pages in the buffer pool based on the pointer conversion technology. The state transition logic is introduced below. It is mainly divided into two parts. The first part introduces the logic of transitioning to the Hot state, and the second part introduces the logic of transitioning from the Hot state to the Cold state. Figure 1 It shows the process of related state flow. Figure 1 Each state is represented by a circle, and the arrow lines and text between the states represent the flow between different states and the operations involved in the flow.
[0057] (3.1) Logic for transitioning to the Hot state.
[0058] In a separated memory architecture, data operations need to be performed in the memory of the computing node. Therefore, when a page allocation request is received from the application layer, the page must be converted to the Hot state, which is called the LSwizzle (pointer reference loading) operation. The LSwizzle operation includes: the system loads the page into the buffer pool of the computing node and the memory node, and retains the reference information of the two buffer pools (i.e., the buffer pool of the computing node and the memory node) to the page in the set data structure (Swip), and updates the position of the corresponding page at the same time, that is, the flag is synchronously updated to LSwizzled. For a page to be converted from the Normal state or the Cold state to the Hot state, it is only necessary to allocate the page in the buffer pool of the computing node and the memory node according to the page allocation requirements, and then update the position of the corresponding page in the Swip to reflect the latest state.
[0059] The state flow of the intermediate state is relatively complex:
[0060] (3.1.1) When a page is converted from the Warm state to the Hot state, the page reference information of the memory node buffer pool is determined based on the second part of the information in Swip, the corresponding page is located in the FIFO queue responsible for evicting the memory node buffer pool page, the page in the memory node buffer pool is reused, and is removed from the FIFO queue responsible for evicting the memory node buffer pool page, and the computing node address in Swip is updated to restore its access capability in the computing node.
[0061] (3.1.2) When a page is converted from the Cool state to the Hot state, the second and third parts of the information in Swip represent the page identifier. Based on the page identifier, the corresponding page is found in the FIFO queue responsible for evicting the memory node buffer pool page; then, according to the page allocation logic, the page is retrieved from the memory node buffer pool to the computing node buffer pool; if it involves an ongoing IO (Inflight IO) operation, special processing is required according to the page allocation logic, that is, for such pages, they will be protected by locks. If there is subsequent access to the same page, the ongoing IO will be blocked here to avoid repeated loading. After completion, the page must be removed from the FIFO queue, and the address of the computing node, memory node and the location of the page in Swip must be updated to ensure state consistency. In this process, the Cool state is an intermediate state. Although the page is still in the memory node buffer pool and has not yet been stored on the disk, it cannot be found through Swip, and the corresponding FIFO queue has a page in the Cool state, so it can be found through the corresponding FIFO queue; further, when an eviction operation is required later, a page is selected from the FIFO queue and then evicted.
[0062] Those skilled in the art can understand that an ongoing IO operation means that the current page is being loaded but has not been fully loaded. The related special processing mainly means that for such pages, they will be protected by locks. If there is subsequent access to the same page, the ongoing IO will be blocked here to avoid repeated loading. This part of the buffer pool design needs to be considered, and the solutions are basically similar ideas, which will not be elaborated in the present invention.
[0063] In the embodiment of the present invention, the FIFO queue refers to a FIFO queue of eviction candidates, which includes two FIFO queues, one responsible for the eviction of computing node pages, and the other responsible for the eviction of memory node pages, and the above two FIFO queues are both located in the computing node.
[0064] (3.2) The logic of flowing from the Hot state to the Cold state.
[0065] The previous article introduced the logic of converting the page state to the Hot state, making the page available to the application layer. However, due to the limited resources of the computing node buffer pool, the system needs to gradually evict high-level pages from the buffer pool and eventually convert them to the Cold state. This process includes the following stages:
[0066] (3.2.1) The Hot state transfers to the Warm state: When the buffer pool resources of the computing node are tight (that is, the resources are less than the threshold), the candidate pages for eviction are selected according to the page recycling algorithm and placed in the FIFO queue responsible for evicting the pages of the computing node buffer pool; then, the following operations are performed: the reference information of the pages in the computing node buffer pool in Swip (that is, the third part of the information) is cleared, and the location of the page (that is, the flag bit in Swip) is updated. The above operation is called LUnswizzle (local pointer dereference) operation. At this time, the state of the page is transferred to the Warm state.
[0067] (3.2.2) Transfer from Warm state to Normal state: When a page is in the Warm state and the corresponding compute node buffer pool page is evicted to the memory node buffer pool, the corresponding candidate page in the FIFO queue responsible for evicting the compute node buffer pool page is cleared; the above operation is called the Cooling operation; at this point, the state transition is completed, the page state changes to the Normal state, and exists only in the memory node buffer pool.
[0068] (3.2.3) Normal state transfers to Cool state: In Normal state, the eviction candidate page in the memory node buffer pool is selected according to the page recycling algorithm, and is placed in the FIFO queue responsible for evicting the memory node buffer pool page; then, the following operations are performed: the reference information of the page in the memory node buffer pool in Swip (that is, the second part of the information) is cleared, and the page identifier is written back to update the location of the page; the above operation is called RUnswizzle (remote pointer dereference) operation; at this time, the state of the page is transferred to Cool state, waiting to be further evicted.
[0069] (3.2.4) Cool state transfers to Cold state: When a page is in the Cool state and needs to be evicted from the memory node buffer pool, the recycled page is selected and written back to the persistent storage device as a dirty page, and the corresponding candidate page in the FIFO queue responsible for evicting the memory node buffer pool page is cleared. Finally, the state of the page changes to the Cold state and only exists in the persistent storage device; the above operation is called the Ice operation.
[0070] The state transfer logic provided by the embodiment of the present invention effectively manages the distribution of pages among computing nodes, memory nodes and persistent storage devices by switching between different states, thereby ensuring fast access to pages and efficient use of system resources.
[0071] like Figure 3 As shown in FIG. 1 , it is a schematic diagram of the buffer management scheme on the computing node; Figure 4 As shown in Figure 1, it is a schematic diagram of the buffer management scheme on the memory node; it includes Figure 1 All possible states are shown, and how the pages are referenced through Swip and other auxiliary structures. Figure 3 and Figure 4 The solid rectangle in the middle represents the page, and the symbol in the page represents the state. Figure 1 The symbols P1, P2, ..., P11 in the upper left corner of the page are the identifiers of these pages, which are used to distinguish different pages. The circle inside the page represents the Swip structure. The line from the Swip in the page to other pages represents the Swip reference, which means that the page in the corresponding buffer pool can be found through the Swip (it can be on the computing node or the memory node, marked with different types of dotted circles). FIFO queues are used to retain eviction candidates. Figure 3 The FIFO queue in is the eviction candidate queue of the computing node buffer pool, that is, the FIFO queue responsible for the eviction of computing node pages. Figure 4The FIFO queue in is the eviction candidate queue of the memory node buffer pool, that is, the FIFO queue responsible for the eviction of memory node pages; the ongoing IO will hold an OS lock (system resource lock). If the same page is repeatedly requested but there is already IO loading, these requests for the same page will be blocked. After the IO is completed, the lock will be released.
[0072] 3. Page allocation.
[0073] Page allocation is the most basic functional requirement of the database buffer pool. When the application layer involves the modification of data pages, it needs to be retrieved into the memory for modification before the result can be written back. For applications based on the buffer pool, resources are usually pooled to reduce the application release overhead. Accordingly, memory allocation also needs to be managed.
[0074] In an embodiment of the present invention, the computing node and the memory node will pre-allocate a portion of the resource pool during the system initialization phase to meet the subsequent page allocation requirements. Assuming that the current split memory architecture is implemented based on an RDMA (remote direct data access) high-speed network, the RDMA programming model requires registration of basic meta information before communication, including relevant information of the memory area, so the buffer pool also needs to be registered through additional communication according to the common practice.
[0075] During the pointer conversion process, when determining the state of the target page, the location of the page may be in the following three situations (the actual state may be more):
[0076] (1) The page is located in the buffer pool of the compute node, the buffer pool of the memory node, and the persistent storage device at the same time.
[0077] (2) The pages are located in the buffer pool of the memory node and the persistent storage device.
[0078] (3) The page is located only on persistent storage devices.
[0079] For the above three situations, it is ultimately necessary to apply for a buffer page in the buffer pool of the computing node and the memory node for the page.
[0080] (1) If the page exists in the buffer pool of the computing node and memory node and the persistent storage device, no additional operation is required for the page application. The existing page can be directly used to complete the page allocation.
[0081] (2) If the page is only located in the buffer pool of the memory node and the persistent storage device, the page address of the buffer pool of the memory node is obtained through address translation, and an available free page is allocated in the buffer pool of the computing node. From the page address of the buffer pool of the memory node, the page is copied to the available free page in the buffer pool of the computing node to complete the page allocation.
[0082] As mentioned before, the second part of Swip stores index information, from which the specific page address can be obtained. Furthermore, accessing the memory node requires some additional information (such as a key, which is determined by the hardware). Figure 2 As shown, the information needed to access the remote memory can be saved in an array (remote memory address information array, RAI), and the second part of the information in Swip stores the index of this array. The process of accessing the page in the memory node buffer pool through Swip can be described as: obtaining the index through the second part of the information in Swip, finding the corresponding data information by accessing the remote memory address information array, and then accessing the buffer pool page of the memory node.
[0083] (3) If the page only exists in the persistent storage device, the page is retrieved from the persistent storage device according to the mapping from the page identifier to the persistent storage device address, and then synchronized to the buffer pool of the memory node and the computing node to complete the page allocation.
[0084] The above classification is only based on the distribution of pages in the buffer pool. Figure 1 There is a one-to-many relationship between the states in the table. What needs to be discussed here is the ongoing IO (input and output) operation. Specifically, during the state transfer process, when a page is retrieved from the buffer pool of the memory node or the persistent storage device, if a request for the same page is received, no additional IO operation is performed, and only the current ongoing IO operation needs to be waited for to end. When the corresponding page needs to be obtained from the persistent storage device, the ongoing IO table located in the computing node ( Figure 3 InflightIO in the memory node) to determine whether the current IO operation is completed; when the corresponding page needs to be obtained from the buffer pool of the memory node, the remote storage address of the page (the index of the remote address information array) is obtained according to Swip, and the status in the remote storage address is queried to determine whether the corresponding page is in an ongoing IO operation.
[0085] Through the hierarchical page allocation mechanism provided by the present invention, the system can efficiently manage page resources between computing nodes, memory nodes and persistent storage, ensuring fast response and resource optimization in different scenarios.
[0086] 4. Page recycling.
[0087] Although the pointer conversion technology introduced in the present invention can effectively improve the page access performance, it does not solve the problem of selecting pages to be evicted after the buffer pool is fully loaded. Traditional page replacement algorithms, such as the least recently used (LRU) or second chance algorithm, require updating status information each time a page is accessed, which can easily lead to performance bottlenecks on frequently accessed pages (such as the root node of a B-tree). In a separated memory architecture, it is also necessary to consider the page eviction strategy of the buffer pool in both the computing node and the memory node. In order to adapt to this architecture, the Unswizzle (dereference of pointers) mechanism of pointer conversion is extended to the separated structure, and different eviction logics are designed for pages in different states. Unswizzle represents clearing the reference to a page, and a reference refers to a page in the buffer pool that can be found through Swip.
[0088] For pages in the Hot state, the LUnswizzle operation is introduced (i.e., clearing the reference of the page in the computing node buffer pool in the set data structure and updating the position of the page) to handle the eviction of the computing node buffer pool. The eviction of the page occurs only when the page does not contain the LSwizzled Swip, that is, when all child node references of the corresponding page in the computing node have been released, the corresponding page is evicted from the computing node buffer pool as a candidate to complete the page recycling in the computing node; the child node reference means that the corresponding page in the buffer pool can be found through the corresponding Swip.
[0089] For pages in the Normal state, the RUnswizzle operation is introduced (i.e., the reference information of the page in the memory node buffer pool in the set data structure is cleared, and the page identifier is written back to update the position of the page) to handle the eviction of the memory node buffer pool. This occurs when there is only an UnSwizzled Swip in the page, that is, when the corresponding page in the memory node is no longer referenced by a child node, the corresponding page is evicted from the memory node buffer pool as a candidate, and the page recycling in the memory node is completed.
[0090] In the embodiment of the present invention, page A1 corresponds to a Swip data structure. When page B1 can be found through the Swip data structure, pages A1 and B1 form a parent-child relationship, where A1 is the parent page and B1 is the child page.
[0091] Page recycling requires a strategy to guide the selection of pages that need to be evicted. In the embodiment of the present invention, the page eviction scheme using pointer conversion is different from the traditional buffer pool design in the replacement strategy, so an extended page replacement strategy is provided, and corresponding adjustments are made in combination with the separated memory architecture. First, the eviction of pages is hierarchical and progressive. In the computing node, the state of the page is converted from the Hot state to the Warm state through the LUnswizzle operation; after the page is evicted to the memory node, it is converted from the Warm state to the Normal state; in the memory node, the state of the page is converted from the Normal state to the Cool state through the RUnswizzle operation; when the page is written from the memory buffer pool to the disk, the complete page recycling (i.e. eviction) process is completed. When entering the intermediate state Warm state, the associated pages will be placed in Figure 3 The warm state queue is shown as a candidate for eviction from the compute node buffer pool; when entering the intermediate state Cool state, the associated pages will be placed Figure 4 The cool state queue is shown as an eviction candidate for the computing node buffer pool. When a page application hits again later, these two states can directly enter the Hot state to avoid unnecessary IO overhead (between computing nodes and memory nodes, memory nodes and persistent storage devices). Finally, the candidate selection algorithm for the Warm state and the Cool state can continue to use the random selection algorithm that performs well in the pointer conversion technology to avoid the additional overhead caused by the need to maintain page statistics. It should be noted that the sub-Swip structure (Swip data contained in the current page) of the Swizzled state (including LSwizzled and RSwizzled states) cannot exist in the pages of the FIFO queue. Specifically, there cannot be a Swip with the flag bit RSwizzled in the page that is about to perform the LUnswizzle operation; there cannot be a Swip with the flag bit RSwizzled in the page that is about to perform the RUnswizzle operation. This constraint is guaranteed by implementing a callback function for each page to check whether there is a Swip with the flag bit LSwizzled / RSwizzled in the current page and return it. When the random selection algorithm selects a page that does not meet the above constraints, it continues to select candidates from the pages pointed to by the Swip contained in the filtered current page.
[0092] The extended Unswizzle mechanism provided by the embodiment of the present invention enables the system to better handle page eviction issues in computing nodes and memory nodes without affecting performance, while maintaining data consistency and efficient access.
[0093] 2. Example explanation.
[0094] In this example, an optimization of RUnswizzle operation in specific cases during page replacement is introduced. When page A and its child page B are only cached on the memory node, and there is no LSwizzled Swip in page B, page B can be selected as an eviction candidate and converted to the Cold state. In this case, since the Swip in page A still references page B (that is, there is a Swip in the data of page A, which records information related to page B), according to the conventional practice, page A needs to be loaded to the compute node for modification and then written back to the memory node. In addition, when RUnswizzle selects candidates, it needs to use the callback function to determine whether there is a RSwizzled Swip reference in the page in the Normal state, and the pages in the Normal state are all located on the memory node. According to the conventional practice, these pages need to be loaded into the memory node before the callback function is called. Although the above implementation method is relatively simple, it introduces additional memory usage and additional network traffic of the compute node, affecting the overall efficiency of the system.
[0095] To solve this problem, the present invention introduces an Offload mechanism, which allows some computing operations to be performed on the memory node, reducing network overhead. The modification operation of page A is delegated to a small number of CPUs in the memory node. This operation is completed through a remote procedure call (RPC) on a high-speed network (e.g., RDMA), ensuring the efficiency of the operation and data consistency. In this way, the system effectively reduces the memory usage and network overhead of the computing node, while maintaining efficient management of the buffer pool in the separated memory architecture.
[0096] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above embodiments can be implemented by software, or by means of software plus necessary general hardware platforms. Based on such understanding, the technical solutions of the above embodiments can be embodied in the form of software products, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0097] Embodiment 2
[0098] The present invention also provides a multi-layer buffer management system based on a separated memory, which is implemented based on the method provided in the above embodiment, and the system mainly comprises: a buffer management module under a separated memory architecture; the buffer management module under the separated memory architecture is implemented by independent buffer pools respectively allocated to computing nodes and memory nodes;
[0099] Among them, the buffer management module: uses pointer conversion technology to record the location of pages in combination with a set data structure; manages page state changes through a state machine to achieve page state flow and update the information in the set data structure; allocates pages in computing nodes and memory nodes in combination with the location of pages recorded in the set data structure; and recycles pages in computing nodes and memory nodes according to the page status and state changes.
[0100] Considering that the specific implementation details involved in the system have been introduced in detail in the previous embodiments, they will not be repeated here.
[0101] Technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the system can be divided into different functional modules to complete all or part of the functions described above.
[0102] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A multi-layer buffer management method based on separate memory, characterized in that: include: Independent buffer pools are allocated in computing nodes and memory nodes respectively, and the buffer management module under the separated memory architecture is implemented collaboratively; The buffer management module: records the location of the page by using pointer conversion technology in combination with a set data structure; manages the state change of the page by a state machine, realizes the state flow of the page and updates the information in the set data structure; allocates pages in computing nodes and memory nodes in combination with the location of the page recorded in the set data structure; reclaims pages in computing nodes and memory nodes according to the state of the page and the state change; The method of recording the location of a page by using a pointer conversion technology in combination with a set data structure includes: using a virtual memory address to replace a page identifier inside a buffer data structure by using a pointer conversion technology; the set data structure includes three parts of information: a first part of information is a flag bit, which is used to indicate the location of the page; a second part of information is a remote information storage bit, which is used to store an index of a remote memory address information array of the page, and the remote memory address information array contains relevant information of a memory node buffer pool page; a third part is a local information storage bit, which is used to store a local memory address of the page, and the local memory address is a memory address of a computing node buffer pool, and the third part of information can reflect the reference information of the page in the computing node buffer pool; The page allocation in the computing node and the memory node according to the location of the page recorded in the set data structure includes: if the page exists in the buffer pool of the computing node and the memory node and the persistent storage device, the existing page is directly used to complete the page allocation; if the page is only in the buffer pool of the memory node and the persistent storage device, the page address of the buffer pool of the memory node is obtained through address conversion, and an available free page is allocated in the buffer pool of the computing node, and the page is copied from the page address of the buffer pool of the memory node to the available free page in the buffer pool of the computing node to complete the page allocation; if the page only exists in the persistent storage device, the page is retrieved from the persistent storage device according to the mapping of the page identifier to the persistent storage device address, and then it is synchronized to the buffer pool of the memory node and the computing node to complete the page allocation.
2. A multi-layer buffer management method based on separate memory according to claim 1, characterized in that: The state machine includes: basic states and intermediate states; the basic states include: Hot state, Normal state and Cold state, and the intermediate states include: Warm state and Cool state; the above states are all states of the pages managed by the state machine; Among them, the Hot state indicates that the page exists in the buffer pool of both the computing node and the memory node; the Normal state indicates that the page exists only in the buffer pool of the memory node; the Cold state indicates that the page is only stored in the persistent storage device; the Warm state indicates the process of the page being evicted from the computing node to the memory node; and the Cool state indicates the process of the page being evicted from the memory node to the persistent storage device.
3. A multi-layer buffer management method based on separate memory according to claim 2, characterized in that: The implementing the state transfer of the page and updating the information in the set data structure includes: transferring to the Hot state and updating the information in the set data structure; wherein: When a page allocation request is received from the application layer, the page state of the corresponding page is converted to the Hot state. The related operation is called LSwizzle operation, which includes: loading the page into the buffer pool of the computing node and the memory node, retaining the reference information of the page in the buffer pool of the computing node and the memory node in the set data structure, and updating the position of the corresponding page in the set data structure; When a page is converted from the Normal state or the Cold state to the Hot state, the page is allocated in the buffer pool of the computing node and the memory node according to the page allocation requirements, and then the position of the corresponding page in the set data structure is updated; When a page is converted from the Warm state to the Hot state, based on the set data structure, the page reference information of the memory node buffer pool is determined, the corresponding page is located in the FIFO queue responsible for evicting the memory node buffer pool page, the page in the memory node buffer pool is reused, and is removed from the FIFO queue responsible for evicting the memory node buffer pool page, and the computing node address in the set data structure is updated; wherein the FIFO queue is a first-in-first-out queue; When a page is converted from the Cool state to the Hot state, the page identifier is determined based on the set data structure, and based on the page identifier, the corresponding page is found in the FIFO queue responsible for evicting the memory node buffer pool page; then, according to the page allocation logic, the page is retrieved from the memory node buffer pool to the computing node buffer pool, and then the page is removed from the FIFO queue, and the addresses of the computing nodes and the memory nodes and the location of the page in the set data structure are updated.
4. The multi-layer buffer management method based on separate memory according to claim 2, characterized in that: The implementing the state transfer of the page and updating the information in the set data structure includes: transferring from the Hot state to the Cold state and updating the information in the set data structure; wherein: The Hot state flows to the Warm state: when the buffer pool resources of the computing node are less than the threshold, the candidate pages for eviction are selected according to the page recycling algorithm, and are placed in the FIFO queue responsible for evicting the pages of the computing node buffer pool; then, the reference information of the pages in the computing node buffer pool in the set data structure is cleared, and the position of the pages is updated; at this time, the state of the page is changed to the Warm state; wherein the FIFO queue is a first-in-first-out queue; The Warm state transitions to the Normal state: When the page is in the Warm state and the corresponding compute node buffer pool page is evicted to the memory node buffer pool, the corresponding candidate page in the FIFO queue responsible for evicting the compute node buffer pool page is cleared; at this point, the state transition is completed and the page state changes to the Normal state; The Normal state flows to the Cool state: in the Normal state, the candidate page for eviction in the memory node buffer pool is selected according to the page recycling algorithm, and is placed in the FIFO queue responsible for evicting the page from the memory node buffer pool; then, the reference information of the page in the memory node buffer pool in the set data structure is cleared, and the page identifier is written back to update the position of the page; at this time, the state of the page is changed to the Cool state; Cool state transfers to Cold state: When a page is in the Cool state and needs to be evicted from the memory node buffer pool, the recycled page is selected, written back to the persistent storage device, and the corresponding candidate page in the FIFO queue responsible for evicting the memory node buffer pool page is cleared. Finally, the state of the page changes to the Cold state.
5. A multi-layer buffer management method based on separate memory according to claim 3 or 4, characterized in that: Also includes: During the state transfer process, when a page is retrieved from the buffer pool of the memory node or the persistent storage device, if a request for the same page is received, no additional IO operation is performed; When it is necessary to obtain the corresponding page from the persistent storage device, it is determined whether the current IO operation is completed according to the ongoing IO table located in the computing node; when it is necessary to obtain the corresponding page from the buffer pool of the memory node, the remote storage address of the page is obtained according to the set data structure, the status in the remote storage address is queried, and it is determined whether the corresponding page is in an ongoing IO operation; wherein IO means input and output.
6. The multi-layer buffer management method based on separate memory according to claim 1, characterized in that: Reclaiming pages in computing nodes and memory nodes based on page status and status changes includes: For pages in the Hot state, a LUnswizzle operation is introduced to process the eviction of the computing node buffer pool, and the page recycling in the computing node is completed; the LUnswizzle operation includes: clearing the reference of the page in the computing node buffer pool in the set data structure, and updating the position of the page; For pages in the Normal state, a RUnswizzle operation is introduced to process the eviction of the memory node buffer pool, and the page recycling in the memory node is completed; the RUnswizzle operation includes: clearing the reference information of the page in the memory node buffer pool in the set data structure, writing back the page identifier, and updating the position of the page; The Hot state indicates that the page exists in the buffer pool of both the compute node and the memory node; the Normal state indicates that the page exists only in the buffer pool of the memory node.
7. A multi-layer buffer management method based on separate memory according to claim 6, characterized in that: Also includes: In the computing node, the page state is converted from the Hot state to the Warm state through the LUnswizzle operation; After the page is evicted to the memory node, it is converted from the Warm state to the Normal state. In the memory node, the page state is converted from the Normal state to the Cool state through the RUnswizzle operation. When the page is written from the memory buffer pool to the disk, the complete page eviction process is completed. The Warm state indicates the process of evicting pages from compute nodes to memory nodes.
8. A multi-layer buffer management system based on separate memory, characterized in that: Based on the method of any one of claims 1 to 7, the system comprises: a buffer management module under a separate memory architecture; the buffer management module under the separate memory architecture is implemented by independently allocated buffer pools in computing nodes and memory nodes respectively; Among them, the buffer management module: uses pointer conversion technology to record the location of pages in combination with a set data structure; manages page state changes through a state machine to achieve page state flow and update the information in the set data structure; allocates pages in computing nodes and memory nodes in combination with the location of pages recorded in the set data structure; and recycles pages in computing nodes and memory nodes according to the page status and state changes.
Citation Information
Patent Citations
Key-Value local storage method and system based on solid state disk (SSD)
CN102722449A
Key-Value storage engine implementation method and system
CN114416742A