Collaborative invalid key-value pair confirmation method and garbage collection method applied to WiscKey

By cooperating with hash tables and bit arrays in memory, the WiscKey system realizes fast confirmation of invalid key-value pairs and efficient garbage collection, solves the problem of high memory access overhead of key-value separated storage systems under update-intensive loads, and improves efficiency System update performance and throughput.

CN118312515BActive Publication Date: 2024-09-24HUAQIAO UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410726237.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-06
Publication Date
2024-09-24
Estimated Expiration
2044-06-06

AI Technical Summary

Technical Problem

Under update-intensive workloads, the garbage collection operation of the key-value separated storage system WiscKey has high memory access overhead, especially because frequent confirmation of invalid key-value pairs requires access to the LSM tree, resulting in large query delays and time overhead.

Method used

A collaborative invalid key-value pair confirmation method is adopted, combining a hash table and a bit array to run collaboratively in memory to avoid accessing external memory. The hash table is used to query the validity of the key-value pair, and the bit array is used to record the location of the invalid key-value pair. , to achieve fast invalid key-value pair confirmation and garbage collection.

Benefits of technology

It significantly reduces the time and space overhead of invalid key-value pair confirmation and garbage collection, improves update performance, reduces dependence on the LSM tree, and improves system throughput and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118312515B
    Figure CN118312515B
Patent Text Reader

Abstract

The present invention is a collaborative invalid key-value pair confirmation method and a garbage collection method applied to WiscKey, which relates to the field of computer storage. The collaborative invalid key-value pair confirmation method includes: if a value offset address is found in a hash table, and it is equal to the address where the key-value pair is located, then this key-value pair is a new version, that is, valid data; if a value offset address is found in the hash table, but it is not equal to the address where the key-value pair is located, then this key-value pair is an old version, that is, invalid data; if the value offset address cannot be found in the hash table, and the corresponding bit in the bit array is 1, then this key-value pair is valid data; if the value offset address cannot be found in the hash table, and the corresponding bit in the bit array is 0, then this key-value pair is an invalid number. The method of the present invention does not need to access external memory, and can effectively control memory occupancy, and realizes garbage collection operations with low time overhead and low space overhead.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer storage, and in particular to a collaborative invalid key-value pair confirmation method and a garbage collection method applied to WiscKey. Background Art

[0002] In recent years, with the rise of the Internet, cloud computing, big data and other applications have become more and more widespread, and NoSQL databases have become increasingly prosperous. As a type of NoSQL, key-value storage has produced many successful commercial products, such as FaceBook's RocksDB, Google's LevelDB and BigTable.

[0003] At present, there are many different implementations of key-value storage systems. One of them is the key-value storage system based on the LSM tree. This system is a popular key-value storage implementation. Compared with other implementation structures, the main advantage of the LSM tree is that it uses a sequential write mode, which fundamentally improves the write throughput. In order to support multi-key range queries and single-key point queries, the LSM tree maintains multiple ordered key ranges. The 0th layer of the LSM tree has multiple ordered key ranges, and each layer from the 1st to the nth layer has an ordered key range. To this end, the LSM tree uses a mechanism called inter-layer merging to sort multiple key-value pairs and recycle invalid key-value pairs. It should be pointed out that the inter-layer merging mechanism of the LSM tree will occupy more I / O bandwidth, causing bandwidth competition with the user's read and write operations, and the repeated writing of data after sorting will increase the life loss of the solid-state drive. In order to solve the problems of the LSM tree, key-value separation came into being. As a classic design of key-value separation, the main method of WiscKey is to store values ​​in a value log in other ways to avoid the values ​​being involved in the execution process of inter-layer merging. The key-value separation strategy significantly improves the system throughput.

[0004] However, in different popular workloads, key-value separation storage systems still have room for memory access optimization. Specifically, the key-value separation storage system WiscKey still cannot fully achieve high performance under update-intensive workloads. The root cause is that WiscKey's value log requires frequent garbage collection operations to reclaim space from key-value pairs that are invalidated due to new updates. However, garbage collection of value logs has high overhead, and if the reserved space is limited, the garbage collection overhead will become more serious. The garbage collection operation requires querying the LSM tree to check the invalidity of each key-value pair. Even though key-value separation has reduced the number of layers of the LSM tree to a certain extent, the query may still need to go through multiple layers of the LSM tree, which has high memory access overhead. Therefore, these queries have high latency, especially when the LSM tree becomes quite large under large data volumes.

[0005] In order to reduce the garbage collection memory access overhead in the WiscKey value log, HashKV adopts a new hash-based data grouping to replace the value log structure. The idea is to divide the value storage structure into fixed-size partitions and map each written key-value pair to a partition through hashing. Because the old and new key-value pairs of the same key exist in the same partition, each garbage collection operation can select a partition, and then identify invalid key-value pairs by scanning the entire partition, thereby reclaiming space. This method of confirming invalid key-value pairs does not require queries on the LSM tree, reducing the garbage collection memory access overhead inherent in the original WiscKey.

[0006] It should be pointed out that although HashKV saves the LSM tree query process through the new value storage structure, the time overhead of other operations in the system has become larger. The reason is that compared with the value log of WiscKey, the design of HashKV value storage structure is more complex, resulting in additional overhead. Therefore, it can be concluded that if the time of WiscKey's key-value pair invalidity check can be reduced to a certain level, while inheriting the advantages of the system value log structure, then under update-intensive loads, the update performance of the key-value separation storage system can be further improved.

[0007] At present, with the development of flash memory technology, the access speed of widely used solid-state drives is much higher than that of magnetic disks. However, the access speed of memory is still three orders of magnitude slower than that of solid-state drives. Therefore, if the memory operation is used to replace the external memory operation of accessing the LSM tree in WiscKey, the memory access time overhead can be reduced, and the speed of key-value pair invalidity check can be significantly improved. Summary of the invention

[0008] In view of the technical problems mentioned above, the purpose of the embodiments of the present application is to propose a collaborative invalid key-value pair confirmation method and garbage collection method applied to WiscKey, which can realize the efficient operation of the key-value separation storage system WiscKey under update-intensive workloads. The present invention combines the advantages of two basic invalid key-value pair confirmation strategies (one is to record the invalid data identified during the LSM tree inter-layer merge in the memory, and the other is to directly query the LSM tree to obtain the validity of the data), so that the two can run collaboratively in the memory without accessing the external memory, and effectively control the memory occupancy, and realize the garbage collection operation with low time overhead and low space overhead.

[0009] The technical solution of the present invention is as follows.

[0010] In a first aspect, a collaborative invalid key-value pair confirmation method applied to WiscKey includes:

[0011] S101, for a key-value pair whose validity is to be confirmed, a query operation of the key in the hash table is issued, and then to S102;

[0012] S102, if the search is successful, go to S103, otherwise, go to S105;

[0013] S103, determining whether the value offset address obtained by querying the hash table is equal to the offset address of the key-value pair in the value log, if they are equal, proceed to S104, if not equal, proceed to S107;

[0014] S104, confirming that the key-value pair is valid data, and ending the confirmation process;

[0015] S105, query the corresponding bit of the bit array, and go to S106;

[0016] S106, if the corresponding bit is 1, go to S104, if the corresponding bit is not 1, go to S107;

[0017] S107, confirming that the key-value pair is invalid data.

[0018] Preferably, each element of the hash table structure stores a key and an offset address of a key-value pair corresponding to the key in the value log;

[0019] After the key-value pair is written to the value log, the key and metadata are inserted into the LSM tree, and the offset address of the key and value log is inserted into the hash table; specifically, the hash table stores a copy of the higher-level data of the LSM tree; as the inter-layer merge proceeds, the data in the higher layers of the LSM tree will be gradually migrated to the bottom layer; at this time, the background thread will delete the data copies in the hash table that do not belong to the higher layers of the LSM tree, so that the hash table always retains the data copies of the higher layers of the LSM tree; among them, the higher layers refer to all layers higher than the bottom layer.

[0020] Preferably, the bit array is a circular array composed of a plurality of bits, and each bit corresponds to each key-value pair in the value log in sequence; when the bit is 0, it means that the corresponding key-value pair is invalid;

[0021] The initial value of each bit in the bit array is 1. When the LSM tree inter-layer merge operation identifies an updated old version key and metadata, the key-value pair pointed to by the old version key and metadata is also old, that is, invalid. The corresponding bit is found through the order position of the key-value pair recorded in the old version key and metadata, and set to 0.

[0022] Preferably, the method for finding the corresponding bit position through the key-value pair sequence position of the old version key and metadata record is as follows:

[0023] index=position-position min

[0024] Among them, index is the bit array subscript, position is the order position of the corresponding key-value pair recorded in the key and metadata, and position min is the global minimum order value.

[0025] On the other hand, a garbage collection method applied to WiscKey is characterized by being based on the collaborative invalid key-value pair confirmation method, specifically comprising:

[0026] S201, when the space of the value log is insufficient, a garbage collection operation is triggered;

[0027] S202, read a batch of key-value pairs from the end of the value log;

[0028] S203, finding invalid key-value pairs and deleting them through the collaborative invalid key-value pair confirmation method;

[0029] S204, append the remaining valid key-value pairs to the header of the value log;

[0030] S205, updating the state of the bit array to maintain a one-to-one correspondence between the bit array and the value log key-value pair;

[0031] S206, write the key and metadata with the new offset address and the new order to the LSM tree, and then write the new offset address and the new order to the hash table;

[0032] S207, releasing the corresponding space at the end of the value log.

[0033] Compared with the prior art, the present invention has the following beneficial effects:

[0034] (1) The present invention combines the advantages of two basic invalid key-value pair confirmation strategies (one is to record the invalid data identified during the LSM tree inter-layer merge in the memory, and the other is to directly query the LSM tree to obtain the validity of the data), so that the two can run in memory in coordination without accessing external memory, and have a higher invalid key-value pair confirmation speed, thereby having a higher garbage collection execution speed and update operation throughput;

[0035] (2) The present invention only needs to put the data of the higher layers of the LSM tree into the memory, thus avoiding excessive memory space occupation. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0037] Figure 1 It is a schematic diagram of the framework of a collaborative invalid key-value pair confirmation method applied to a key-value separation storage system WiscKey according to an embodiment of the present invention;

[0038] Figure 2 It is a flow chart of a collaborative invalid key-value pair confirmation method applied to a key-value separation storage system WiscKey according to an embodiment of the present invention;

[0039] Figure 3 The present invention is a flowchart of a garbage collection method applied to a key-value separation storage system WiscKey according to an embodiment of the present invention. DETAILED DESCRIPTION

[0040] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.

[0041] The collaborative invalid key-value pair confirmation method proposed by the present invention and applied to the key-value separation storage system WiscKey includes: if the value offset address is found in the hash table and it is equal to the address where the key-value pair is located, then this key-value pair is a new version, that is, valid data; if the value offset address is found in the hash table, but it is not equal to the address where the key-value pair is located, then this key-value pair is an old version, that is, invalid data; if the value offset address cannot be found in the hash table, and the corresponding bit in the bit array is 1, then this key-value pair is valid data; if the value offset address cannot be found in the hash table, and the corresponding bit in the bit array is 0, then this key-value pair is an invalid number.

[0042] See also Figure 1 As shown, the system structure of the collaborative invalid key-value pair confirmation method applied to the key-value separation storage system WiscKey of the present invention includes a series of memory structures, each of which includes a hash table and a bit array.

[0043] See also Figure 2 As shown, it is an execution flow chart of the collaborative invalid key-value pair confirmation method applied to the key-value separation storage system WiscKey, which includes the following steps.

[0044] 101, for a key-value pair whose validity is to be confirmed, a query operation of the key in the hash table is issued to 102;

[0045] 102, if the search is successful, go to 103, otherwise, go to 105;

[0046] 103, determine whether the value offset address obtained by querying the hash table is equal to the offset address of the key-value pair in the value log, if they are equal, go to 104, if not equal, go to 107;

[0047] 104, confirming that the key-value pair is valid data, and ending the confirmation process;

[0048] 105, query the corresponding bit of the bit array, to 106;

[0049] 106, if the corresponding bit is 1, go to 104, if the corresponding bit is not 1, go to 107;

[0050] 107, confirming that the key-value pair is invalid data.

[0051] In the present invention, during the garbage collection process, the hash table replaces the LSM tree to complete the invalidity check of the key-value pair in the memory. When checking whether each key-value pair is invalid, it is only necessary to query the structure without querying the LSM tree. Each element of the structure not only stores the key, but also has the offset address of the key-value pair corresponding to it in the value log. These data come from each write operation. When the key-value pair is written to the value log, the key and metadata are inserted into the LSM tree, and then the offset address of the key and value log is inserted into the hash table. In fact, what is stored in the hash table is a copy of the data of the LSM tree. However, it should be pointed out that although the hash table replaces the function of the LSM tree in garbage collection, it does not store all the data copies of the LSM tree, but only stores the copies of the data of the higher layers of the LSM tree (all layers higher than the bottom layer). As the inter-layer merge proceeds, the data of the higher layers of the LSM tree will be migrated to the bottom layer one after another. At this time, a background thread will delete the data copies that do not belong to the higher layers of the LSM tree in the hash table, so that the hash table always retains the data copies of the higher layers of the LSM. Note that the fact that the hash table stores a copy of some of the data in the LSM tree does not mean that the basic functions of the LSM tree are deprived. On the contrary, range queries and point queries still require the use of the LSM tree.

[0052] The bit array is a circular array composed of multiple bits, and each bit corresponds to each key-value pair in the value log in order. When the bit is 0, it means that the corresponding key-value pair is invalid. The initial value of each bit of the bit array is 1. When the LSM tree inter-layer merge operation identifies an updated old version of the key and metadata (the metadata includes fields such as value size, value offset address and order), it means that the key-value pair pointed to by the key and metadata is also old (that is, invalid). At this time, the corresponding bit can be found through the key-value pair sequence position recorded in the key and metadata, and set to 0, indicating that the key-value pair corresponding to the key and metadata is old (that is, invalid). The method of finding the corresponding bit by the key-value pair sequence position recorded in the key and metadata is as follows:

[0053] index=position-position min

[0054] Among them, index is the bit array subscript, position is the order position of the corresponding key-value pair recorded in the key and metadata, and position min is the global minimum order value.

[0055] See also Figure 3 As shown, it is an execution flow chart of the garbage collection method applied to the key-value separation storage system WiscKey, which includes the following steps.

[0056] S201, when the space of the value log is insufficient, a garbage collection operation is triggered;

[0057] S202, read a batch of key-value pairs from the end of the value log;

[0058] S203, finding invalid key-value pairs and deleting them by coordinating the invalid key-value pair confirmation method;

[0059] S204, append the remaining valid key-value pairs to the header of the value log;

[0060] S205, updating the state of the bit array to maintain a one-to-one correspondence between the bit array and the value log key-value pair;

[0061] S206, write the key and metadata with the new offset address and the new order to the LSM tree, and then write the new offset address and the new order to the hash table;

[0062] S207, releasing the corresponding space at the end of the value log.

[0063] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A collaborative invalid key-value pair confirmation method applied to WiscKey, It is characterized in that include: S101, for a key-value pair whose validity is to be confirmed, a query operation of the key in the hash table is issued, and then to S102; S102, if the search is successful, go to S103, otherwise, go to S105; S103, determining whether the value offset address obtained by querying the hash table is equal to the offset address of the key-value pair in the value log, if they are equal, proceed to S104, if not equal, proceed to S107; S104, confirming that the key-value pair is valid data, and ending the confirmation; S105, query the corresponding bit of the bit array, and go to S106; S106, if the corresponding bit is 1, go to S104, if the corresponding bit is not 1, go to S107; S107, confirming that the key-value pair is invalid data; The hash table and the bit array are stored in a memory structure; Each element of the hash table structure stores the key and the offset address of the key-value pair corresponding to the key in the value log; after the key-value pair is written to the value log, the key and metadata are inserted into the LSM tree, and the offset address of the key and value log is inserted into the hash table; specifically, the hash table stores a copy of the higher-level data of the LSM tree; As the inter-layer merge proceeds, the data in the higher layers of the LSM tree will be gradually migrated to the bottom layer. At this time, the background thread will delete the data copies in the hash table that do not belong to the higher layers of the LSM tree, so that the hash table always retains the data copies of the higher layers of the LSM tree. The higher layers refer to all layers higher than the bottom layer. The bit array is a circular array composed of multiple bits, and each bit corresponds to each key-value pair in the value log in sequence; when the bit is 0, it means that the corresponding key-value pair is invalid; the initial value of each bit in the bit array is 1. When the LSM tree inter-layer merge operation identifies an updated old version key and metadata, the key-value pair pointed to by the old version key and metadata is also old, that is, invalid; find the corresponding bit through the key-value pair sequence position recorded in the old version key and metadata, and set it to 0; The method to find the corresponding bit position through the key-value pair sequence of the old version key and metadata record is as follows: index = position - position min ; in, index is the bit array subscript, position is the order of the corresponding key-value pairs recorded in the key and metadata. position min is the global minimum order value.

2. A garbage collection method applied to WiscKey, It is characterized in that Based on the collaborative invalid key-value pair confirmation method as claimed in claim 1, it specifically includes: S201, when the space of the value log is insufficient, a garbage collection operation is triggered; S202, read a batch of key-value pairs from the end of the value log; S203, finding invalid key-value pairs and deleting them through the collaborative invalid key-value pair confirmation method; S204, append the remaining valid key-value pairs to the header of the value log; S205, updating the state of the bit array to maintain a one-to-one correspondence between the bit array and the value log key-value pair; S206, write the key and metadata with the new offset address and the new order to the LSM tree, and then write the new offset address and the new order to the hash table; S207, releasing the corresponding space at the end of the value log.