Memory system integrated with storage and calculation and key value storage system based on b+ tree index
By introducing a storage and computing integrated memory system into the key-value storage system and using a resistive memory cross-point array to implement in-situ equal value and in-situ first largest value search, the problem of low efficiency of B+ tree indexing is solved and storage performance is improved.
Patent Information
- Application Number
- CN202411226505.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2025-10-14
- Estimated Expiration
- 2044-09-03
AI Technical Summary
In existing key-value storage systems, B+ tree indexing operations require multiple rounds of searching and accessing, which reduces indexing efficiency and affects storage performance.
A storage and computing integrated memory system is adopted, and a resistive random access memory cross-point array is used to implement in-situ equal value search and in-situ first largest value search, reducing data access and comparison operations and improving search parallelism.
It reduces the search complexity of B+ tree indexes and improves the storage performance of key-value storage systems, especially the search efficiency of B+ tree nodes.
Smart Images

Figure CN119336698B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the intersection 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 stores allow applications to store unformatted data, eliminating the need for fixed data models and reducing the need for data formatting. They are widely used in high-performance, low-latency, scalable, and highly concurrent applications. In a key-value store, each data item consists of a unique key and an associated value. Due to this structure, key-value store operations require data indexing to quickly insert, query, update, and delete the value corresponding to a given key.
[0003] Various data structures are used to accelerate data indexing, typically tree indexes and hash indexes. B+ trees are an important and typical tree index structure, widely used in databases and data-intensive systems. The B+ tree indexing process requires traversing multiple layers of nodes within the tree, resulting in a search time complexity of O(logN), where N is the amount of data stored. This process requires numerous search and access operations, resulting in reduced indexing efficiency and impacting the storage performance of key-value storage systems.
[0004] At present, some researchers have proposed new index structures such as learning index, but the index structure is usually organized in 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 existing technology 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. Its 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 objectives, according to one aspect of the present invention, a storage and computing integrated memory system is provided, comprising: a plurality of array clusters and corresponding plurality of array cluster controllers; the array clusters comprising a plurality of array groups; the array groups comprising a plurality of arrays, each array group having a computing mode and a storage mode; the arrays being cross-point arrays composed of resistive memory cells; the array cluster controllers being configured to control the array groups within 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 line to activate all cells in the selected row; sensing the word line voltage output by each selected row to search for a row storing data matching the data to be searched;
[0009] If the array group is in calculation mode and the rows of data are stored in order, the array operation also includes an in-place first largest value search operation; the in-place first largest value search operation includes:
[0010] S1: Initialize left as the highest bit line number and right as the lowest bit line number;
[0011] S2: If left <right,则设置mid=(left+right) / 2;否则,转入S5;
[0012] S3: Search the rows whose left to mid bits of the stored data match the left to mid bits of the data to be searched through an in-situ equal search operation, and remove the rows that do not match, while taking the left to mid bits of the data to be searched as a common prefix;
[0013] S4: If the number of remaining 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 all common prefixes are concatenated in order to form the longest common prefix, if the next digit of the longest common prefix in the data to be searched is 0, the data stored in the first row of the remaining rows is determined to be the first larger value; otherwise, the data stored in the next row of the last row of the remaining rows is determined to be the first larger value.
[0015] Furthermore, the array operation also includes: a row read operation and a row write operation;
[0016] Row read operations include:
[0017] Applying a voltage to the word line of the row to be read to activate all cells in the row to be read;
[0018] The voltage outputted by each bit line is sensed to read the data stored in the row to be read;
[0019] A row write operation includes:
[0020] 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.
[0021] Furthermore, array operations also include: row deletion operations and intra-cluster move operations;
[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 a source row to a target row. 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 storage-computing integrated system provided by the present invention and an index controller; 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] At each node of the B+ tree, the key is sequentially mapped to a computational pattern array group, and the value is sequentially mapped to half of a storage pattern array group; the key and value have the same offset in the corresponding array group;
[0029] In a B+ tree, nodes are sequentially deployed on idle array groups of an array cluster, and connections between nodes are implemented using array group address pointers.
[0030] Furthermore, the index controller is further configured to perform a routing operation; the routing operation is configured 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, set the node pointed to by the corresponding child node pointer as the new current node, and re-enter 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; index operations include: insert operations; insert operations are 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 routing operation i The first leaf node with the largest value L i ;
[0036] Find the leaf node L by performing an in-place first larger value search operation i The mapped array group stores the 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 to make room 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 the in-situ equal value search operation s The mapped array group stores the 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 stored key k through routing operation scd or greater than key k scdThe first leaf node with a larger value is recorded 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 the 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 located 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 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 located at [k scd ,k scu ], and the scanning operation ends.
[0048] Furthermore, the index operation also includes: update operation; update operation is used to update the key-value pair data <k u ,v u Updated to <k u ,v u '>, the update operations include:
[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 the in-situ equal value search operation u The mapped array group stores the 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 the 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 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 the in-situ equal value search operation d The mapped array group stores the key k d Sum value v d The rows are recorded as rows l kd and line l vd ;
[0055] Delete row l by 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 resistive random access memory crosspoint array to implement in-situ parallel equal value search in the memory. Based on the equal value search, an in-situ first largest value search is implemented 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, greatly improving search efficiency. Searching for items in a node that are equal to or greater than the target is a key operation in a B+ tree index. By implementing in-situ equal value search and in-situ first largest value search, the present invention can support efficient indexing of the B+ tree.
[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 switching memory and a cross-point array structure formed by the resistive switching memory;
[0060] Figure 2A structure diagram of a memory computing integrated memory system provided by an embodiment of the present application is provided.
[0061] Figure 3 An array operation schematic diagram provided by an embodiment of the present application is provided, wherein (a) is a row reading operation schematic diagram, and (b) is an in-place equivalent search operation schematic diagram.
[0062] Figure 4 Pseudo code of an in-place first larger value search operation provided by an embodiment of the present application is provided.
[0063] Figure 5 A relative position diagram of a closest item (longest prefix matching item), target and final result in a first larger value algorithm provided by an embodiment of the present application is provided.
[0064] Figure 6 An example diagram of an in-place first larger value search operation provided by an embodiment of the present application is provided, wherein (a)-(f) are schematic diagrams of each step in the in-place first larger value search operation process.
[0065] Figure 7 A B+ tree data item and tree node mapping scheme schematic diagram provided by an embodiment of the present application is provided.
[0066] Figure 8 A B+ tree overall mapping scheme schematic diagram provided by an embodiment of the present application is provided.
[0067] Figure 9 Pseudo code of a B+ tree leaf node splitting algorithm provided by an embodiment of the present application is provided. DETAILED DESCRIPTION
[0068] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application. In addition, the technical features involved in each embodiment of the present application described below can be combined with each other as long as there is no conflict.
[0069] In the present application, the terms "first", "second", etc. (if any) in the present application and the accompanying drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.
[0070] A B+Tree consists of a large number of nodes, either internal or leaf. When indexing key-value pairs, leaf nodes store key-value pairs, while internal nodes store auxiliary values to aid in lookups. Auxiliary values and key-value pairs are stored in lexicographic order by key to support range queries. An internal node has a degree of M, containing M keys for indexing and M+1 pointers to child nodes for navigating to leaf nodes. A leaf node has a degree of K, meaning each leaf node contains K pointers to key-value pairs and one pointer to the next leaf node. When inserting a key-value pair, if the number of leaf nodes reaches a threshold, the node is split and a new leaf node is created. A key with a middle value is selected as the auxiliary value. All key-value pairs larger than the auxiliary value are moved to the new leaf node, while those with a smaller value remain in the original leaf node. Node splitting begins at the leaf node, with the auxiliary value added to its parent node, which is an internal node. If the number of keys exceeds the threshold, the node is split upward until the split condition is no longer met. When a parent node does not exist, a new parent node is created, thereby increasing the height of the B+Tree. The search process of a 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] As you can see, the indexing process of the B+ tree requires a large number of search and data movement operations, which causes a large number of memory accesses and reduces the efficiency of the indexing operation.
[0072] In order to solve the technical problem that existing indexing methods for key-value pair data all lead to frequent comparisons and memory accesses, resulting in a decrease in indexing operation efficiency, 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 content-addressable memory such as ReRAM (resistance random access memories), and realize in-memory data movement, thereby reducing data movement between the computer (CPU) and the 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, a brief introduction to the resistive memory cell and the cross-point array structure composed thereof is given as follows.
[0074] The structure of the resistive memory cell is as follows Figure 1As shown, the basic structure consists of a resistive switching material, a top electrode, and a bottom electrode. The resistive switching material can be a metal oxide or the like, and its resistance can be reversibly switched between a high resistance state and a low resistance state under the action of an applied electric field, thereby completing data writing. Data reading can be completed by measuring the current flowing out or the converted voltage without changing the state of the cell by applying a small voltage. Generally, the high resistance state of the resistive random access memory cell is defined as data 0, and the low resistance state is defined as data 1.
[0075] A cross-point array of resistive random access memory cells is shown in FIG. 1. Figure 1 As shown, a calculation voltage can be applied to the array word line (row), and the result of the matrix-vector multiplication operation between the input calculation voltage vector and the conductance matrix stored in the array can be obtained by reading the current flowing out of the bit line (column). The complexity of the implemented matrix-vector multiplication operation is only O(1), so it is widely learned to accelerate neural networks, graph computing, and other applications dominated by matrix-vector multiplication. The cross-point array can work in two modes, namely a calculation mode and a storage mode; in the calculation mode, a content addressable cell stores one bit of data using a left and right resistive random access memory cell, at which time the cross-point array can also implement a parallel data comparison operation. This parallel data comparison function is also called a content addressable function. Through the content addressable function, it can be determined that the data stored in the array is the same as the input data in the row. Specifically, the left and right resistive random access memory cells 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 random access memory cell (R) stores data, and the right cell (RB) stores its inverse value.
[0076] Table 1 Content Addressing
[0077] Cell value R RB Search Target SL SLB ML result 1 Low resistance state High impedance state 1 0 Vsrc ≈0 match 1 Low resistance state High impedance state 0 Vsrc 0 >Vref Mismatch 0 High impedance state Low resistance state 1 0 Vsrc >Vref Mismatch 0 High impedance state Low resistance state 0 Vsrc 0 ≈0 match
[0078] Table 1 shows a truth table of data in a content addressable cell, a search target to array input, and array output to search result. Among them, Vsrc represents the search voltage, and Vref represents the reference voltage. When performing an in-place equality search operation, the search voltage Vsrc is input from the lower end of the cell to one of the bit lines according to the target value, and the search result is determined according to the row line voltage. If the reference voltage Vref is not exceeded, 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 random access memory cell connected to the bit line of the input voltage will be in a high resistance state, blocking voltage leakage to the row line, and the row line will not change significantly. Otherwise, if the data does not match, the resistive random access 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 the storage mode, one resistive random access memory cell stores one bit of data.
[0080] The following are examples.
[0081] Example 1:
[0082] A storage and computing integrated memory system, such as Figure 2 The three-layer structure shown is: array cluster, array group, and array. The array is a cross-point array composed of resistive memory cells; multiple arrays form an array group, and the arrays in the array group can be activated simultaneously. 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 devices include a row selector, a read driver, a read sense amplifier, a search driver, and a search sense amplifier. 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 cell 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 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 cell 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 for the row that matches 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) 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 in the row to be read; the row to be read is selected by a row selector;
[0086] The voltage output by each bit line is sensed by a read sense amplifier 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 and row write operations, 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 a source row to a target row. Intra-cluster move operations include:
[0092] The data in the source row is read out through the row read operation; during the reading process, the source row is selected by the row selector;
[0093] The read data is written into the target row through the row write operation, and the intra-cluster move operation ends; the write process is completed and the target row is selected by the row selector.
[0094] Since equal value search and first largest 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 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 largest 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 that supports parallel data comparison within the storage and computing integrated memory system to implement in-situ equal value search and in-situ first largest value search operations for the array group in the computing mode.
[0095] like Figure 3 As shown in (b) in the figure, 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 search sense amplifier senses the word line voltage output by each selected row to search for the row storing data that matches the data to be searched. Referring to Table 1, it can be seen that 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 comparison. The first greater value search operation provided by the embodiment is based on the equal search operation in place, and the array group needs to be stored in order in addition to being in the calculation mode. The process of the first greater value search operation in place 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 greater value greater than the data to be searched is found with the help of the rows. For the search in the first stage, the embodiment considers that in binary numbers, the more high bits match, the closer the numbers are. Therefore, the closest item is found by performing equal search on the target from the highest bit, and excluding the items that do not match until no match is found. This process uses several equal search operations in place and binary search to implement and accelerate the process.
[0100] The first greater value search operation in place can be described at the algorithm level by the pseudo code shown in the following table. Figure 4 The lines 3-10 in the table describe the process of finding the closest value. First, the binary search pointers and the vector for recording the items participating in the search are initialized. 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, and the middle pointer is 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 the row selectors, which are initialized to all "1" and "0" respectively. Then, the equal search operation is performed between the left pointer and the middle pointer of the vector, and different processing is performed according to the number of matching items (m_row):
[0101] (1) If m_row = 0, i.e., there is no matching item, as shown in lines 6-7 in the table, the vector is kept unchanged, the right pointer is moved to the middle, and the search for the matching prefix is continued in a narrower range. Figure 4
[0102] (2) If m_row > 0, it means that there are matching items, as shown in lines 8-10 in the table. The items that do not match are removed from the vector, the left pointer is moved to the middle, and the search for the matching prefix is continued in a wider range. Figure 4
[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 are not removed are the items closest to the target, because they have the longest common prefix. Thus, the search in the first stage is completed, and the rows close to the data to be searched, i.e., the rows having the longest common prefix with the data to be searched, are found.
[0104] In combination with the order of the internal keys of the B+ tree node, the final result corresponding to the first greater value search operation is selected from the rows close to the data to be searched found in the first stage, as shown in lines 11-14 in the table. Figure 4
[0105] Figure 5 The relative position relationship of the target, the closest items obtained in the previous step and the final result in the node is shown. Since the closest items have 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, and in combination with the ordered nature 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, which can be determined by the first bit after the longest common prefix in the searchable data first ), specifically:
[0106] (1) If bit first = 1, it means that the closest items are all less than the target, and the final result is the next item of the last item in the closest items;
[0107] (2) If bit first = 0, it means that the closest items are all greater than the target, and the final result is the minimum value (the first) in the closest items.
[0108] Based on the above analysis, in this embodiment, the in-place first larger value search operation includes:
[0109] S1: initialize left as the highest bit line sequence number and right as the lowest bit line sequence number;
[0110] S2: if left < right, set mid = (left + right) / 2; otherwise, go to S5;
[0111] S3: search for the row in the stored data whose left to mid bits match the left to mid bits of the data to be searched by the in-place equal value search operation, and eliminate the rows that do not match, while taking the left to mid bits of the data to be searched as the common prefix;
[0112] S4: if the number of remaining rows is 0, update right as right = mid; otherwise, update left as left = mid + 1, and then go to S2;
[0113] S5: after concatenating all common prefixes into the longest common prefix, if the next bit of the longest common prefix in the data to be searched is 0, determine that the data stored in the first row of the remaining rows is the first larger value; otherwise, determine that the data stored in the next row of the last row of the remaining rows is the first larger value.
[0114] Figure 6An example of the first large value search operation in place is shown, which is used to search the first item greater than or equal to 38 in [14, 32, 36, 37, 42, 57], wherein (a)-(e) show steps 1-5 of the first stage search, which is 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 In the example, the specific search process is as follows: first, in step 1, three pointers and a vector (row selector) are initialized. Then, the in-place equal value search operation is performed on the selected rows between the left pointer and the middle pointer. In steps 2 and 4, since the matching item > 0, the unmatched item is 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 pointer and the right pointer converge, the loop is terminated, and the remaining items ([36, 37]) are the longest prefix matching (1001) data and the closest data to the target, ending the first stage search. Figure 6 In the example, since the first bit after the longest common prefix of the data to be searched 38 is "1", all the closest items are less than the data to be searched 38, on the left side of it, so the final result is the next item of the last item in the closest item, that is, 42.
[0115] In this embodiment, the first large value search operation in place is realized by several in-place equal value search operations to search the first large value, and the time complexity is O(logN), where N is the number of bits in the data to be searched.
[0116] In summary, the memory computing integrated memory system provided by the embodiment utilizes the parallel data comparison function (i.e. content addressable function) of the cross-point array of the resistive random access memory, realizes in-place equal value search in the memory, and realizes in-place first large value search in the memory based on the in-place equal value search. In the search process, the data does not need to be read from the memory to the CPU, and the data comparison does not need to be performed in the CPU, and multiple rows of data can be searched in parallel, greatly improving the search efficiency. The equal and the first greater than the target in the search node are the key operations of the B+ tree index. By implementing in-place equal value search and in-place first large value search, the embodiment can support efficient indexing of the B+ tree.
[0117] Embodiment 2:
[0118] A key-value storage system based on B+ tree index, comprising: the memory computing integrated system provided by the above-mentioned embodiment 1 and an index controller; the memory 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 memory computing integrated system.
[0119] In this embodiment, the mapping scheme of B+ tree to the storage-computing integrated system is divided into three levels: data item mapping, tree node mapping, and tree mapping, wherein the data item mapping and the tree node mapping are as shown in Figure 7 and the tree mapping is as shown in Figure 8 Specifically, the following is performed.
[0120] Each node of the B+ tree, wherein the keys are mapped to a computing mode array group in order, and the values are mapped to a half storage mode array group in order; the offset of the keys and the values in the corresponding array group is the same, thereby facilitating the reading of the data of the values after the address of the keys is located; the array group of the same size has a storage capacity in the computing mode that is half of the storage capacity in the storage mode, in order to support the index operation, the keys need to be calculated and compared, and the values do not need to be calculated and compared, in this embodiment, the keys in the B+ tree node are mapped to a computing mode array group, and the values are mapped to a half storage mode array group, so that the array storage space utilization rate is improved while the efficient and complete key-value index operation is ensured.
[0121] The B+ tree, wherein the nodes are deployed to the idle array groups of the array cluster in order, and the connection between the nodes is implemented by using the array group address pointer.
[0122] The B+ tree operation is a routing (searching) process from the root node to the leaf node. The process is divided into two stages: the internal node and the leaf node. All operations have the same process in the internal node, that is, the first key greater than or equal to the target value is found, and the address of the next layer node (stored in the value) is obtained. In the leaf node, the insertion and searching operations need to search the first key greater than or equal to the target value, and the searching, updating, and deleting operations need to search the key equal to the target value, and if the target is found, the corresponding operation is performed.
[0123] Correspondingly, in this embodiment, the index controller is also used to perform the routing operation and the index operation.
[0124] The routing operation is used to route from the root node of the B+ tree to the leaf node in which the target key or the first larger value of the target key is stored according to the target key; the routing operation includes the following steps.
[0125] R1: initialize the current node as the root node;
[0126] R2: if the current node is the leaf node, go to R3; otherwise, perform the in-place first larger value searching operation to obtain the first larger value of the target key in the current node, take the node pointed to by the corresponding child node pointer as the new current node, and re-enter R2;
[0127] R3: determine that the current leaf node is the leaf node in which the target key or the first larger value of the target key is stored, 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 routing operation i The first leaf node with the largest value L i ;
[0130] Find the leaf node L by performing an in-place first larger value search operation i The mapped array group stores the 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 to make room 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 the 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 the in-situ equal value search operation s The mapped array group stores the key k s and the corresponding value rows, respectively, 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 in 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 recorded 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 the 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 located 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 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 located 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 operations include:
[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 the in-situ equal value search operation u The mapped array group stores the 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 the row write operation u 'Write line lvu , the update operation ends.
[0146] The index operation further includes a delete operation, the delete operation is used for deleting the key-value pair data <k d , v d >, the delete operation includes:
[0147] The leaf node storing the key k d is found through the routing operation, and is recorded as a leaf node L d ;
[0148] The row storing the key k d and the value v d in the array group mapped by the leaf node L d is found through the in-place equivalent search operation, and is recorded as row l kd and row l vd , respectively.
[0149] The data in the row l kd and the row l vd is deleted through the row deletion operation, and the delete operation ends.
[0150] According to the needs of the B+ tree index, the embodiment adds a special instruction set for the CPU for controlling the storage-computing integrated memory system, for implementing the B+ tree mapping and index operation. The instruction is decoded into one or more array operations in the total control unit, and is sent to the corresponding array cluster, and the array operation corresponding to the instruction can be customized; the embodiment adds the storage space application, the storage space release, the reading, the writing, the deletion, the in-place equivalent search, the in-place first larger value search, and the data movement command for the B+ tree index, wherein the data movement operation is classified into the intra-cluster data movement and the inter-cluster data movement when being decoded; the storage space application and the storage space release command are completed by the total control unit; the inter-cluster data movement is finally decoded into an array cluster reading operation and an array cluster writing operation; and the other instructions correspond to an array cluster operation corresponding to the instruction. Specifically, as shown in Table 2.
[0151] Table 2 instruction set
[0152]
[0153] Wherein, HMEM is an array group address, including an array cluster and an array group id; ROW is a row number, that is, the offset of the target row in the array group; KEY, VALUE is a key-value pair of the key-value index; TARGET is a search operation target; and NUM is the number of rows of the operation.
[0154] The corresponding index operations can be implemented by calling the instructions in Table 2. Through the pim_matching_search and pim_larger_search instructions, in-place equal search and in-place first larger value search operations can be performed, with time complexity of O(1) and O(logN) respectively, where N is the number of data bits.
[0155] The generation 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 a leaf node can be described at the algorithm level by the pseudo code shown in Figure 9 The process is as follows:
[0156] 1) Line 1: Apply for storage space for a new node;
[0157] 2) Lines 4-5 and 9-10: Move the last half of the key-value pairs of the current node to the new node, and reserve space for the new key-value pair according to the search result obtained by the in-place equal search (i.e. the insertion position of the new key-value pair, line offset);
[0158] 3) Lines 6-7 and 11-12: Write the new key-value pair to the target position;
[0159] 4) Line 13: Add the next leaf node pointer to the current node.
[0160] The splitting process of an internal node is similar to that of a leaf node, except that the in-place equal search operation is replaced by an in-place first larger value search operation, and the last pointer points to the right child. The merging process is similar to splitting, with allocation and insertion being changed to deallocation and deletion.
[0161] Those skilled in the art will readily understand that the above description is only a preferred embodiment of the present application, and is not intended to limit the present application. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application.
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 operations include 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 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 operations further include 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 unmatched 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 order to form the longest common prefix, if the next bit of 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 of the last row among the remaining rows as the first larger value.
2. The storage and computing integrated memory system according to claim 1, wherein: The array operations further include: row read operation and 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 bit line to realize 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, and realizing the writing of the data to be written.
3. The storage and computing integrated memory system according to claim 2, wherein: The array operations further include: row deletion operation and in-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 in-cluster movement operation is used to move the data in the source row to the target row, and the in-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 in-cluster movement operation ends.
4. A key-value storage system based on B+ tree index, characterized in that: Including: The memory-in-computation memory system and the index controller according to claim 3; the memory-in-computation memory system is used to store key-value pair data; the index controller is used to build a B+ tree; the B+ tree is used to index the key-value pair data stored in the memory-in-computation memory system; For each node of the B+ tree, the key is sequentially mapped to a computation mode array group, and the value is sequentially mapped to half of a storage mode array group, and the key and the value have the same offset in the corresponding array group; The nodes in the B+ tree are sequentially deployed on idle array groups of the array cluster, and the connections between the nodes are realized using array group address pointers.
5. The key-value storage system based on B+ tree index according to claim 4, characterized in that: The index controller is further configured to perform a routing operation; the routing operation is configured 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, set 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 the stored key greater than k i The first leaf node with the largest value L i ; Find the leaf node L by performing the in-place first larger value search operation i The mapped array group stores the 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 to make room 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 equivalent search operation s The mapped array group stores the 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 claim 6 or 7, characterized in that: 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: 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 recorded 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 the 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 1 through the row read operation vscu Start, key is located 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 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 1 through the row read operation vscu Start, key is located at [k scd , k scu ], and the scanning operation ends.
9. The key-value storage system based on B+ tree index according to claim 6 or 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 equivalent search operation u The mapped array group stores the 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 claim 6 or 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 equivalent search operation d The mapped array group stores the 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 , the deletion operation is completed.
Citation Information
Patent Citations
Storage and calculation integrated index system and key value pair storage system
CN117539408A
Storage and calculation integrated circuit, chip and electronic equipment
CN118072788A