Storage and calculation integrated memory system and key value storage system based on B + tree index
By implementing in-situ equal value search and in-situ first larger value search in an integrated storage and computing memory system, the problem of a large number of searches and memory accesses in index operations in the existing technology is solved, and storage performance and search efficiency are improved.
Patent Information
- Application Number
- CN202411226505.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-09-03
AI Technical Summary
The existing key-value pair storage system has a large number of search and memory fetch operations in the index operation, resulting in a degradation of storage performance.
By realizing the equivalent value search in situ and the first larger value search in place in the deposit and calculations, use the parallel data comparison function of the cross -point matrix of the blocking memory, reduce data access and comparison operations, and improve the search operation operation. Parallelism.
The search efficiency is improved, the time complexity of the B+tree index is reduced, and the storage performance of the key value storage system is improved.
Smart Images

Figure CN119336698A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the intersection field of storage and computing, and more specifically, relates to a storage and computing integrated memory system and a key-value storage system based on B+ tree index. Background Art
[0002] Key-value storage systems allow applications to store unformatted data, which replaces the need for fixed data models and reduces the need for data formatting. They are widely used in high-performance, low-latency, scalable, and high-concurrency applications. In a key-value storage system, each data item consists of a unique key and an associated value. Due to this structure, key-value storage operations require data indexing to quickly insert, query, update, and delete the value corresponding to a given key.
[0003] A variety of data structures are used to speed up data indexing, usually including tree indexes and hash indexes. Among them, B+ tree is an important and typical tree index structure, which is widely used in databases and data-intensive systems. The indexing process of B+ tree requires traversing multiple layers of tree nodes, and its search time complexity is usually O(logN), where N is the amount of data storage. This process requires a large number of search and memory access operations, resulting in a decrease in the efficiency of index operations, affecting the storage performance of the key-value pair storage system.
[0004] At present, some researchers have proposed new index structures such as learning index, but the index structure is usually organized into a tree shape, and there are still multiple rounds of calculation and comparison, which will lead to a large number of search operations and memory access, resulting in a decrease in the efficiency of index operations.
[0005] In general, the storage performance of existing key-value storage systems still needs to be further improved. Summary of the invention
[0006] In response to the defects of the prior art and the need for improvement, the present invention provides a storage and computing integrated memory system and a key-value storage system based on B+ tree index, whose purpose is to implement in-situ equal value search and in-situ first larger value search in the intersection array, so as to reduce data access, comparison and other operations during the search process, and improve the parallelism of search operations, thereby improving search efficiency and supporting efficient indexing of B+ tree.
[0007] To achieve the above-mentioned object, according to one aspect of the present invention, a storage-computation integrated memory system is provided, comprising: a plurality of array clusters and a plurality of corresponding array cluster controllers; the array clusters comprise a plurality of array groups; the array groups comprise a plurality of arrays, and the array groups have a computing mode and a storage mode; the arrays are cross-point arrays composed of resistive memory cells; the array cluster controller is used to control the array groups in the corresponding array clusters so that the array groups support array operations;
[0008] If the array group is in the calculation mode, the array operation includes an in-situ equal-value search operation; the in-situ equal-value search operation includes: applying a voltage matching the data to be searched to the bit lines to activate all the cells in the selected rows; sensing the word line voltages output by each selected row to search for the rows storing data matching the data to be searched;
[0009] If the array group is in the calculation mode and the data in each row is stored in an orderly manner, the array operation further includes an in-situ first larger value search operation; the in-situ first larger value search operation includes:
[0010] S1: Initialize left as the serial number of the highest-order bit line and right as the serial number of the lowest-order bit line;
[0011] S2: If left < right, set mid = (left + right) / 2; otherwise, go to S5;
[0012] S3: Search for the rows in which the data stored in the left to mid bits matches the left to mid bits of the data to be searched through the in-situ equal-value search operation, and eliminate the unmatched rows. At the same time, use the left to mid bits in the data to be searched as the common prefix;
[0013] S4: If the remaining number of rows is 0, update right according to right = mid; otherwise, update left according to left = mid + 1, and then go to S2;
[0014] S5: After concatenating all the common prefixes in order to form the longest common prefix, if the next bit after the longest common prefix in the data to be searched is 0, determine that the data stored in the first row among the remaining rows is the first larger value; otherwise, determine that the data stored in the row next to the last row among the remaining rows is the first larger value.
[0015] Furthermore, the array operation further includes: a row read operation and a row write operation;
[0016] The row read operation includes:
[0017] Applying a voltage to the word line where the row to be read is located to activate all the cells in the row to be read;
[0018] Sensing the voltage results output by each bit line to realize the reading of the data stored in the row to be read;
[0019] The row write operation includes:
[0020] Applying a voltage matching the data to be written to the bit lines to activate all the cells in the row to be written and realize the writing of the data to be written.
[0021] Furthermore, the array operation further includes: a row deletion operation and a within-cluster movement operation;
[0022] Row deletion operations include:
[0023] A valid bit indicating that the data in the row is invalid is written to the row to be deleted through a row write operation, and the deletion operation ends;
[0024] Intra-cluster move operations are used to move data from source rows to target rows. Intra-cluster move operations include:
[0025] Read the data in the source row through the row read operation;
[0026] The read data is written into the target row through the row write operation, and the intra-cluster move operation is completed.
[0027] According to another aspect of the present invention, a key-value storage system based on a B+ tree index is provided, comprising: the above-mentioned storage-computing integrated system and an index controller provided by the present invention; the storage-computing integrated system is used to store key-value pair data; the index controller is used to establish a B+ tree; the B+ tree is used to index the key-value pair data stored in the storage-computing integrated system;
[0028] In each node of the B+ tree, the key is sequentially mapped to a computational mode array group, and the value is sequentially mapped to half of the storage mode array group; the key and value have the same offset in the corresponding array group;
[0029] In the B+ tree, nodes are deployed sequentially to the idle array groups of the array cluster, and the connection between nodes is realized using array group address pointers.
[0030] Furthermore, the index controller is also used to perform a routing operation; the routing operation is used to route from the root node of the B+ tree to a leaf node storing the target key or the first larger value of the target key according to the target key; the routing operation includes:
[0031] R1: Initialize the current node as the root node;
[0032] R2: If the current node is a leaf node, then go to R3; otherwise, perform the in-place first larger value search operation to obtain the first larger value in the current node that is greater than the target key, take the node pointed to by the corresponding child node pointer as the new current node, and then go back to R2;
[0033] R3: Determine that the current leaf node is the leaf node that stores the target key or the first larger value of the target key, and the routing ends.
[0034] Furthermore, the index controller is also used to perform index operations; the index operations include: insert operations; the insert operation is used to insert new key-value pair data <k i ,v i >, the insert operation includes:
[0035] Find the stored key greater than k through the routing operation i The first leaf node L with a larger value i ;
[0036] Find the leaf node L by performing an in-place first larger value search operation i The mapped array group stores the keys greater than key k. i The first larger value and the corresponding value of the row are recorded as row l ki and line l vi ;
[0037] By moving the leaf node L i In the mapped array group, row l ki The keys stored in the following rows are moved back one row, leaving space for inserting key k i and change the row l vi The values stored in the following rows are moved back one row, leaving space for inserting the value v i row;
[0038] Press key k i Sum value v i Write the corresponding rows respectively and the insertion operation ends.
[0039] Furthermore, the index operation also includes: a search operation; the search operation is used to search for the key k s The corresponding value v s , the search operations include:
[0040] The key k is stored by the routing operation s The leaf node is denoted as leaf node L s ;
[0041] Find the leaf node L through in-situ equal value search operation s The mapped array group stores key k s and the corresponding value rows, respectively, are recorded as row l ks and l vs ;
[0042] For row l vs The row performs a row read operation and reads the value v s , the search operation ends.
[0043] Furthermore, the index operation also includes: a scan operation; the scan operation is used to find the key in the search range [k scd ,k scu ], the scanning operation includes:
[0044] T1: Find the key k stored through routing operation scd or greater than key k scdThe first leaf node with a larger value is denoted as leaf node L sc ;
[0045] T2: Find the leaf node L through in-situ equal value search operation sc The mapped array group stores key k scd The rows of the corresponding values are recorded as rows l kscd and line l vscu ; If the search is successful, go to T3; otherwise, go to T4;
[0046] T3: Read row l through row read operation vscu Start, key is at [k scd ,k scu ], the scanning operation ends;
[0047] T4: Find the leaf node L through the in-place first larger value search operation sc The mapped array group stores the keys greater than key k. scd The first larger value and the corresponding value of the row are recorded as row l kscd ' and line l vscu ', read row l through row read operation vscu Start, key is at [k scd ,k scu ] and the scanning operation ends.
[0048] Furthermore, the index operation also includes: an update operation; the update operation is used to update the key-value pair data <k u ,v u >Updated to <k u ,v u '>, the update operation includes:
[0049] The key k is stored by the routing operation u The leaf node is denoted as leaf node L u ;
[0050] Find the leaf node L through in-situ equal value search operation u The mapped array group stores key k u and value v u The rows are recorded as rows l ku and line l vu ;
[0051] The value v is written by a row write operation u 'Write line l vu , the update operation is completed.
[0052] Furthermore, the index operation also includes: a delete operation; the delete operation is used to delete the key-value pair data <k d,v d >, the deletion operations include:
[0053] The key k is stored by the routing operation d The leaf node is denoted as leaf node L d ;
[0054] Find the leaf node L through in-situ equal value search operation d The mapped array group stores key k d Sum value v d The rows are recorded as rows l kd and line l vd ;
[0055] Delete row l through row deletion operation kd and line l vd The data in the file is deleted and the deletion operation is completed.
[0056] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects:
[0057] (1) The storage and computing integrated memory system provided by the present invention utilizes the in-situ parallel data comparison function (i.e., content addressable function) of the cross-point array of the resistive memory to realize in-situ parallel equal value search in the memory, and based on the equal value search, realizes in-situ first larger value search in the memory. During the search process, there is no need to read data from the memory to the CPU, nor is there any need to perform data comparison in the CPU. At the same time, multiple rows of data can be searched in parallel, which greatly improves the search efficiency. Searching for items in a node that are equal to and the first item that is greater than the target is a key operation of the B+ tree index. The present invention can support efficient indexing of the B+ tree by realizing in-situ equal value search and in-situ first larger value search.
[0058] (2) The key-value storage system based on B+ tree index provided by the present invention utilizes a storage-computing integrated memory system to store key-value pair data, and maps the B+ tree index structure to the storage-computing integrated memory system. Due to the parallelism of the underlying hardware and the fact that the storage-computing integrated memory system can support in-situ equal value search and in-situ first largest value search, the time complexity of the equal value search of a node in the B+ tree is reduced to O(1); the time complexity of the largest value search is reduced to O(logN), where N is the number of data bits. The two work together to greatly improve the search efficiency of the B+ tree nodes, thereby effectively improving the storage performance of the key-value storage system. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 A schematic diagram of an existing resistive memory and a cross-point array structure formed by the resistive memory;
[0060] Figure 2A structural diagram of a storage-computing integrated memory system provided in an embodiment of the present invention;
[0061] Figure 3 Schematic diagram of array operation provided by an embodiment of the present invention; wherein (a) is a schematic diagram of a row read operation, and (b) is a schematic diagram of an in-situ equal value search operation;
[0062] Figure 4 The pseudo code of the in-situ first larger value search operation provided by the embodiment of the present invention;
[0063] Figure 5 A relative position diagram of the closest item (longest prefix matching item), target, and final result in the first larger value algorithm provided in an embodiment of the present invention;
[0064] Figure 6 An example diagram of an in-situ first largest value search operation provided by an embodiment of the present invention; wherein (a) to (f) are schematic diagrams of various steps in the in-situ first largest value search operation process;
[0065] Figure 7 A schematic diagram of a B+ tree data item and tree node mapping solution provided by an embodiment of the present invention;
[0066] Figure 8 A schematic diagram of the overall mapping solution of the B+ tree provided by an embodiment of the present invention;
[0067] Fig. 9 Pseudo code of the B+ tree leaf node splitting algorithm provided in the embodiment of the present invention. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0069] In the present invention, the terms "first", "second", etc. (if any) in the present invention and the accompanying drawings are used to distinguish similar objects but not necessarily to describe a specific order or sequence.
[0070] B+Tree consists of a large number of nodes, including internal nodes and leaf nodes. When used to index key-value data, leaf nodes store key-value pairs, and internal nodes store auxiliary values for auxiliary searches. Auxiliary values and key-value pairs are stored in the lexicographic order of the keys to support range queries. The degree of an internal node is M, which contains M keys for indexing and M+1 child node pointers for jumping and eventually finding a leaf node; the degree of a leaf node is K, that is, each leaf node contains K pointers to key-value data and 1 pointer to the next leaf node. When inserting key-value pairs, if the number of leaf nodes reaches the threshold, the leaf node will be split, a new leaf node will be created, and the key of the middle size will be selected as the auxiliary value. All key-value pairs larger than the auxiliary value will be migrated to the new leaf node, and those smaller than the auxiliary value will be retained in the original leaf node. The node splitting starts from the leaf node, and the auxiliary value is added to its parent node. The parent node is an internal node. If the number of keys exceeds the threshold, the splitting process will continue upward until the splitting condition is no longer met. When the parent node does not exist, a new parent node is created, thereby increasing the height of the B+Tree. The search process of the B+Tree starts from the root node and selects its child nodes according to the size of the auxiliary values stored in the internal nodes until a leaf node is found. The time complexity is O(logN), where N is the number of key-value pairs in the B+Tree.
[0071] It can be seen that the indexing process of the B+ tree requires a large number of search and data movement operations, which causes a large amount of memory access and reduces the efficiency of the indexing operation.
[0072] In order to solve the technical problem that the existing indexing methods for key-value pair data will cause frequent comparison and memory access, resulting in a decrease in the efficiency of indexing operations, the present invention provides a storage-computing integrated indexing system and a key-value pair storage system. The overall idea is to design and implement in-situ equal value search and in-situ first larger value search based on the characteristics of B+ tree index operations on the basis of a crosspoint array constructed based on a content-addressable memory based on ReRAM (resistance random access memories), and to realize data movement in memory, thereby reducing data movement between a computer (CPU) and a memory (storage-computing integrated memory). The parallel search provided by the crosspoint array structure improves parallelism, thereby improving the performance of the indexing system.
[0073] Before explaining the technical solution of the present invention in detail, the resistive memory cell and the cross-point array structure composed of the resistive memory cell and the cross-point array structure are briefly introduced as follows.
[0074] The structure of the resistive memory cell is as follows Figure 1As shown in the figure, its basic structure consists of a resistive material, a top electrode, and a bottom electrode. The resistive material can be a metal oxide, etc., and its resistance can be reversibly converted between a high resistance state and a low resistance state under the action of an external electric field to complete the writing of data. By applying a small voltage, the outflowing current or the converted voltage can be measured without changing the cell state to complete the data reading. Usually, the high resistance state of the resistive memory cell is defined as data 0, and the low resistance state is defined as data 1.
[0075] The cross-point array composed of resistive memory cells is as follows Figure 1 As shown, a calculation voltage can be applied to the word line (row) of the array, and the matrix-vector multiplication operation result between the input calculation voltage vector and the conductivity matrix stored in the array can be obtained by reading the current flowing out of the bit line (column). The realized matrix-vector multiplication operation complexity is only O(1), so it is widely used to accelerate neural networks, graph computing and other applications dominated by matrix-vector multiplication. The crosspoint array can work in two working modes, namely, calculation mode and storage mode; in the calculation mode, the left and right resistive memory cells are used to form a content addressable unit to store one bit of data. At this time, the crosspoint array can also realize parallel data equivalent operation. This parallel data comparison function is also called content addressable function. Through the content addressable function, the row where the data stored in the array is the same as the input data can be determined. Specifically, the left and right resistive memories are named R and RB respectively, the corresponding two bit lines are SL and SLB, and the common row line is ML. The left resistive memory cell (R) stores data, and the right cell (RB) stores its inverted value.
[0076] Table 1 Content addressing
[0077] Cell Value R RB Search Target SL SLB ML result 1 Low impedance High impedance 1 0 Vsrc ≈0 match 1 Low impedance High impedance 0 Vsrc 0 >Vref Mismatch 0 High impedance Low impedance 1 0 Vsrc >Vref Mismatch 0 High impedance Low impedance 0 Vsrc 0 ≈0 match
[0078] Table 1 shows a truth table of data to content addressable unit, search target to array input, and array output to search result in a content addressable unit. Among them, Vsrc represents the search voltage and Vref represents the reference voltage. When performing an in-situ equal value search operation, the search voltage Vsrc is input from the lower end of the unit to one of the bit lines according to the target value, and the search result is judged according to the row line voltage. If it does not exceed the reference voltage Vref, the search is successful, otherwise it fails. When the target value is 0 and 1, the voltage is input to the left (SL) and right (SLB) bit lines respectively. If the stored data is the same as the target value, the resistive memory cell connected to the bit line of the input voltage will be in a high-resistance state, blocking the voltage from leaking to the row line, and the row line will not change significantly; otherwise, if there is a mismatch, the resistive memory cell will be in a low-resistance state, and the search voltage will leak to the row line, causing the row line voltage to rise.
[0079] In storage mode, one resistive memory cell stores one bit of data.
[0080] The following are examples.
[0081] Embodiment 1:
[0082] A storage and computing integrated memory system, such as Figure 2 As shown, it is a three-layer structure: array cluster, array group, array. The array is a cross-point array composed of resistive memory cells; multiple arrays form an array group, the arrays in the array group can be activated at the same time, and the array group has a computing mode and a storage mode; multiple array groups form an array cluster.
[0083] like Figure 2 As shown, corresponding to the multiple array clusters, this embodiment also includes multiple array cluster controllers. Each array cluster is controlled by a cluster controller through peripheral devices to control all array groups so that the array groups support array operations. Figure 2 As shown, the peripheral device includes a row selector, a read driver, a read sense amplifier, a search driver, and a search sense amplifier. Among them, the row selector is connected to the word line to select the row to be operated; the read driver is connected to the word line to generate a voltage to activate the resistive memory unit on the word line; the read sense amplifier is connected to the bit line to detect whether the voltage on the bit line exceeds the corresponding threshold and output the result, thereby reading out the data stored in the activated row; the search driver is connected to the word line to generate a voltage to activate the resistive memory unit on the bit line; the search sense amplifier is connected to the word line to detect whether the voltage on the word line exceeds the threshold and output the result, thereby searching out the row matching the data to be searched.
[0084] Based on the above architecture, conventional read and write operations can be implemented within the array group. Specifically, the row read operation is as follows: Figure 3 As shown in (a) of the above, it specifically includes:
[0085] A voltage is applied to the word line of the row to be read by a read driver to activate all cells of the row to be read; the row to be read is selected by a row selector;
[0086] The voltage outputted by each bit line is sensed by a read sense amplifier, so as to read the data stored in the row to be read;
[0087] A row write operation includes:
[0088] A voltage matching the data to be written is applied to the bit line to activate all cells in the row to be written, thereby writing the data to be written; the row to be written is selected by a row selector.
[0089] Based on the above row read operation and row write operation, this embodiment can implement a row delete operation by writing a valid bit, and implement data movement within a cluster through one row read operation and one row write operation. Specifically, the row delete operation includes:
[0090] A valid bit indicating that the data in the row is invalid is written to the row to be deleted through a row write operation, and the deletion operation ends; the row to be deleted is selected by a row selector;
[0091] Intra-cluster move operations are used to move data from source rows to target rows. Intra-cluster move operations include:
[0092] The data in the source row is read out through a row read operation; during the reading process, the source row is selected by a row selector;
[0093] The read data is written into the target row through the row write operation, and the intra-cluster move operation is completed; the write process is completed, and the target row is selected by the row selector.
[0094] Since equal value search and first larger value search are key operations in the B+ tree indexing process, if the execution efficiency of these two search operations can be effectively improved, the indexing operation efficiency of the B+ tree can be effectively improved, thereby improving the storage performance of the key-value storage system. It is easy to understand that the first larger value is the first value greater than the target. Based on this consideration, this embodiment further utilizes the feature of the array group in the computing mode supporting parallel data comparison function in the storage and computing integrated memory system, and implements in-situ equal value search and in-situ first larger value search operations for the array group in the computing mode.
[0095] like Figure 3 As shown in (b) in FIG. 1 , the in-situ equal value search operation includes:
[0096] A voltage matching the data to be searched is applied to the bit line by the search driver to activate all cells in the selected row; in the in-situ equal value search operation, the selected row can be one row or multiple rows, which are also selected by the row selector; the specific method of applying the voltage to the bit line of the selected row can be referred to Table 1;
[0097] The word line voltage output by each selected row is sensed by a search sense amplifier to search for rows storing data matching the data to be searched. Referring to Table 1, if the sensed word line voltage is approximately 0 (less than the reference voltage), it indicates that the data stored in the corresponding row matches the data to be searched.
[0098] Due to the parallelism of the underlying hardware, the search for multiple rows of data can be performed in parallel, and the time complexity of the above in-situ equal search operation is O(1).
[0099] The array natively only supports equal value comparison. The in-situ first larger value search operation provided by this embodiment is proposed based on the in-situ equal value search operation, and the array group is not only in calculation mode, but also the rows of data need to be stored in order. The process of the in-situ first larger value search operation can be divided into two stages. In the first stage, the partial rows closest to the data to be searched are found, and then the first larger value greater than the data to be searched is found with the help of these rows. For the search in the first stage, this embodiment takes into account that in binary numbers, the more high-order matching bits there are, the closer the numbers are. Therefore, the closest item is found by performing an equal value search with the target starting from the highest bit, excluding unmatched items until no match is found. This process uses several in-situ equal value search operations and binary searches to implement and accelerate this process.
[0100] The in-place first larger value search operation can be used Figure 4 The pseudo code shown is described at the algorithm level. Lines 3 to 10 describe the process of finding the closest value. First, initialize the pointer of the binary search and the vector used to record the items involved in the search. The left pointer and the right pointer point to the first column (i.e., the highest bit) and the last column (i.e., the lowest bit) of the item respectively. The middle pointer is located between the two. The pointers are stored and maintained in the array cluster controller; all items are added to the vector at the beginning. The vector is implemented by a row selector, which is initialized to all "1" accordingly, and is set to "0" accordingly when deleted. Then, perform equal value search operations cyclically between the left pointer and the middle pointer of the items in the vector, and perform different processing according to the number of matching items (m_row):
[0101] (1) If m_row = 0, there is no match, such as Figure 4 As shown in lines 6-7 in , keep the vector unchanged, move the right pointer to the middle, and continue searching for matching prefixes in a narrower range;
[0102] (2) If m_row>0, it means there is a match, such as Figure 4 As shown in 8 to 10 in , remove the unmatched items from the vector, move the left pointer to the middle, and continue searching for the matching prefix in a wider range;
[0103] The termination condition of the loop is that the left pointer and the right pointer converge (point to the same column). The items that have not been removed are the items closest to the target because they have the longest common prefix. This completes the first stage of the search and finds the row close to the data to be searched, that is, the row with the longest common prefix with the data to be searched.
[0104] Combined with the order of the internal keys of the B+ tree nodes, the final result is selected from the rows close to the data to be searched in the first stage. Figure 4 Lines 11 to 14 in .
[0105] Figure 5 It shows the relative positional relationship of the target, the closest item obtained in the previous step, and the final result in the node. Since the closest item has the same longest prefix as the target, due to the characteristics of binary data, these closest items are either all greater than the target or all less than the target. Considering the orderliness of the items in the B+ tree node, they are all located on the left or right side of the target. Therefore, the final result needs to be determined based on the size relationship between the target and the items, and this size relationship can be determined by the first bit (bit first ) after the longest common prefix in the searchable data. Specifically:
[0106] (1) If bit first = 1, it indicates that the closest items are all less than the target, and the final result is the next item after the last item among the closest items;
[0107] (2) If bit first = 0, it indicates that the closest items are all greater than the target, and the final result is the minimum value (the first one) among the closest items.
[0108] Based on the above analysis, it can be known that in this embodiment, the in-situ first larger value search operation includes:
[0109] S1: Initialize left as the highest bit line number and right as the lowest bit line number;
[0110] S2: If left < right, then set mid = (left + right) / 2; otherwise, go to S5;
[0111] S3: Search for the rows in the stored data whose left to mid bits match the left to mid bits of the data to be searched through the in-situ equal value search operation, and eliminate the unmatched rows. At the same time, use the left to mid bits in the data to be searched as the common prefix;
[0112] S4: If the remaining number of rows is 0, then update right according to right = mid; otherwise, update left according to left = mid + 1, and then go to S2;
[0113] S5: After concatenating all the common prefixes in order to form the longest common prefix, if the next bit after the longest common prefix in the data to be searched is 0, then determine the data stored in the first row among the remaining rows as the first larger value; otherwise, determine the data stored in the next row after the last row among the remaining rows as the first larger value.
[0114] Figure 6The figure shows an example of executing an in-situ first larger value search operation, which is used to search for the first item greater than or equal to 38 in [14,32,36,37,42,57]. Among them, steps 1 to 5 shown in (a) to (e) are the first stage search, which are used to find the closest item to 38, and step 6 shown in (f) is the second stage search, which is used to find the first value greater than 38 from the closest item. Figure 6 The specific search process is as follows: First, initialize three pointers and a vector (row selector) in step 1. Then, perform an in-situ equal search operation on the selected rows between the left pointer and the middle pointer in a loop. In steps 2 and 4, since the matching item > 0, the unmatched items are deleted and the left pointer is moved to the middle; in step 3, since the matching item = 0, all items are retained and the right pointer is moved to the middle. In step 5, since the left and right pointers converge, the loop is terminated, and the remaining items ([36, 37]) are the longest prefix matching (1001) data and the data closest to the target, ending the first stage of the search. Figure 6 In the figure, since the first bit after the longest common prefix of the data to be searched 38 is "1", the closest items are all smaller than the data to be searched 38 and are on its left. Therefore, the final result is the next item of the last item in the closest items, that is, 42.
[0115] In this embodiment, the in-situ first larger value search operation implements the first larger value search through several in-situ equal value search operations, and the time complexity is O(logN), where N is the number of bits in the data to be searched.
[0116] In general, the storage and computing integrated memory system provided by this embodiment utilizes the parallel data comparison function (i.e., content addressable function) of the cross-point array of the resistive memory to realize in-situ equal value search in the memory, and on the basis of the in-situ equal value search, realizes the in-situ first larger value search in the memory. During the search process, there is no need to read the data from the memory to the CPU, nor is there any need to perform data comparison in the CPU. At the same time, multiple rows of data can be searched in parallel, which greatly improves the search efficiency. Searching for items in a node that are equal to and greater than the target is a key operation of the B+ tree index. This embodiment can support efficient indexing of the B+ tree by realizing in-situ equal value search and in-situ first larger value search.
[0117] Embodiment 2:
[0118] A key-value storage system based on B+ tree index includes: the storage-computing integrated system and index controller provided in the above-mentioned embodiment 1; the storage-computing integrated system is used to store key-value pair data; the index controller is used to establish a B+ tree; the B+ tree is used to index the key-value pair data stored in the storage-computing integrated system.
[0119] In this embodiment, the mapping scheme of mapping the B+ tree to the storage and computing integrated system is divided into three levels: data item mapping, tree node mapping, and tree mapping. Among them, the data item mapping and the tree node mapping are as follows: Figure 7 As shown, the tree mapping is Figure 8 The details are as follows:
[0120] In each node of the B+ tree, the keys therein are sequentially mapped to a computing mode array group, and the values therein are sequentially mapped to half of the storage mode array group; the keys and values have the same offset in the corresponding array group, which facilitates the rapid reading of the value data after locating the address of the key; for array groups of the same size, the storage capacity in the computing mode is half of the storage capacity in the storage mode. In order to support index operations, calculation, comparison and other operations need to be performed on the keys, but not on the values. In this embodiment, the keys in the B+ tree nodes are mapped to a computing mode array group, and the values are mapped to half of the storage mode array group, which can improve the utilization rate of the array storage space while ensuring efficient and complete key-value indexing operations;
[0121] In the B+ tree, nodes are deployed sequentially to the idle array groups of the array cluster, and the connection between nodes is realized using array group address pointers.
[0122] B+ tree operations are all routing (searching) processes starting from the root node to the leaf node. The process is divided into two stages: internal nodes and leaf nodes. All operations are performed in the same process in the internal node, finding the first key greater than or equal to the target value and obtaining the address of the next layer of nodes (stored in the value). In the leaf node, insert and search operations need to search for the first key greater than or equal to the target value, and search, update and delete operations need to search for the key equal to the target value. If the target is found, the corresponding operation is performed.
[0123] Accordingly, in this embodiment, the index controller is also used to perform routing operations and indexing operations.
[0124] The routing operation is used to route from the root node of the B+ tree to the leaf node storing the target key or the first larger value of the target key according to the target key; the routing operation includes:
[0125] R1: Initialize the current node as the root node;
[0126] R2: If the current node is a leaf node, then go to R3; otherwise, perform the in-place first larger value search operation to obtain the first larger value in the current node that is greater than the target key, take the node pointed to by the corresponding child node pointer as the new current node, and then go back to R2;
[0127] R3: Determine that the current leaf node is the leaf node that stores the target key or the first larger value of the target key, and the routing ends.
[0128] Index operations include: insert operations; insert operations are used to insert new key-value pair data <k i ,v i >, the insert operation includes:
[0129] Find the stored key greater than k through the routing operation i The first leaf node L with a larger value i ;
[0130] Find the leaf node L by performing an in-place first larger value search operation i The mapped array group stores the keys greater than key k. i The first larger value and the corresponding value of the row are recorded as row l ki and line l vi ;
[0131] By moving the leaf node L i In the mapped array group, row l ki The keys stored in the following rows are moved back one row, leaving space for inserting key k i and change the row l vi The values stored in the following rows are moved back one row, leaving space for inserting the value v i row;
[0132] Press key k i Sum value v i Write the corresponding rows respectively and the insertion operation ends.
[0133] Index operations also include: search operations; search operations are used to find key k s The corresponding value v s , the search operations include:
[0134] The key k is stored by the routing operation s The leaf node is denoted as leaf node L s ;
[0135] Find the leaf node L through in-situ equal value search operation s The mapped array group stores key k s and the corresponding value rows are recorded as row l ks and l vs ;
[0136] For row l vs The row performs a row read operation and reads the value v s , the search operation ends.
[0137] Index operations also include: Scan operations; Scan operations are used to find keys within the search range [k scd ,k scu], the scanning operation includes:
[0138] T1: Find the key k stored through routing operation scd or greater than key k scd The first leaf node with a larger value is denoted as leaf node L sc ;
[0139] T2: Find the leaf node L through in-situ equal value search operation sc The mapped array group stores key k scd The rows of the corresponding values are recorded as rows l kscd and line l vscu ; If the search is successful, go to T3; otherwise, go to T4;
[0140] T3: Read row l through row read operation vscu Start, key is at [k scd ,k scu ], the scanning operation ends;
[0141] T4: Find the leaf node L through the in-place first larger value search operation sc The mapped array group stores the keys greater than key k. scd The first larger value and the corresponding value of the row are recorded as row l kscd ' and line l vscu ', read row l through row read operation vscu Start, key is at [k scd ,k scu ] and the scanning operation ends.
[0142] Index operations also include: update operations; update operations are used to update key-value pairs of data <k u ,v u >Updated to <k u ,v u '>, the update operation includes:
[0143] The key k is stored by the routing operation u The leaf node is denoted as leaf node L u ;
[0144] Find the leaf node L through in-situ equal value search operation u The mapped array group stores key k u and value v u The rows are recorded as rows l ku and line l vu ;
[0145] The value v is written by a row write operation u 'Write line lvu , the update operation is completed.
[0146] Index operations also include: delete operations; delete operations are used to delete key-value pair data <k d ,v d >, the deletion operations include:
[0147] The key k is stored by the routing operation d The leaf node is denoted as leaf node L d ;
[0148] Find the leaf node L through in-situ equal value search operation d The mapped array group stores key k d Sum value v d The rows are recorded as rows l kd and line l vd ;
[0149] Delete row l through row deletion operation kd and line l vd The data in the deletion operation is completed.
[0150] According to the needs of B+ tree index, this embodiment adds a dedicated instruction set to the CPU for controlling the storage and computing integrated memory system, which is used to implement B+ tree mapping and indexing operations. The instructions will be decoded into one or more array operations in the general control unit and sent to the corresponding array cluster. The array operation corresponding to the instruction can be customized; this embodiment adds storage space application, storage space release, read, write, delete, in-situ equal value search, in-situ first larger value search, and data movement commands to the B+ tree index, where the data movement operation will be classified into intra-cluster and inter-cluster data movement during decoding; storage space application and storage space release commands are completed by the general control unit; inter-cluster data movement is finally decoded into an array cluster read operation and an array cluster write operation; other instructions correspond to a corresponding array cluster operation. The details are shown in Table 2.
[0151] Table 2 Instruction set
[0152]
[0153] Among them, HMEM is the array group address, including the array cluster and array group id; ROW is the row number, that is, the offset of the target row in the array group; KEY, VALUE are the key-value pairs of the key-value index; TARGET is the search operation target; NUM is the number of rows operated.
[0154] The corresponding indexing operation can be implemented by calling the instructions in Table 2. The pim_matching_search and pim_larger_search instructions can be used to perform in-place equal value search and in-place first larger value search operations, with time complexities of O(1) and O(logN) respectively, where N is the number of data bits.
[0155] The creation and deletion of nodes are implemented by pim_node_malloc() and pim_node_free(). In the insertion and deletion operations, when a node is full and empty, it needs to be split and merged. The splitting process of leaf nodes can be used Fig. 9 The pseudo code shown is described at the algorithm level. The process is as follows:
[0156] 1) Line 1: Apply for storage space for the new node;
[0157] 2) Lines 4-5, 9-10: Move the second half of the key-value pairs of the current node to the new node, and reserve space for the new key-value pairs based on the search results obtained from the equal value search (that is, the insertion position of the new key-value pairs, the row offset);
[0158] 3) Lines 6-7, 11-12: Write the new key-value pair to the target location;
[0159] 4) Line 13: Add the next leaf node pointer to the current node.
[0160] The internal node splitting process is similar to the leaf node, except that the in-place equal value search operation is changed to an in-place first larger value search operation, and the last pointer points to the right subtree. The merging process is similar to splitting, changing allocation and insertion to release and deletion.
[0161] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A storage and computing integrated memory system, comprising: Multiple array clusters and corresponding multiple array cluster controllers; Each of the array clusters includes multiple array groups; Each of the array groups includes multiple arrays, and each of the array groups has a computing mode and a storage mode; each of the arrays is a cross-point array composed of resistive memory cells; the array cluster controller is used to control the array groups within the corresponding array cluster to enable the array groups to support array operations; characterized in that: If an array group is in the computing mode, then the array operation includes an in-situ equal-value search operation; the in-situ equal-value search operation includes: applying a voltage matching the data to be searched to the bit lines to activate all the cells in the selected rows; sensing the word line voltages output by each of the selected rows to search for the rows storing the data matching the data to be searched; If an array group is in the computing mode and the data in each row is stored in an orderly manner, then the array operation further includes an in-situ first larger value search operation; the in-situ first larger value search operation includes: S1: Initialize left as the serial number of the highest-order bit line and right as the serial number of the lowest-order bit line; S2: If left < right, then set mid = (left + right) / 2; otherwise, go to S5; S3: Through the in-situ equal-value search operation, search for the rows in which the data stored in the left to mid bits matches the left to mid bits of the data to be searched, and eliminate the non-matching rows, and at the same time use the left to mid bits in the data to be searched as the common prefix; S4: If the remaining number of rows is 0, then update right according to right = mid, otherwise, update left according to left = mid + 1, and then go to S2; S5: After concatenating all the common prefixes in sequence to form the longest common prefix, if the next bit after the longest common prefix in the data to be searched is 0, then determine that the data stored in the first row among the remaining rows is the first larger value; otherwise, determine that the data stored in the next row after the last row among the remaining rows is the first larger value.
2. The storage and computing integrated memory system according to claim 1, characterized in that: The array operation further includes: a row read operation and a row write operation; The row read operation includes: Applying a voltage to the word line where the row to be read is located to activate all the cells in the row to be read; Sensing the voltage results output by each of the bit lines to implement the reading of the data stored in the row to be read; The row write operation includes: Applying a voltage matching the data to be written to the bit lines to activate all the cells in the row to be written, to implement the writing of the data to be written.
3. The storage and computing integrated memory system as claimed in claim 2, characterized in that: The array operation further includes: a row deletion operation and an intra-cluster movement operation; The row deletion operation includes: Writing a valid bit indicating the invalidity of the data within the row to the row to be deleted through the row write operation, and the deletion operation ends; The intra-cluster movement operation is used to move the data in the source row to the target row, and the intra-cluster movement operation includes: Reading out the data in the source row through the row read operation; Writing the read data to the target row through the row write operation, and the intra-cluster movement operation ends.
4. A key-value storage system based on B+ tree index, characterized in that: Including: The computing-in-memory system and the index controller according to claim 3; the computing-in-memory system is used to store key-value pair data; the index controller is used to establish a B+ tree; the B+ tree is used to index the key-value pair data stored in the computing-in-memory system; In each node of the B+ tree, the key is sequentially mapped to a calculation mode array group, and the value is sequentially mapped to half of the storage mode array group, and the offset of the key and the value in the corresponding array group is the same; The nodes in the B+ tree are sequentially deployed on the idle array groups of the array cluster, and the connection between the nodes is realized using the array group address pointer.
5. The key-value storage system based on B+ tree index according to claim 4, characterized in that: The index controller is further used to perform a routing operation; the routing operation is used to route from the root node of the B+ tree to a leaf node storing the target key or the first larger value of the target key according to the target key; the routing operation includes: R1: Initialize the current node as the root node; R2: If the current node is a leaf node, then go to R3; otherwise, perform the in-situ first larger value search operation to obtain the first larger value in the current node that is greater than the target key, take the node pointed to by the corresponding child node pointer as the new current node, and re-enter R2; R3: Determine that the current leaf node is the leaf node that stores the target key or the first larger value of the target key, and the routing ends.
6. The key-value storage system based on B+ tree index according to claim 5, characterized in that: The index controller is also used to perform index operations; the index operations include: insert operations; the insert operations are used to insert new key-value pair data <k i ,v i >, the insertion operation includes: The routing operation searches for stored keys greater than key k i The first leaf node L with a larger value i ; Find the leaf node L by performing the in-place first larger value search operation i The mapped array group stores the keys greater than key k. i The first larger value and the corresponding value of the row are recorded as row l ki and line l vi ; The leaf node L is moved by the intra-cluster movement operation. i In the mapped array group, row l ki The keys stored in the following rows are moved back one row, leaving space for inserting key k i and change the row l vi The values stored in the following rows are moved back one row, leaving space for inserting the value v i row; Press key k i Sum value v i Write the corresponding rows respectively and the insertion operation ends.
7. The key-value storage system based on B+ tree index according to claim 6, characterized in that: The index operation also includes: a search operation; the search operation is used to search for the key k s The corresponding value v s , the search operation includes: The routing operation searches for the key k stored s The leaf node is denoted as leaf node L s ; Find the leaf node L through the in-situ equal value search operation s The mapped array group stores key k s and the corresponding value rows, respectively, are recorded as row l ks and l vs ; For row l vs The row read operation is performed and the value v is read s , the search operation ends.
8. The key-value storage system based on B+ tree index according to any one of claims 5 to 7, characterized in that: The index operation also includes: a scanning operation; the scanning operation is used to find the key in the search range [k scd ,k scu ], the scanning operation includes: T1: Find the key k stored through the routing operation scd or greater than key k scd The first leaf node with a larger value is denoted as leaf node L sc ; T2: Find the leaf node L through the in-situ equal value search operation sc The mapped array group stores key k scd The rows of the corresponding values are recorded as rows l kscd and line l vscu ; If the search is successful, go to T3; otherwise, go to T4; T3: Read row l through the row read operation vscu Start, key is at [k scd ,k scu ], the scanning operation ends; T4: Find the leaf node L through the in-situ first larger value search operation sc The mapped array group stores the keys greater than key k. scd The first larger value and the corresponding value of the row are recorded as row l kscd ' and line l vscu ', read row l through the row read operation vscu Start, key is at [k scd ,k scu ] and the scanning operation ends.
9. The key-value storage system based on B+ tree index according to any one of claims 5 to 7, characterized in that: The index operation also includes: an update operation; the update operation is used to update the key-value pair data <k u ,v u >Updated to <k u ,v u '>, the update operation includes: The routing operation searches for the key k stored u The leaf node is denoted as leaf node L u ; Find the leaf node L through the in-situ equal value search operation u The mapped array group stores key k u and value v u The rows are recorded as rows l ku and line l vu ; The row write operation sets the value v u 'Write line l vu , the update operation is completed.
10. The key-value storage system based on B+ tree index according to any one of claims 5 to 7, characterized in that: The index operation also includes: a delete operation; the delete operation is used to delete the key-value pair data <k d ,v d >, the deletion operation includes: The routing operation searches for the key k stored d The leaf node is denoted as leaf node L d ; Find the leaf node L through the in-situ equal value search operation d The mapped array group stores key k d Sum value v d The rows are recorded as rows l kd and line l vd ; Delete row l by the row deletion operation kd and line l vd The data in the storage medium is deleted, and the deletion operation is completed.
Citation Information
Patent Citations
Index tree construction method and system for key value storage system
CN110083601A
Non-volatile SRAM (Static Random Access Memory) in-memory calculation circuit, array and method based on memristor
CN117079687A
Storage and calculation integrated index system and key value pair storage system
CN117539408A
Storage and calculation integrated array and storage and calculation integrated device
CN117894360A
Storage and calculation integrated circuit, chip and electronic equipment
CN118072788A