CN115329141A - Data management method for persistent memory and persistent memory controller - Google Patents

Data management method for persistent memory and persistent memory controller Download PDF

Info

Publication number
CN115329141A
CN115329141A CN202210883333.8A CN202210883333A CN115329141A CN 115329141 A CN115329141 A CN 115329141A CN 202210883333 A CN202210883333 A CN 202210883333A CN 115329141 A CN115329141 A CN 115329141A
Authority
CN
China
Prior art keywords
pointer
hash table
layer
hash
dynamic multi
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210883333.8A
Other languages
Chinese (zh)
Inventor
华宇
陈章玉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huazhong University of Science and Technology
Original Assignee
Huazhong University of Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huazhong University of Science and Technology filed Critical Huazhong University of Science and Technology
Priority to CN202210883333.8A priority Critical patent/CN115329141A/en
Publication of CN115329141A publication Critical patent/CN115329141A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9014Indexing; Data structures therefor; Storage structures hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Storage Device Security (AREA)

Abstract

The invention discloses a data management method facing a persistent memory and a persistent memory controller, belonging to the field of data storage and comprising the following steps: respectively constructing a dynamic multi-layer hash table and an announcement array in a persistent memory and a volatile memory; after the element is stored to persistent memory, its pointer p is in the array of advertisements n Finding a matched hash bucket H, if a pointer p exists in the H o Then p will be o Inserting dynamic multi-layer hash table, and replacing element pointer in H with p atomically n A 1 is to p n Inserting a dynamic multi-layer hash table and then emptying H; if H is empty, p is n Inserting a dynamic multi-layer hash table and then emptying H; the pointer insertion method comprises the following steps: when the element pointer which is the same as the key corresponding to the element pointer to be inserted does not exist in the dynamic multi-layer hash table, traversing the visible layer from top to bottom, searching the matched alternative bucket, and atomically inserting the pointer into the idle slot position of the matched alternative bucket. The invention can realize the Hash table access with high throughput and low delay and the strong consistency guarantee which can be linearized.

Description

Data management method for persistent memory and persistent memory controller
Technical Field
The invention belongs to the field of data storage, and particularly relates to a data management method facing a persistent memory and a persistent memory controller.
Background
The novel persistent memory technology has the byte access performance close to a volatile memory and the persistence of a disk, the single capacity of the existing Itanium persistent memory issued by Intel reaches 512GB, and the high-performance storage service is expected to be provided for mass data. However, the Asynchronous memory Refresh (ADR) mechanism of persistent memory, which is widely used at present, only guarantees the persistence of the write queue in the memory controller, and the data of the CPU cache line and the volatile memory are still volatile due to power failure, so the persistent memory application program needs to guarantee that the program can be restored to a consistent state after being restarted, which is called crash consistency. In addition, persistent memory has read-write asymmetry, e.g., the write bandwidth of the futon persistent memory is only one third of the read bandwidth.
The index structure is one of the key technologies of the storage system. Unlike tree-based indexes, hash indexes can directly locate alternative positions of data through a hash function, and related operations have time complexity of a constant level, so that the hash indexes are widely applied to storage systems. The existing server platform is often multi-core, for example, one to strong CPU supporting the heaven persistent memory generally has dozens of threads, and abundant hardware parallel resources can support the performance of a concurrent storage system. Therefore, establishing a proper hash index structure is of great significance to data management in the persistent memory.
The existing hash table construction method and system under the persistent memory mainly pay attention to write optimization and crash consistency, and have limitations in terms of high concurrency and correctness guarantee: on one hand, many existing construction schemes perform concurrency control through a lock, however, the lock limits concurrency expandability of the hash table under a high concurrency scene, resulting in high access delay, wherein the hash table capacity expansion operation based on the coarse-grained lock severely blocks other concurrency threads, resulting in low throughput rate; on the other hand, the existing lock-free hash table construction scheme aiming at the persistent memory lacks a correctness guarantee mechanism, and a persistent memory index meeting strong consistency needs to ensure that the finished operation still exists and the data is consistent after crash restart, namely linearization can be realized under the persistent memory; in addition, in the aspect of persistent memory management, a general allocator scheme is adopted in the existing hash table construction scheme, and high persistent memory management overhead in a concurrent environment is caused by verification technologies such as a log before writing and the like adopted to guarantee crash consistency.
Disclosure of Invention
Aiming at the defects and improvement requirements of the prior art, the invention provides a data management method facing a persistent memory and a persistent memory controller, and aims to realize high-throughput low-delay Hash table access and strong consistency guarantee capable of being linearized.
To achieve the above object, according to an aspect of the present invention, there is provided a persistent memory-oriented data management method, where data is a key-value pair element, the method including:
an initialization step: constructing a dynamic multi-layer hash table in a persistent memory, wherein the dynamic multi-layer hash table comprises a plurality of hash buckets for storing the pointers of the elements with the specified number, each pointer comprises X alternative buckets in each layer of hash table, the number of the hash buckets in the hash table with higher layers is more, and the accessible hash table is a visible layer; constructing a notice array in a volatile memory, wherein array elements are hash buckets; x is a positive integer;
a pointer insertion step: judging whether an element pointer which is the same as a key corresponding to the element pointer to be inserted exists in the dynamic multi-layer hash table or not, and if so, exiting the pointer insertion step; otherwise, traversing all visible layers from top to bottom, searching a matched alternative bucket for the element pointer to be inserted, and if an idle slot position exists in the matched alternative bucket, atomically inserting the pointer into the matched alternative bucket; if no spare slot position exists in the matched alternative barrel, distributing a new top-layer hash table for the dynamic multi-layer hash table, and then re-executing the pointer insertion step;
a synchronization step: after storing an element to be stored to persistent memory, a pointer p to the element in the advertisement array n Searching the hash bucket, if the matched hash bucket H has an old element pointer p o Then the pointer p is inserted by a pointer insertion step o After inserting the dynamic multi-layered hash table, the element pointer in hash bucket H is atomically replaced with pointer p n The pointer p is inserted by a pointer insertion step n Inserting a dynamic multi-layer hash table, and then emptying a hash bucket H; if hash bucket H is empty, pointer p is inserted by a pointer insertion step n The dynamic multi-layered hash table is inserted, followed by emptying hash bucket H.
The invention establishes a multi-layer hash table structure capable of being dynamically expanded to index the element pointers, can realize the management of the element pointers in a lock-free mode and realizes high concurrency; meanwhile, coordinated concurrent insertion operation is realized through the announcement array, specifically, before the element pointer is inserted into the dynamic multi-layer hash table, the element pointer is firstly tried to be inserted into the announcement array, if the old element pointer already exists in the matched hash bucket, the element pointer is firstly inserted into the dynamic multi-layer hash table, then the new element pointer is inserted into the announcement array through atom replacement operation, and then the new pointer is inserted, so that the operations can be executed according to strict sequence, linearization under a persistent memory is realized, and strong consistency is ensured. In general, the invention realizes high concurrency of the persistent memory and realizes linearization under the persistent memory.
Further, the data management method facing the persistent memory provided by the present invention further includes:
and a pointer migration step: traversing all visible layers except the bottom layer from top to bottom, searching a matched alternative bucket for the element pointer to be migrated, and if an idle slot position exists in the matched alternative bucket, atomically inserting the pointer into the matched alternative bucket; if no idle slot position exists in the matched alternative barrel, distributing a new top-layer hash table for the dynamic multi-layer hash table, and then re-executing the pointer migration step;
a re-hashing step performed in the background: when the number of the visible layers exceeds two, all element pointers in the bottom hash table are migrated to other visible layers through a pointer migration step, and after migration is completed, the storage space occupied by the bottom hash table is released;
in the pointer insertion step, if the number of layers of the visible layer is greater than 2, the bottom layer is not traversed when the alternative bucket matched with the element pointer to be inserted is searched; if the number of layers of the visible layer is 2 before the element pointer is inserted, and a new visible layer appears after the element pointer is inserted, the pointer insertion step is executed again.
The invention can effectively control the layer number of the dynamic multi-layer hash table through the re-hash operation executed by the background, thereby ensuring the query efficiency.
In the pointer insertion operation, when the number of layers of the visible layer is more than 2, the pointer is not allowed to be inserted into the bottom layer, so that the situation that the pointer is inserted into the bottom layer and then migrates due to the heavy hash operation, and finally insertion failure is caused can be effectively avoided; when the number of visible layers is 2, the pointer is likely to be inserted into the bottom layer, the number of visible layers is 2 before the element pointer is inserted, and a new visible layer appears after the element pointer is inserted, so that the inserted element pointer is likely to migrate due to the heavy hash operation after the element pointer is inserted into the bottom layer, thereby causing insertion failure.
Further, the initialization step further includes: and establishing a ring buffer area in the persistent memory, wherein the ring buffer area is used for storing the first addresses of the hash tables of all layers in a sequence from low to high in the hierarchy.
The invention manages each layer of hash table in the dynamic multilayer hash table by using the ring buffer, and can effectively reduce the time and space overhead of management compared with the existing lock-free hash table construction scheme that each layer of hash table is managed by a linked list.
Further, the persistent memory-oriented data management method provided by the present invention further includes: a pre-allocation step performed in the background;
the initialization step further comprises: pre-allocating M layers of hash tables as inaccessible layers for the dynamic multi-layer hash tables, and sequentially storing the first addresses of the layers of hash tables into a ring buffer area;
in the pointer inserting step, a new hash table is added to the dynamic multi-layer hash table as a top-layer hash table in a mode of distributing the pre-distributed hash table with the lowest level to the dynamic multi-layer hash table as a visible layer;
the pre-distribution step comprises the following steps: when the number of the pre-allocated inaccessible hash tables is less than M, pre-allocating the hash tables as the inaccessible hash tables for the dynamic multi-layer hash tables, and sequentially storing the first addresses of the hash tables of each layer into a ring buffer area to enable the number of the pre-allocated inaccessible hash tables to be M;
wherein M is a positive integer.
According to the dynamic multi-layer hash table expansion method, part of storage space is pre-allocated to the dynamic multi-layer hash table, when the dynamic multi-layer hash table needs to be expanded, the expansion can be completed by directly setting the pre-allocated layers as the visible layers, the rapid expansion of the dynamic multi-layer hash table can be realized, and the execution efficiency of pointer insertion operation is ensured.
Further, the persistent memory-oriented data management method provided by the present invention further maintains hierarchical metadata < Lt, lb > in the volatile memory, where Lt and Lb are used to store numbers of the top hash table and the bottom hash table in the ring buffer respectively; the hash table with the serial number within the range of [ Lt, lb ] is an accessible hash table in the dynamic multi-layer hash table;
in the pointer inserting step, a new hash table is added to the dynamic multi-layer hash table to serve as a top-layer hash table, and meanwhile, the value of the hierarchy metadata < Lt, lb > is atomically updated; in the re-hashing step, the value of the hierarchical metadata < Lt, lb > is atomically updated while the storage space occupied by the underlying hash table is released.
In a traditional lock-free hash table construction scheme, a top-level pointer, a bottom-level pointer and a mark for capacity expansion are maintained as metadata, the metadata exceeds 8 bytes, and cannot be updated by atomic operation; in the invention, only the numbers Lt and Lb for storing the top hash table and the bottom hash table in the annular buffer zone are required to be maintained as the hierarchical metadata, the hierarchical metadata do not exceed 8 bytes, and the hierarchical metadata can be updated through atomic operation.
Further, the data management method facing the persistent memory provided by the present invention further includes:
an element insertion step: atomically allocating a frame with a proper size to an element to be inserted, so that after the element is stored in one block or a plurality of continuous blocks in the frame, the difference between the size of the allocated storage space and the size of the storage space required by the element is minimum; inserting the elements to be inserted into the allocated frames in sequence;
the frame is a continuous space in a persistent memory, and each frame comprises a plurality of blocks with fixed sizes; different kinds of frames, block sizes are different.
The invention manages the elements inserted into the persistent memory by using the frames with different block granularities, and can effectively improve the space utilization rate of the persistent memory.
Further, dynamically storing a hash table and frames in a persistent memory, dynamically allocating space without logs, wherein the dynamically storing hash table allocates storage space atomically according to the sequence of addresses from high to low, and the frames allocate storage space atomically according to the sequence of addresses from low to high;
or, the dynamic storage hash table allocates the storage space atomically according to the sequence of addresses from low to high, and the frame allocates the storage space atomically according to the sequence of addresses from high to low.
In the invention, the dynamic multi-layer hash table and the frame have different required storage spaces, and the dynamic multi-layer hash table and the frame are respectively arranged at the high address end and the low address end of the persistent memory for centralized storage, so that space fragments can be reduced, and the space utilization rate is improved.
Further, the persistent memory-oriented data management method provided by the present invention further includes:
an updating step: after inserting the new element into the persistent memory, the element pointer p is obtained 1 (ii) a Traversing the accessible layers in the dynamic multi-layer hash table from bottom to top, searching all matched element pointers, and only keeping the last matched pointer p 2 And delete the remaining matched pointers, using pointer p 1 Atomically replacing the pointer p 2 (ii) a If before and after the updating step is executed, the access can be made in the dynamic multi-layer Hash tableIf the number of the layers is changed, the updating step is executed again;
and (3) deleting: traversing accessible layers in the dynamic multi-layer hash table from bottom to top, deleting all matched pointers one by one atomically, and releasing corresponding elements; if the accessible layer number in the dynamic multi-layer hash table changes before and after the deletion step is executed, the deletion step is executed again;
and (3) query step: and traversing all accessible layers in the dynamic multi-layer hash table from bottom to top until the first matched element pointer is found, and returning the element to be found according to the pointer.
According to the invention, when the accessible layer number in the dynamic multi-layer hash table is changed before and after the updating step is executed, the updating step is executed again, so that the updating failure caused by the repeated hash operation after a new pointer is inserted into the bottom layer can be avoided; according to the invention, when the accessible layer number in the dynamic multi-layer hash table is changed before and after the deletion step is executed, the deletion step can be executed again, and the situation that the pointer matched with the bottom layer is not deleted because the pointer is migrated to a new visible layer can be avoided.
Further, a persistence flag bit is set in the element pointer to indicate whether to be persisted;
and, the pointer inserting step further comprises: before insertion, setting a persistence flag bit of the cache line for indicating that the cache line is not persisted, inserting a pointer into a dynamic multi-layer hash table, then refreshing a corresponding cache line, and then atomically setting the persistence flag bit for indicating that the cache line is persisted;
when any thread reads a pointer whose persistence flag bit indicates that it is not persisted, the corresponding cache line is flushed and the persistence flag bit is set atomically to indicate that it has been persisted.
The invention realizes the cooperative persistence by setting the persistence flag bit in the element pointer, particularly, the persistence flag of the element pointer is set to be 'persisted' only after the element pointer is successfully inserted into the dynamic multi-layer hash table, any thread reads the pointer which is not persisted, the corresponding cache line is refreshed firstly, the persistence flag bit is set to be 'persisted' atomically, the persistent storage of the pointer is effectively ensured, and the consistency of the persistent memory is ensured.
According to another aspect of the present invention, there is provided a persistent memory controller, comprising: a processor and a computer-readable storage medium;
a computer program is stored in a computer readable storage medium; the processor is used for reading the computer program and executing the data management method facing the persistent memory provided by the invention.
Generally, by the above technical solution conceived by the present invention, the following beneficial effects can be obtained:
(1) The invention designs the announcement array and a cooperative mechanism to coordinate concurrent insertion operation, realizes the concurrent access of the hash table which can be linearized, and ensures strong consistency.
(2) The invention carries out collaborative design on persistent memory management and hash table construction, and the element pointer in the hash table is used as an indicator for finishing key value data storage, thereby realizing the persistent memory management and concurrent access without lock and log, obviously providing the throughput of the system and reducing the delay of operation.
(3) The invention realizes the dynamic multi-layer hash table module through the hierarchical ring buffer area in the persistent memory, controls the visibility of the hash table hierarchy by using the hierarchical metadata in the volatile memory, and can ensure the high hash table load rate and reduce the overhead of crash consistency.
Drawings
Fig. 1 is a schematic diagram illustrating a persistent memory-oriented data management method according to an embodiment of the present invention;
FIG. 2 is a flowchart of an advertisement array and a coordination mechanism provided in an embodiment of the present invention;
FIG. 3 is a diagram illustrating a persistent memory allocation scheme according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a frame structure according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. In addition, the technical features involved in the embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
In the present application, the terms "first," "second," and the like (if any) in the description and the drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
In order to solve the technical problem that the existing persistent memory-oriented lock-free hash table construction scheme cannot realize linearization in the persistent memory, the invention provides a persistent memory-oriented data management method, which has the overall thought that: the dynamic multi-layer hash table is used for indexing the element pointers, so that lock-free persistent memory management and concurrent access are realized, and the concurrent insertion operation of the element pointers is coordinated by using the announcement array system, so that the high-throughput low-delay hash table access and the linearization strong consistency guarantee are realized.
The following are examples.
Example 1:
in this embodiment, data is a key-value pair element, as shown in fig. 1, this embodiment includes:
an initialization step: and constructing a dynamic multi-layer hash table in a persistent memory, and constructing an advertisement array in a volatile memory.
As shown in fig. 1, the dynamic multi-layered hash table includes a multi-layered hash table, and each of the multi-layered hash table is composed of a plurality of hash buckets, and optionally, in this embodiment, each of the hash buckets is used to store 8 element pointers. In order to improve the parallelism and comprehensively consider the computation cost of the hash function, in this embodiment, each pointer has 2 candidate buckets in the hash table, and the positions of the candidate buckets are respectively passed through the hash function H 1 () And H 2 () Calculating, wherein the hash function can be selected correspondingly according to the actual application requirement so as to reduce the collision rate as much as possible; in other embodiments of the present invention, the number of alternative bucket positions of the element pointer in each layer may be adjusted to other integers.In the dynamic multi-layer hash table, the number of hash buckets in the hash table with higher hierarchy is greater, and in this embodiment, in two adjacent layers, the number of hash buckets in a higher layer is twice the number of hash buckets in a lower layer. In the dynamic multi-layer hash table, the accessible hash table is a visible layer.
In the advertisement array, the elements are hash buckets.
As shown in fig. 1, in the present embodiment, a ring buffer is used to manage a dynamic multi-layer buffer; accordingly, the initializing step further comprises: establishing a ring buffer area in the persistent memory, wherein the ring buffer area is used for storing the first address of each layer of hash table according to the sequence of the layers from low to high;
this embodiment still includes:
the pre-allocation step performed in the background includes: when the number of the pre-allocated inaccessible hash tables is less than 3, pre-allocating the hash tables as the inaccessible hash tables for the dynamic multi-layer hash tables, and sequentially storing the first addresses of the hash tables of each layer into a ring buffer area to enable the number of the pre-allocated inaccessible hash tables to be 3;
it should be noted that in other embodiments of the present invention, the number of pre-allocated layers can be flexibly adjusted according to actual situations.
As shown in fig. 1, in this embodiment, hierarchy metadata < Lt, lb > is also maintained in the volatile memory, where Lt and Lb are respectively used to store numbers of the top hash table and the bottom hash table in the ring buffer; the hash table with the number within the range of [ Lt, lb ] is an accessible hash table in the dynamic multi-layer hash table; the numbers Lt and Lb of the top hash table and the bottom hash table in the ring buffer are used as metadata to control the visible layer in the dynamic multi-layer hash table, and because the hierarchy metadata < Lt, lb > does not exceed 8 bytes and can be updated through atomic operation, the visible layer can be accurately controlled in real time by updating the hierarchy metadata through the atomic operation when the visible layer in the dynamic multi-layer hash table changes.
Based on the above structure, in this embodiment, the element pointer is inserted, updated, deleted, and queried through the hash table, and the inserting, updating, deleting, and querying of the pointer are completed respectively.
In this embodiment, the pointer inserting step includes: judging whether an element pointer which is the same as a key corresponding to the element pointer to be inserted exists in the dynamic multi-layer hash table or not, and if so, exiting the pointer insertion step; otherwise, traversing all visible layers from top to bottom, searching a matched alternative bucket for the element pointer to be inserted, and if an idle slot position exists in the matched alternative bucket, atomically inserting the pointer into the matched alternative bucket;
in this embodiment, before the element pointer is inserted, it is determined whether an element pointer that is the same as a key corresponding to the element pointer to be inserted exists in the dynamic multi-layer hash table, and if the element pointer exists, it is determined that the insertion fails, and the pointer insertion operation is directly exited, so that it can be ensured that the same key has at most one value in the dynamic multi-layer hash table, and the accuracy of the subsequent query operation is ensured; the judging mode is specifically as follows: traversing all visible layers from bottom to top, searching matched alternative buckets for the element pointers to be inserted, acquiring keys corresponding to the inserted element pointers in each alternative bucket, comparing the keys with the keys corresponding to the element pointers to be inserted, if the comparison results are different, inserting the elements, otherwise, judging that the inserting fails;
according to the method, the visible layer is traversed according to the top-down sequence, the matched spare bucket idle slot position can be found in a higher layer preferentially, and the pointer is inserted atomically, so that the subsequent query efficiency is improved; in order to further improve the efficiency, as a preferred embodiment, in this embodiment, if the multiple matched alternative buckets in the same layer all include an idle slot, an alternative bucket with a smaller offset of the idle slot in the bucket is selected, and the pointer is inserted atomically, so that the loads of the multiple matched alternative buckets can be balanced, the collision rate is reduced, and the efficiency is further improved;
if no spare slot position exists in the matched alternative barrel, distributing a new top-layer hash table for the dynamic multi-layer hash table, and then re-executing the pointer insertion step;
in order to implement fast capacity expansion of the dynamic multi-layer hash table to improve the efficiency of pointer insertion operation, as a preferred implementation, the initialization step of this embodiment further includes: pre-allocating 3 layers of hash tables as inaccessible layers for the dynamic multi-layer hash tables, and sequentially storing the first addresses of the hash tables in the ring buffer area; in the pointer insertion step, a new hash table can be added to the dynamic multi-layer hash table as the top-layer hash table by allocating the hash table with the lowest pre-allocated level to the dynamic multi-layer hash table as the visible layer. Specifically, by atomically updating the value of the hierarchy metadata < Lt, lb >, making Lt the same number in the ring buffer as the newly allocated hierarchy, the capacity expansion can be completed.
With the insertion of the element pointer, the levels of the dynamic multi-level hash table may gradually increase, and in order to avoid that the query efficiency is affected by too many levels, the embodiment further includes:
and a pointer migration step: traversing all visible layers except the bottom layer from top to bottom, searching a matched alternative bucket for the element pointer to be migrated, and if an idle slot position exists in the matched alternative bucket, atomically inserting the pointer into the matched alternative bucket; if no idle slot position exists in the matched alternative barrel, distributing a new top-layer hash table for the dynamic multi-layer hash table, and then re-executing the pointer migration step;
a re-hashing step performed in the background: when the number of the visible layers exceeds two, all element pointers in the bottom hash table are migrated to other visible layers through a pointer migration step, and after migration is completed, the storage space occupied by the bottom hash table is released; the number of layers of the dynamic multi-layer hash table can be effectively controlled through the re-hash operation executed by the background, and the query efficiency is ensured.
In the pointer insertion step of this embodiment, if the number of layers of the visible layer is greater than 2, when searching for an alternative bucket matching the element pointer to be inserted, the bottom layer is not traversed; therefore, enough alternative buckets can be ensured to ensure successful insertion, the pointer is not allowed to be inserted into the bottom layer, and the situation that the pointer is migrated due to the heavy hash operation after being inserted into the bottom layer, and finally the insertion is invalid can be effectively avoided;
in order to avoid this situation, in this embodiment, if the number of layers of the visible layer is 2 before the element pointer is inserted, and a new visible layer appears after the element pointer is inserted, the inserted element pointer may migrate due to the re-hash operation after the element pointer is inserted into the bottom layer, so as to cause insertion failure.
In this embodiment, the updating step includes: after inserting the new element into the persistent memory, the element pointer p is obtained 1 (ii) a Traversing the accessible layers in the dynamic multi-layer hash table from bottom to top, searching all matched element pointers, and only keeping the last matched pointer p 2 And delete the remaining matched pointers, using pointer p 1 Atomically replacing the pointer p 2
In order to avoid that the update is invalid due to the re-hash operation after the new pointer is inserted into the bottom layer, this embodiment further includes: and if the accessible layer number in the dynamic multi-layer hash table is changed before and after the updating step is executed, the updating step is executed again.
In this embodiment, the deletion operation includes: traversing the accessible layers in the dynamic multi-layer hash table from bottom to top, deleting all matched pointers one by one atomically, and releasing corresponding elements;
in order to avoid that the pointer of the bottom layer match is not deleted because it is migrated to the new visible layer, this embodiment further includes: and if the accessible layer number in the dynamic multi-layer hash table is changed before and after the deletion step is executed, the deletion step is executed again.
In this embodiment, the query operation includes: and traversing all accessible layers in the dynamic multi-layer hash table from bottom to top until the first matched element pointer is found, and returning the element to be found according to the pointer.
To further ensure consistency of the persistent memory, the embodiment sets the highest bit of the element pointer as a persistent flag bit, "1" indicates that it has been persisted, and "0" indicates that it has not been persisted;
and, the pointer inserting step further includes: setting a persistence flag bit of the cache line before insertion to indicate that the cache line is not persisted, namely, to be set to '0', inserting a pointer into a dynamic multi-layer hash table, then flushing a corresponding cache line, and then atomically setting the persistence flag bit to indicate that the cache line is persisted, namely, to be set to '1';
when any thread reads a pointer of which the persistence flag bit indicates that the pointer is not persisted, refreshing the corresponding cache line, and atomically setting the persistence flag bit for indicating that the pointer is persisted; based on this operation, the present embodiment implements cooperative persistence of element pointers.
In order to implement linearization under the persistent memory to ensure strong consistency, this embodiment further includes:
a synchronization step: as shown in FIG. 2, after an element to be stored is stored to persistent memory, a pointer p to the element is placed in the advertisement array n Searching the hash bucket, if the matched hash bucket H has an old element pointer p o Then the pointer p is inserted by a pointer insertion step o After inserting the dynamic multi-layered hash table, the element pointers in the hash bucket H are atomically replaced by a pointer p n The pointer p is inserted by a pointer insertion step n Inserting a dynamic multi-layer hash table, and then emptying a hash bucket H; if hash bucket H is empty, pointer p is inserted by a pointer insertion step n Inserting a dynamic multi-layer hash table, and then emptying a hash bucket H; based on the operation, the embodiment realizes the cooperative concurrent insertion operation, ensures that the operations can be executed according to a strict sequence, realizes the linearization under the persistent memory, and ensures the strong consistency.
In order to fully utilize the storage space, in this embodiment, the storage areas of the elements in the persistent memory are managed in the form of frames; the frames are continuous spaces in the persistent memory, each frame comprises a plurality of blocks with fixed sizes, one or more blocks are allocated to each block when the elements are stored, the internal structure of the frame is as shown in fig. 3, the head of the frame records the signature and the size of the block in the frame, and reserved bits. As shown in fig. 4, in this embodiment, 16 kinds of frames are predetermined, and are sequentially from frame class 0 to frame class 15, the sizes of blocks in the different kinds of frames are different, and each foreground thread has a persistent memory allocator for managing 16 kinds of frames.
Based on the above persistent memory allocation scheme, this embodiment further includes:
element insertion: atomically allocating a frame with a proper size to an element to be inserted, so that after the element is stored in one block or a plurality of continuous blocks in the frame, the difference between the size of the allocated storage space and the size of the storage space required by the element is minimum; and sequentially inserting the elements to be inserted into the allocated frames.
As shown in fig. 4, in this embodiment, the persistent memory allocator dynamically allocates space for elements and layers of the hash table in the persistent memory without log, where the dynamic allocation range of the elements is extended from a low address to a high address, and the extended granularity is a frame with a fixed size, and the space is atomically extended by a global frame pointer; the distribution range of the layers is expanded from a high address to a low address, the recovered layers can be redistributed to new elements, and the new layers are distributed atomically through a global layer pointer;
because the space occupied by the elements and the pointers is different in size, the dynamic multi-layer hash table and the frames are respectively arranged at the high address end and the low address end of the persistent memory for centralized storage, so that space fragments can be reduced, and the space utilization rate is improved. It should be noted that in some other embodiments of the present invention, the storage locations of the dynamic multi-layer hash table and the frame may be interchanged, that is, the dynamic allocation range of the element extends from high address to low address, and the allocation range of the layer extends from low address to high address.
Example 2:
a persistent memory controller, comprising: a processor and a computer-readable storage medium;
a computer program is stored in a computer readable storage medium; the processor is configured to read the computer program and execute the persistent memory-oriented data management method provided in embodiment 1.
Example 3:
a persistent memory system, comprising: persistent memory and the persistent memory controller provided in embodiment 2 above.
It will be understood by those skilled in the art that the foregoing is only an exemplary embodiment of the present invention, and is not intended to limit the invention to the particular forms disclosed, since various modifications, substitutions and improvements within the spirit and scope of the invention are possible and within the scope of the appended claims.

Claims (10)

1. A data management method facing persistent memory is disclosed, the data is key value pair elements, and the method is characterized by comprising the following steps:
an initialization step: constructing a dynamic multi-layer hash table in a persistent memory, wherein the dynamic multi-layer hash table comprises a plurality of hash buckets for storing the pointers of the elements with the specified number, each pointer comprises X alternative buckets in each layer of hash table, the number of the hash buckets in the hash table with higher layers is more, and the accessible hash table is a visible layer; constructing a notice array in a volatile memory, wherein the array element is a hash bucket; x is a positive integer;
a pointer insertion step: judging whether an element pointer which is the same as a key corresponding to the element pointer to be inserted exists in the dynamic multi-layer hash table or not, and if so, exiting the pointer insertion step; otherwise, traversing all visible layers from top to bottom, searching a matched alternative bucket for the element pointer to be inserted, and if an idle slot position exists in the matched alternative bucket, atomically inserting the pointer into the matched alternative bucket; if no spare slot position exists in the matched alternative barrel, distributing a new top-layer hash table for the dynamic multi-layer hash table, and then re-executing the pointer insertion step;
a synchronization step: after storing the element to be stored to the persistent memory, a pointer p to the element in the advertisement array n Searching the hash bucket, if the matched hash bucket H has an old element pointer p o Said pointer p is inserted by said pointer insertion step o Inserting the dynamic multi-layer haarFollowing the Hill Table, atomically replacing the element pointer in the hash bucket H with the pointer p n The pointer p is inserted by the pointer insertion step n Inserting the dynamic multi-layer hash table, and then emptying the hash bucket H; if the hash bucket H is empty, the pointer p is inserted by the pointer insertion step n Inserting the dynamic multi-layer hash table, and then emptying the hash bucket H.
2. The persistent memory-oriented data management method of claim 1, further comprising:
a pointer migration step: traversing all visible layers except the bottom layer from top to bottom, searching a matched alternative bucket for the element pointer to be migrated, and if an idle slot position exists in the matched alternative bucket, atomically inserting the pointer into the matched alternative bucket; if no spare slot position exists in the matched alternative barrel, distributing a new top-layer hash table for the dynamic multi-layer hash table, and then re-executing the pointer migration step;
a re-hashing step performed in the background: when the number of the visible layers exceeds two, all the element pointers in the bottom hash table are migrated to other visible layers through the pointer migration step, and after migration is completed, the storage space occupied by the bottom hash table is released;
in the pointer insertion step, if the number of layers of the visible layer is greater than 2, the bottom layer is not traversed when the alternative bucket matched with the element pointer to be inserted is searched; if the number of layers of the visible layer is 2 before the element pointer is inserted, and a new visible layer appears after the element pointer is inserted, the pointer insertion step is executed again.
3. The persistent-memory-oriented data management method according to claim 2, wherein the initializing step further comprises: and establishing a ring buffer area in the persistent memory, wherein the ring buffer area is used for storing the first addresses of the hash tables of all layers in a sequence from low to high in the hierarchy.
4. The persistent memory-oriented data management method of claim 3, further comprising: a pre-allocation step performed in the background;
the initialization step further comprises: pre-allocating M layers of hash tables as inaccessible layers for the dynamic multi-layer hash tables, and sequentially storing the first addresses of the hash tables in the ring buffer;
in the pointer inserting step, a new hash table is added to the dynamic multi-layer hash table as a top-layer hash table in a mode that the pre-allocated hash table with the lowest level is allocated to the dynamic multi-layer hash table as a visible layer;
the pre-allocating step comprises: when the number of the pre-allocated inaccessible hash tables is less than M, pre-allocating the hash tables as the inaccessible hash tables for the dynamic multi-layer hash tables, and sequentially storing the first addresses of the hash tables of each layer into the ring buffer area to enable the number of the pre-allocated inaccessible hash tables to be M;
wherein M is a positive integer.
5. The persistent-memory-oriented data management method according to claim 4, wherein hierarchy metadata < Lt, lb > is further maintained in the volatile memory, where Lt and Lb are respectively used to store numbers of the top hash table and the bottom hash table in the ring buffer; the hash table with the number within the range of [ Lt, lb ] is an accessible hash table in the dynamic multi-layer hash table;
in the pointer inserting step, while adding a new hash table as a top hash table to the dynamic multi-layer hash table, the value of the hierarchical metadata < Lt, lb > is atomically updated; in the re-hashing step, the value of the hierarchical metadata < Lt, lb > is atomically updated while the storage space occupied by the underlying hash table is released.
6. The persistent memory-oriented data management method according to any one of claims 1 to 5, further comprising:
element insertion: atomically allocating a frame with a proper size to an element to be inserted, so that after the element is stored in one block or a plurality of continuous blocks in the frame, the difference between the size of the allocated storage space and the size of the storage space required by the element is minimum; inserting the elements to be inserted into the allocated frames in sequence;
wherein, the frames are continuous spaces in the persistent memory, and each frame comprises a plurality of blocks with fixed sizes; different kinds of frames, block sizes are different.
7. The persistent memory-oriented data management method according to claim 6, wherein the dynamic storage hash table and the frame dynamically allocate space in the persistent memory without log, the dynamic storage hash table allocates storage spaces atomically in the order of addresses from high to low, and the frame allocates storage spaces atomically in the order of addresses from low to high;
or, the dynamic storage hash table allocates the storage space atomically according to the sequence of addresses from low to high, and the frame allocates the storage space atomically according to the sequence of addresses from high to low.
8. The persistent memory-oriented data management method according to any one of claims 1 to 5, further comprising:
an updating step: after inserting the new element into the persistent memory, obtaining the element pointer p 1 (ii) a Traversing accessible layers in the dynamic multi-layered hash table from bottom to top, looking up all matching element pointers, and retaining only the last matching pointer p 2 And deleting the other matched pointers by using the pointer p 1 Atomically replacing the pointer p 2 (ii) a If the accessible layer number in the dynamic multi-layer hash table changes before and after the updating step is executed, the updating step is executed again;
and (3) deleting: traversing accessible layers in the dynamic multi-layer hash table from bottom to top, deleting all matched pointers one by one atomically, and releasing corresponding elements; if the accessible layer number in the dynamic multi-layer hash table changes before and after the deletion step is executed, the deletion step is executed again;
and (3) query step: and traversing all accessible layers in the dynamic multi-layer hash table from bottom to top until the first matched element pointer is found, and returning the element to be found according to the pointer.
9. The persistent memory-oriented data management method according to claim 8, wherein a persistence flag bit is set in the element pointer to indicate whether or not to be persisted;
and, the pointer inserting step further includes: before inserting, setting a persistence flag bit of the cache line for indicating that the cache line is not persisted, inserting a pointer into the dynamic multi-layer hash table, then refreshing the corresponding cache line, and then atomically setting the persistence flag bit for indicating that the cache line is persisted;
when any thread reads a pointer whose persistence flag bit indicates that it is not persisted, the corresponding cache line is flushed and the persistence flag bit is set atomically to indicate that it has been persisted.
10. A persistent memory controller, comprising: a processor and a computer-readable storage medium;
the computer-readable storage medium has stored therein a computer program; the processor is used for reading the computer program and executing the data management method facing the persistent memory according to any one of claims 1 to 9.
CN202210883333.8A 2022-07-26 2022-07-26 Data management method for persistent memory and persistent memory controller Pending CN115329141A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210883333.8A CN115329141A (en) 2022-07-26 2022-07-26 Data management method for persistent memory and persistent memory controller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210883333.8A CN115329141A (en) 2022-07-26 2022-07-26 Data management method for persistent memory and persistent memory controller

Publications (1)

Publication Number Publication Date
CN115329141A true CN115329141A (en) 2022-11-11

Family

ID=83919722

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210883333.8A Pending CN115329141A (en) 2022-07-26 2022-07-26 Data management method for persistent memory and persistent memory controller

Country Status (1)

Country Link
CN (1) CN115329141A (en)

Similar Documents

Publication Publication Date Title
CN111309270B (en) Persistent memory key value storage system
CN101556557B (en) Object file organization method based on object storage device
CN110825748B (en) High-performance and easily-expandable key value storage method by utilizing differentiated indexing mechanism
JP6205650B2 (en) Method and apparatus utilizing non-uniform hash function to place records in non-uniform access memory
US8478931B1 (en) Using non-volatile memory resources to enable a virtual buffer pool for a database application
US7949839B2 (en) Managing memory pages
CN110119425A (en) Solid state drive, distributed data-storage system and the method using key assignments storage
CN107544756B (en) Key-Value log type local storage method based on SCM
US11269772B2 (en) Persistent memory storage engine device based on log structure and control method thereof
CN114281762B (en) Log storage acceleration method, device, equipment and medium
CN112597254B (en) Hybrid DRAM-NVM (dynamic random Access memory-non volatile memory) main memory oriented online transactional database system
US20180004798A1 (en) Read only bufferpool
EP3974974A1 (en) Virtualization method and system for persistent memory
CN115168364A (en) NVM-based partition Clevel hash index structure and data processing method
KR100907477B1 (en) Apparatus and method for managing index of data stored in flash memory
CN111221773B (en) Data storage architecture method based on RDMA high-speed network and skip list
Hu et al. Parallel multi-split extendible hashing for persistent memory
CN115048046B (en) Log file system and data management method
CN116226232A (en) Persistent memory data storage method and system for distributed database
US11687392B2 (en) Method and system for constructing persistent memory index in non-uniform memory access architecture
CN113204520B (en) Remote sensing data rapid concurrent read-write method based on distributed file system
CN115329141A (en) Data management method for persistent memory and persistent memory controller
CN111078143B (en) Hybrid storage method and system for data layout and scheduling based on segment mapping
US7185029B1 (en) Method and apparatus for maintaining, and updating in-memory copies of the first and second pointers to reference the new versions of the first and second control structures that indicate available and allocated portions of usable space in the data file
KR100982591B1 (en) File system, main storage and flash storage for progressive indexing and data management method using the progressive indexing

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination