Persistent memory key-value system and operation method thereof

By adopting a two-stage insertion submission and lock-free query mechanism in the persistent memory key-value system, the concurrent control and performance problems of the persistent memory key-value system under the multi-core architecture are solved, and efficient persistence and scalability are achieved.

CN113485946BActive Publication Date: 2024-12-03ZTE CORP +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011218384.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-04
Publication Date
2024-12-03
Estimated Expiration
2040-11-04

AI Technical Summary

Technical Problem

The existing persistent memory key-value system is not designed for multi-core architecture, resulting in difficulty in concurrency control, frequent triggering of cache coherence protocols, low write bandwidth, and read and write locks embedded in data structures lead to cache jitter and persistence delay, affecting CPU performance.

Method used

By introducing two-stage insertion and submission process in the persistent memory key-value system, the first stage is to clear the persistent flag bit and flush it to persistent memory. The second stage is to set the flag bit to notify the successful persistence, avoiding the write-lock resource operation A persistent memory write is introduced, and lock-free query and a time-cycle-based memory recovery mechanism are adopted.

Benefits of technology

Improves the performance of insertion operation, reduces persistent memory write operations, improves the scalability and query performance under the multi-core architecture, avoids log operations, and optimizes the system's concurrent control and persistence delay.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113485946B_ABST
    Figure CN113485946B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a persistent memory key-value system and an operation method thereof, the operation method comprising: searching for an index of the persistent memory key-value system to locate key-value pair metadata to be inserted; obtaining a write lock resource corresponding to the key-value pair metadata in a dynamic random access memory; allocating persistent memory for the key-value pair metadata and persisting the key-value pair metadata; atomically inserting the key-value pair metadata into the persistent memory key-value system. Through the present invention, during the key-value pair insertion operation, the operation of the write lock resource will not introduce any write to the persistent memory, and no log operation is required, thereby improving the insertion operation performance and the scalability under the multi-core architecture.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of persistent memory storage technology, and in particular, to a persistent memory key-value system and an operating method thereof. Background Art

[0002] Persistent Memory has similar performance to Dynamic Random Access Memory (DRAM) and supports byte-granular addressing; at the same time, like disks, persistent memory can store data persistently. For example, existing persistent memory products have sub-microsecond latency and a single-bar capacity of up to 512GB, which brings many opportunities for new memory storage systems. Existing persistent memory supports two modes: application direct access mode and memory mode. Application direct access mode abstracts persistent memory into a special storage device that can be directly read and written through load and store instructions. In memory mode, DRAM acts as a cache for persistent memory, providing applications with an abstraction of a large-capacity memory, but without storage capabilities.

[0003] Most modern servers are multi-core architectures, that is, a processor contains dozens or even hundreds of CPU cores to improve the concurrent performance of the entire system. However, the multi-core architecture brings about the problem of concurrency control, that is, how threads on different CPU cores can efficiently and correctly access data concurrently.

[0004] Existing persistent memory key-value systems are not designed for multi-core architectures, which leads to many problems. First, the concurrency primitives that ensure the correct execution of multiple threads (such as read-write locks) cause data to jitter back and forth between the caches of different CPU cores, frequently triggering inefficient cache consistency protocols, seriously affecting CPU performance. Second, the write bandwidth of persistent memory is very low, with a single write bandwidth of only about 2.3GB / s, which is about 1 / 6 of DRAM. The various consistency mechanisms (such as logs) used by the key-value system to ensure crash consistency will consume additional persistent memory write bandwidth; at the same time, read-write locks are usually embedded in the data structure, and the cache jitter they bring will also cause a large amount of persistent memory to be written back. Finally, due to the high read latency and persistence latency of persistent memory, the critical section time is prolonged, resulting in serious blocking of conflicting operations between different threads. Summary of the invention

[0005] An embodiment of the present invention provides a persistent memory key-value system and an operating method thereof, so as to at least solve the problem in the related art that the existing persistent memory key-value system is not designed for a multi-core architecture, resulting in low operating performance.

[0006] According to one embodiment of the present invention, a method for operating a persistent memory key-value system is provided, the method comprising: searching an index of the persistent memory key-value system to locate key-value pair metadata to be inserted; acquiring a write lock resource corresponding to the key-value pair metadata in a dynamic random access memory; allocating persistent memory for the key-value pair metadata, and persisting the key-value pair metadata; atomically inserting the key-value pair metadata into the persistent memory key-value system, wherein the submission process of the key-value pair metadata insertion comprises two stages, in the first stage, clearing the persistence flag in the key-value pair metadata, and calling a CPU persistence instruction to flush it from the CPU cache to the persistent memory; in the second stage, setting the persistence flag, and notifying the read operation that the key-value pair metadata has been successfully persisted.

[0007] In an exemplary embodiment, before obtaining the write lock resource corresponding to the key-value pair metadata in the dynamic random access memory, it also includes: separating the write lock resource from the index of the persistent memory key-value system and maintaining the write lock resource in the dynamic random access memory.

[0008] In an exemplary embodiment, the write lock resource is maintained in the dynamic random access memory in a table structure, wherein the input of the table structure is a node address of an index, and the output of the table structure is the corresponding write lock resource.

[0009] In an exemplary embodiment, before atomically inserting the key-value pair metadata into the persistent memory key-value system, the method further includes: storing the key-value pair metadata in an atomically modifiable format.

[0010] In an exemplary embodiment, the atomically modifiable format means that the key-value pair metadata is packaged into a continuous persistent memory space and supports being atomically modified by a CPU.

[0011] In an exemplary embodiment, when a conflicting first insert operation and a second insert operation occur simultaneously, the first insert operation is not allocated or written to a persistent memory, and the first insert operation is returned.

[0012] In an exemplary embodiment, the key-value pair metadata includes at least one of the following: a key-value pair fingerprint, a key-value pair address, and a persistence flag; wherein the key-value pair fingerprint is several bits of the hash value of the key, the key-value pair address points to the key-value pair in the persistent memory, and the persistence flag indicates the persistence status of the key-value pair metadata.

[0013] In an exemplary embodiment, after atomically inserting the key-value pair metadata into the persistent memory key-value system, the method further includes: querying the key-value pair metadata in the persistent memory key-value system without locks.

[0014] In an exemplary embodiment, querying the key-value pair metadata without lock includes: checking the persistence flag in the key-value pair metadata, and if the persistence flag is clear, calling the CPU persistence instruction to persist the target key-value pair metadata; calling the atomic instruction to set the persistence flag, and reading the key-value pair pointed to by the metadata.

[0015] In an exemplary embodiment, the method further includes: periodically reclaiming persistent memory garbage through a background thread based on a time period memory recycling method.

[0016] According to another embodiment of the present invention, a persistent memory key-value system is provided, which includes: a search module, used to search for an index of the persistent memory key-value system to locate key-value pair metadata to be inserted; an acquisition module, used to acquire a write lock resource corresponding to the key-value pair metadata in a dynamic random access memory; an allocation module, used to allocate persistent memory for the key-value pair metadata and persist the key-value pair metadata; an insertion module, used to atomically insert the key-value pair metadata into the persistent memory key-value system, wherein the submission process of the key-value pair metadata insertion includes two stages, in the first stage, the persistence flag in the key-value pair metadata is cleared, and the CPU persistence instruction is called to flush it from the CPU cache to the persistent memory; in the second stage, the persistence flag is set, and the read operation is notified that the key-value pair metadata has been successfully persisted.

[0017] In an exemplary embodiment, the system further includes: a maintenance module, configured to separate the write lock resource from an index of the persistent memory key-value system and maintain the write lock resource in the dynamic random access memory.

[0018] In an exemplary embodiment, the system further includes: a storage module, configured to store the key-value pair metadata in an atomically modifiable format.

[0019] In an exemplary embodiment, the system further includes: a query module for querying the key-value pair metadata in the persistent memory key-value system without locks.

[0020] In an exemplary embodiment, the system further includes: a recycling module, which is used to periodically recycle persistent memory garbage through a background thread in a memory recycling manner based on a time period.

[0021] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any one of the above method embodiments when run.

[0022] According to yet another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0023] Through the above-mentioned embodiments of the present invention, during the insertion operation of the key-value pair, the operation on the write lock resource will not introduce any write to the persistent memory, and no log operation is required, thereby improving the insertion operation performance and improving the scalability under the multi-core architecture. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 is a flowchart of an operating method of a persistent memory key-value system according to an embodiment of the present invention;

[0025] Figure 2 is a structural block diagram of a persistent memory key-value system according to an embodiment of the present invention;

[0026] Figure 3 is a structural block diagram of a persistent memory key-value system according to another embodiment of the present invention;

[0027] Figure 4 is a schematic diagram of a multi-core architecture-friendly persistent memory key-value system according to an embodiment of the present invention;

[0028] Figure 5 is a schematic diagram of the structure of key-value pair metadata according to an embodiment of the present invention;

[0029] Figure 6 is a flow chart of an insertion operation of a multi-core architecture-friendly persistent memory key-value system according to an embodiment of the present invention;

[0030] Figure 7 is a query operation flow chart of a multi-core architecture-friendly persistent memory key-value system according to an embodiment of the present invention;

[0031] Figure 8 4 is a schematic diagram of eliminating two concurrent conflicting insertion operations according to an embodiment of the present invention. DETAILED DESCRIPTION

[0032] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with the embodiments.

[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0034] Example 1

[0035] In this embodiment, a method for operating a persistent memory key-value system is provided. Figure 1 is a flow chart according to an embodiment of the present invention, such as Figure 1 As shown, the process includes the following steps:

[0036] Step S102, searching the index of the persistent memory key-value system to locate the key-value pair metadata to be inserted;

[0037] Step S104, obtaining a write lock resource corresponding to the key-value pair metadata in the dynamic random access memory;

[0038] Step S106, allocating persistent memory for the key-value pair metadata, and persisting the key-value pair metadata;

[0039] Step S108, atomically inserting the key-value pair metadata into the persistent memory key-value system, wherein the submission process of the key-value pair metadata insertion includes two stages. In the first stage, the persistence flag in the key-value pair metadata is cleared, and the CPU persistence instruction is called to flush it from the CPU cache to the persistent memory; in the second stage, the persistence flag is set, and the read operation is notified that the key-value pair metadata has been successfully persisted.

[0040] Before step S104 of this embodiment, the method may further include: separating the write lock resource from the index of the persistent memory key-value system, and maintaining the write lock resource in the dynamic random access memory.

[0041] In this embodiment, the write lock resource may be maintained in the dynamic random access memory in a table structure, wherein the input of the table structure is a node address of an index, and the output of the table structure is the corresponding write lock resource.

[0042] Before step S108 of this embodiment, the method may further include: storing the key-value pair metadata in a format that can be atomically modified.

[0043] In this embodiment, the atomically modifiable format means that the key-value pair metadata is packaged into a continuous persistent memory space and supports being atomically modified by the CPU.

[0044] In this embodiment, when the conflicting first insert operation and the second insert operation occur simultaneously, the persistent memory is not allocated and written for the first insert operation, and the first insert operation is returned.

[0045] In this embodiment, the key-value pair metadata includes at least one of the following: a key-value pair fingerprint, a key-value pair address, and a persistence flag; wherein the key-value pair fingerprint is several bits of the hash value of the key, the key-value pair address points to the key-value pair in the persistent memory, and the persistence flag indicates the persistence status of the key-value pair metadata.

[0046] After step S108 of this embodiment, the method may further include: querying the key-value pair metadata in the persistent memory key-value system without lock.

[0047] In this embodiment, querying the key-value pair metadata without lock may include: checking the persistence flag in the key-value pair metadata, and if the persistence flag is clear, calling the CPU persistence instruction to persist the target key-value pair metadata; calling the atomic instruction to set the persistence flag, and reading the key-value pair pointed to by the metadata.

[0048] In this embodiment, the method may further include: periodically reclaiming persistent memory garbage through a background thread based on a time period memory recycling method.

[0049] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0050] Example 2

[0051] In this embodiment, a persistent memory key-value system is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated here. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0052] Figure 2is a structural block diagram of a persistent memory key-value system according to an embodiment of the present invention, such as Figure 2 As shown, the system includes a search module 10 , an acquisition module 20 , an allocation module 30 and an insertion module 40 .

[0053] The search module 10 is used to search the index of the persistent memory key-value system to locate the key-value pair metadata to be inserted.

[0054] The acquisition module 20 is used to acquire the write lock resource corresponding to the key-value pair metadata in the dynamic random access memory.

[0055] The allocation module 30 is used to allocate persistent memory for the key-value pair metadata and persist the key-value pair metadata.

[0056] The insertion module 40 is used to atomically insert the key-value pair metadata into the persistent memory key-value system, wherein the submission process of the key-value pair metadata insertion includes two stages. In the first stage, the persistence flag in the key-value pair metadata is cleared, and the CPU persistence instruction is called to flush it from the CPU cache to the persistent memory; in the second stage, the persistence flag is set, and the read operation is notified that the key-value pair metadata has been successfully persisted.

[0057] Figure 3 is a structural block diagram of a persistent memory key-value system according to another embodiment of the present invention. Figure 3 As shown, the system includes Figure 2 In addition to all the modules shown, the system also includes a maintenance module 50 , a storage module 60 , a query module 70 and a recycling module 80 .

[0058] The maintenance module 50 is used to separate the write lock resource from the index of the persistent memory key-value system and maintain the write lock resource in the dynamic random access memory.

[0059] The storage module 60 is used to store the key-value pair metadata in a format that can be atomically modified.

[0060] The query module 70 is used to query the key-value pair metadata in the persistent memory key-value system without lock.

[0061] The recycling module 80 is used for recycling persistent memory garbage periodically through a background thread in a time-based memory recycling manner.

[0062] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0063] In order to facilitate the understanding of the technical solution provided by the present invention, the following will be described in detail with reference to embodiments of specific scenarios.

[0064] Example 3

[0065] Figure 4 Schematic diagram of a multi-core architecture-friendly persistent memory key-value system according to an embodiment of the present invention. Figure 4 As shown, the multi-core architecture-friendly persistent memory key-value system based on this embodiment can perform the following insertion and query operations:

[0066] S1, separates the write lock resource from the index of the persistent memory key-value system and maintains it separately in the dynamic random access memory;

[0067] S2, stores the key-value metadata in an atomically modifiable format, and uses the CPU's atomic instructions to atomically switch the system from one consistency state to another consistency state when an insert operation occurs (two-stage atomic insert);

[0068] S3, when two conflicting insert operations occur at the same time, one of the operations is allowed to return directly without allocating or writing any persistent memory (eliminating concurrent inserts);

[0069] S4, when a query operation occurs, the key-value data is read without lock.

[0070] In this embodiment, the write lock resource is used to control multiple concurrent insert operations.

[0071] Furthermore, in one embodiment of the present invention, write lock resources are maintained in a dynamic random access memory in a table structure, the table structure input is an indexed node address, and the output is a corresponding lock resource.

[0072] Specifically, for example, the table structure of the write lock resource is an array of 4096 64-bit lock fields; since the lock table only occupies 32KB of space, it can be cached in the high-speed CPU second-level cache and almost no TLB misses are introduced. It is worth noting that this table structure will introduce pseudo-conflicts, that is, different index nodes compete for the same lock field. However, since the real load is mostly query-intensive and the query operation is lock-free, the probability of pseudo-conflicts is extremely low.

[0073] It should be noted that the traditional persistent memory key-value system embeds the write lock into the persistent index, which will cause multiple problems: first, the lock operation will cause additional persistent memory writes, consuming the limited bandwidth of the persistent memory; second, when the key-value system crashes and restarts, it is necessary to scan the entire index and clear the contents of the lock field. The present invention maintains the lock resources in DRAM, reducing the persistent memory bandwidth consumption while improving the recovery performance.

[0074] Furthermore, in one embodiment of the present invention, the metadata of the key-value pair includes a key-value pair fingerprint, a key-value pair address, and a persistence flag, wherein the key-value pair fingerprint is several bits of the hash value of the key, the key-value pair address points to the key-value pair in the persistent memory, and the persistence flag indicates the persistence status of the key-value pair metadata.

[0075] Specifically, the key-value pair fingerprint is used to speed up the location of the key-value pair. When the fingerprint does not match, the query operation can directly skip the corresponding key-value pair metadata, avoiding an additional read of the key-value pair in the persistent memory. When the persistence flag is 0, it means that the key-value pair metadata is not persisted; otherwise, it means that it is successfully persisted. Key-value metadata is generally stored in an index, which includes a hash table, B+ tree, dictionary tree, etc.

[0076] Furthermore, in one embodiment of the present invention, the atomically modifiable format means that the key-value pair metadata is packaged into a continuous persistent memory space and supports being atomically modified by the CPU.

[0077] Specifically, Figure 5 FIG. 1 is a schematic diagram of the structure of key-value pair metadata according to an embodiment of the present invention. Figure 5 As shown in the figure, the key-value metadata is 64 bits, of which the highest 16 bits store the key-value fingerprint, the middle 47 bits store the key-value address, and the lowest 1 bit stores the persistence flag. The reasons why the highest 16 bits and the lowest bit can store additional information are: first, the virtual address space of Intel processors has only the lower 48 bits, and second, the persistent memory address allocated by the key-value system is 8-byte aligned (that is, the lowest 3 bits of the address are 0). The CPU can atomically operate on 64-bit key-value metadata.

[0078] Furthermore, in one embodiment of the present invention, the consistency state means that the metadata of the key-value system and the inserted key-value pairs can correspond one to one and are permanently stored in the persistent memory.

[0079] Furthermore, in one embodiment of the present invention, the submission process of the insert operation includes two stages, wherein the first stage clears the persistence flag in the key-value pair metadata and calls the CPU persistence instruction to flush it from the CPU cache to the persistent memory; in the second stage, the persistence flag is set to notify the read operation that the key-value pair metadata has been successfully persisted.

[0080] Figure 6 FIG. 1 is a flowchart of an insertion operation of a multi-core architecture-friendly persistent memory key-value system according to an embodiment of the present invention. Figure 6 The insertion operation may include the following steps:

[0081] Step S601, search the index and locate the key-value pair metadata;

[0082] Step S602, obtaining the corresponding lock resource in DRAM;

[0083] Step S603, allocating persistent memory and persisting the key-value pair;

[0084] Step S604: The submission process of inserting the key-value pair metadata includes two stages, wherein the first stage clears the persistence flag in the key-value pair metadata and calls the CPU persistence instruction to flush it from the CPU cache to the persistent memory;

[0085] Step S605: In the second stage of the submission of the insert operation, the persistence flag is set, and the read operation is notified that the key-value pair metadata has been successfully persisted.

[0086] like Figure 6 As shown in the figure, before the commit process, the insert operation successfully obtains the corresponding lock resources in DRAM, allocates persistent memory, and persists the inserted key-value pair. For example, on Intel CPUs, persistence instructions include CLFLUSH, CLWB, and CLFLUSHOPT. The assignment of key-value pair metadata in both stages of the commit is atomic; in the first stage, the value of the entire new key-value pair metadata is written and persisted. Relying on the atomic write provided by the CPU, the insert operation does not require mechanisms such as logs to protect consistency.

[0087] Furthermore, in one embodiment of the present invention, during the lock-free query process of the query operation, the persistence flag in the target key-value pair metadata is checked. If the persistence flag is cleared, the CPU persistence instruction is called to persist the key-value pair metadata, and then the atomic instruction is called to set the persistence flag.

[0088] Figure 7 FIG. 1 is a flow chart of a query operation of a multi-core architecture-friendly persistent memory key-value system according to an embodiment of the present invention. Figure 7 As shown, the query operation may include the following steps:

[0089] Step S701, search the index to locate the target key-value pair metadata;

[0090] Step S702, determining whether the persistence flag of the target key-value pair metadata is cleared, if yes, executing step S703, if no, executing step S705;

[0091] Step S703, calling the CPU persistence instruction to persist the target key-value pair metadata;

[0092] Step S704, calling the atomic instruction CAS (compare-and-swap) to set the persistence flag;

[0093] Step S705: read the target key-value pair pointed to by the metadata.

[0094] like Figure 7 As shown in the figure, during the query operation, when the persistence flag of the target key-value pair metadata is cleared, it means that the metadata has not been successfully persisted. In order to ensure that the query operation does not read uncommitted data, the query operation actively persists the metadata and calls the atomic instruction to set the persistence flag. This active persistence mechanism ensures that after the system crashes and restarts, there is no need to traverse all the key-value pair metadata to set the persistence flag.

[0095] Figure 8 FIG. 2 is a schematic diagram of eliminating two concurrent conflicting insertion operations according to an embodiment of the present invention. Figure 8 As shown, in this embodiment, when two concurrent conflicting insert operations occur, one of the operations returns directly without allocating or modifying any persistent memory. This mechanism of eliminating operations does not violate the correct concurrency semantics, because in the definition of linearizability, the execution results of two operations that overlap in time are equivalent to the execution results of a certain serial order.

[0096] Furthermore, in one embodiment of the present invention, in order to solve the lock-free reading problem of the query operation, an Epoch (time period)-based memory recycling method is used to periodically recycle memory garbage using a background thread.

[0097] Specifically, the key-value system maintains a global counter, and each thread maintains a local counter. At the beginning of each key-value operation, the local counter is updated to the global counter. When the persistent memory space needs to be released, the <value of the local counter, the released memory address> is recorded in the recycling list. At the same time, a background thread periodically adds 1 to the global counter, collects the local counter values ​​of all threads, and calculates the minimum value, which is recorded as Safe-Epoch; at this time, all memory in the recycling list that is less than Safe-Epoch can be safely released.

[0098] During the insertion operation of the above embodiment of the present invention, the operation of the write lock resource will not introduce any write to the persistent memory, and no log operation is required, which improves the performance of the insertion operation. In addition, when multiple concurrent conflicting insertion operations occur, the allocation and writing of the persistent memory are further reduced. For query operations, its lock-free process greatly improves the concurrent query performance of the key-value system in a multi-core architecture while ensuring correct semantics.

[0099] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0100] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0101] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0102] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0103] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0104] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0105] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method of operating a persistent memory key-value system, It is characterized in that include: Look up the index of the persistent memory key-value system to locate the key-value pair metadata to be inserted; Acquire a write lock resource corresponding to the key-value pair metadata in a dynamic random access memory; Allocating persistent memory for the key-value pair metadata and persisting the key-value pair metadata; Atomically inserting the key-value pair metadata into the persistent memory key-value system, wherein the submission process of the key-value pair metadata insertion includes two stages. In the first stage, the persistence flag in the key-value pair metadata is cleared, and the CPU persistence instruction is called to flush it from the CPU cache to the persistent memory; in the second stage, the persistence flag is set, and the read operation is notified that the key-value pair metadata has been successfully persisted.

2. The method according to claim 1, It is characterized in that Before acquiring the write lock resource corresponding to the key-value pair metadata in the dynamic random access memory, it also includes: The write lock resource is separated from the index of the persistent memory key-value system and maintained in the dynamic random access memory.

3. The method according to claim 2, It is characterized in that in, The write lock resource is maintained in the dynamic random access memory in a table structure, wherein the input of the table structure is a node address of an index, and the output of the table structure is the corresponding write lock resource.

4. The method according to claim 1, It is characterized in that Before atomically inserting the key-value pair metadata into the persistent memory key-value system, the method further includes: The key-value metadata is stored in an atomically modifiable format.

5. The method according to claim 4, It is characterized in that The atomically modifiable format means that the key-value pair metadata is packaged into a continuous persistent memory space and supports being atomically modified by the CPU.

6. The method according to claim 1, It is characterized in that Also includes: When the conflicting first insert operation and second insert operation occur simultaneously, the persistent memory is not allocated and written to the first insert operation, and the first insert operation is returned.

7. The method according to claim 1, It is characterized in that in, The key-value pair metadata includes at least one of the following: a key-value pair fingerprint, a key-value pair address, and a persistence flag; wherein the key-value pair fingerprint is several bits of the hash value of the key, the key-value pair address points to the key-value pair in the persistent memory, and the persistence flag indicates the persistence status of the key-value pair metadata.

8. The method according to claim 1, It is characterized in that After atomically inserting the key-value pair metadata into the persistent memory key-value system, the method further includes: The key-value pair metadata is queried in the persistent memory key-value system without locks.

9. The method according to claim 8, It is characterized in that in, Querying the key-value pair metadata without locks includes: Checking the persistence flag in the key-value pair metadata, and if the persistence flag is cleared, calling the CPU persistence instruction to persist the target key-value pair metadata; Call the atomic instruction to set the persistence flag and read the key-value pair pointed to by the metadata.

10. The method according to claim 1, It is characterized in that Also includes: A time-cycle-based memory recycling method that periodically recycles persistent memory garbage through background threads.

11. A persistent memory key-value system, It is characterized in that include: A search module, used to search the index of the persistent memory key-value system to locate the key-value pair metadata to be inserted; An acquisition module, used for acquiring a write lock resource corresponding to the key-value pair metadata in a dynamic random access memory; An allocation module, used for allocating persistent memory for the key-value pair metadata and persisting the key-value pair metadata; An insertion module is used to atomically insert the key-value pair metadata into the persistent memory key-value system, wherein the submission process of the key-value pair metadata insertion includes two stages, wherein, in the first stage, the persistence flag in the key-value pair metadata is cleared, and the CPU persistence instruction is called to flush it from the CPU cache to the persistent memory; in the second stage, the persistence flag is set, and the read operation is notified that the key-value pair metadata has been successfully persisted.

12. The system according to claim 11, It is characterized in that Also includes; A maintenance module is used to separate the write lock resource from the index of the persistent memory key-value system and maintain the write lock resource in the dynamic random access memory.

13. The system according to claim 11, further comprising: include: The storage module is used to store the key-value pair metadata in a format that can be atomically modified.

14. The system according to claim 11, It is characterized in that Also includes: A query module is used to query the key-value pair metadata in the persistent memory key-value system without lock.

15. The system according to claim 11, It is characterized in that Also includes: The recycling module is used for memory recycling based on time periods, and periodically recycles persistent memory garbage through background threads.

16. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 10 when executed by a processor.

17. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the steps of the method described in any one of claims 1 to 10 are implemented.