# US 2021/0342259 A1 · Key-value stores with optimized merge policies and optimized lsm-tree structures

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0342259 A1
- Document ID: US20210342259A1
- Status: Published application
- Kind: A1
- Application number: 17/376,827
- Filed: 2021-07-15
- Published: 2021-11-04
- Earliest claimed: 2018-01-22
- Assignees: President and Fellows of Harvard College
- Inventors: Stratos IDREOS; Niv DAYAN
- Web page: https://patentgrep.com/patent/US20210342259A1

## CPC

- G06F 12/0238: {Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory}
- G06F 16/1734: {Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs}
- G06F 16/2246: {Trees, e.g. B+trees}
- G06F 16/2272: {Management thereof}
- G06F 2212/7202: Allocation control and policies
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Embodiments of the invention utilize an improved LSM-tree-based key-value approach to strike the optimal balance between the costs of updates and lookups and storage space. The improved approach involves use of a new merge policy that removes merge operations from all but the largest levels of LSM-tree. In addition, the improved approach may include an improved LSM-tree that allows separate control over the frequency of merge operations for the largest level and for all other levels. By adjusting various parameters, such as the storage capacity of the largest level, the storage capacity of the other smaller levels, and/or the size ratio between adjacent levels in the improved LSM-tree, the improved LSM-tree-based key-value approach may maximize throughput for a particular workload.

## Claims

### Claim at position 1

1-18. (canceled)

### Claim 19

A database system comprising:
a main memory;
a secondary store comprising nonvolatile storage;
memory containing a log-structured merge-tree (LSM-tree) providing indexed access to files stored in the file buffer and the secondary store, the LSM-tree being organized to accommodate a range of merge policies; and
a processor for accessing runs in the main memory, each of the runs including a plurality of key-value pairs sorted by key, wherein:
(i) each of the runs is sorted and has a size;
(ii) the runs are organized into a plurality of levels according to run size; and
(iii) the processor is configured to select a merge policy from a plurality of alternatives and operate the LSM-tree in accordance with the selected merge policy, the merge policy determining a frequency of merging runs within each of the LSM-tree levels.

### Claim 20 (depends on 19)

The system of claim 19, wherein the processor is further configured to select a merge policy based on comparison of an update cost with a lookup cost, the update cost specifying a I/O cost of modifying a file in the secondary store or the file buffer and the lookup cost specifying a cost of retrieving a file from the secondary store or the file buffer.

### Claim 21 (depends on 20)

The system of claim 20, wherein the lookups are point lookups that find a most recent version of a key-value pair in the secondary store or in one of the runs.

### Claim 22 (depends on 20)

The system of claim 20, wherein the lookups are range lookups that find a most recent version of key-value pairs within a range in the secondary store or in the main memory.

### Claim 23 (depends on 20)

The system of claim 20, wherein the merge policy specifies a frequency of merge operations within each of the levels.

### Claim 24 (depends on 23)

The system of claim 23, wherein the processor is further configured to select a storage capacity for each of the levels, the storage capacities having sizes conforming to a unitary size ratio between successive levels that dictates a frequency at which a level fills up and spills to another level.

### Claim 25 (depends on 24)

The system of claim 24, wherein:
(i) a largest one of the levels has a storage capacity of Z runs;
(ii) the other levels have a storage capacity of K runs;
(iii) the unitary size ratio is T;
(iv) K=T−1 and Z=1; and
(v) Z, K, and T are integers greater than 1.

### Claim 26 (depends on 24)

The system of claim 24, wherein:
(i) a largest one of the levels has a storage capacity of Z runs;
(ii) the other levels have a storage capacity of K runs;
(iii) the unitary size ratio is T;
(iv) 1<K≤T−1 and 1<Z≤T−1; and
(v) Z, K, and T are integers greater than 1.

### Claim 27

A method for providing an improved key-value storing system, the method comprising:
providing a main memory;
providing a secondary store comprising nonvolatile storage;
providing memory containing a log-structured merge-tree (LSM-tree) having indexed access to files stored in the file buffer and the secondary store, the LSM-tree being organized to accommodate a range of merge policies;
accessing runs in the main memory, each of the runs including a plurality of key-value pairs sorted by key, wherein (i) each of the runs is sorted and has a size and (ii) the runs are organized into a plurality of levels according to run size; and
selecting a merge policy from a plurality of alternatives and operate the LSM-tree in accordance with the selected merge policy, the merge policy determining a frequency of merging runs within each of the LSM-tree levels.

### Claim 28 (depends on 27)

The method of claim 27, further comprising selecting a merge policy based on comparison of an update cost with a lookup cost, the update cost specifying a I/O cost of modifying a file in the secondary store or the file buffer and the lookup cost specifying a cost of retrieving a file from the secondary store or the file buffer.

### Claim 29 (depends on 28)

The method of claim 28, wherein the lookups are point lookups that find a most recent version of a key-value pair in the secondary store or in one of the runs.

### Claim 30 (depends on 28)

The method of claim 28, wherein the lookups are range lookups that find a most recent version of key-value pairs within a range in the secondary store or in the main memory.

### Claim 31 (depends on 28)

The method of claim 28, wherein the merge policy specifies a frequency of merge operations within each of the levels.

### Claim 32 (depends on 31)

The method of claim 31, further comprising selecting a storage capacity for each of the levels, the storage capacities having sizes conforming to a unitary size ratio between successive levels that dictates a frequency at which a level fills up and spills to another level.

### Claim 33 (depends on 32)

The method of claim 32, wherein:
(i) a largest one of the levels has a storage capacity of Z runs;
(ii) the other levels have a storage capacity of K runs;
(iii) the unitary size ratio is T;
(iv) K=T−1 and Z=1; and
(v) Z, K, and T are integers greater than 1.

### Claim 34 (depends on 32)

The method of claim 32, wherein:
(i) a largest one of the levels has a storage capacity of Z runs;
(ii) the other levels have a storage capacity of K runs;
(iii) the unitary size ratio is T;
(iv) 1<K≤T−1 and 1<Z≤T−1; and
(v) Z, K, and T are integers greater than 1.

### Claim 35

A database system comprising:
a main memory having an associated storage cost;
a secondary store comprising nonvolatile storage and having an associated storage cost higher than that of the main memory;
memory containing a log-structured merge-tree (LSM-tree) providing indexed access to files stored in the main memory and in the secondary store; and
a processor for accessing runs in the main memory, each of the runs including a plurality of key-value pairs sorted by key, wherein:
(i) each of the runs is sorted and has a size;
(ii) the runs are organized within the secondary store into a plurality of levels according to run size; and
(iii) the processor is configured to merge all runs within a largest level corresponding to the largest run size into a single run whenever a new run is added to the largest level and at every other level merging runs only from lower levels.

### Claim 36 (depends on 35)

The system of claim 35, wherein the processor is further configured to perform updates to memory contents, point lookups to find a most recent version of a stored key-value pair, and range lookups to find a most recent version of all stored key-value pairs within a target key range.

### Claim 37 (depends on 36)

The system of claim 36, wherein the main memory further comprises a plurality of Bloom filters each associated with a run, the processor being further configured to allocate a memory budget among the Bloom filters to minimize an I/O cost of point lookups.

### Claim 38 (depends on 37)

The system of claim 37, wherein the processor is further configured to assign a false positive rate to the Bloom filter at each level based at least in part on a number of entries in the corresponding run, and minimize the point-lookup cost by (i) defining a memory budget, (ii) determining false positive rates of the Bloom filters that minimize the point-lookup cost given the defined memory budget, and (iii) assigning the determined false positive rates to the Bloom filters.

### Claim 39

A method for providing an improved key-value storing system, the method comprising:
providing a main memory having an associated storage cost;
providing a secondary store comprising nonvolatile storage and having an associated storage cost higher than that of the main memory;
providing memory containing a log-structured merge-tree (LSM-tree) having indexed access to files stored in the main memory and in the secondary store;
accessing runs in the main memory, each of the runs including a plurality of key-value pairs sorted by key, wherein (i) each of the runs is sorted and has a size and (ii) the runs are organized within the secondary store into a plurality of levels according to run size; and
merging all runs within a largest level corresponding to the largest run size into a single run whenever a new run is added to the largest level and at every other level merging runs only from lower levels.

### Claim 40 (depends on 39)

The method of claim 39, further comprising performing updates to memory contents, point lookups to find a most recent version of a stored key-value pair, and range lookups to find a most recent version of all stored key-value pairs within a target key range.

### Claim 41 (depends on 39)

The method of claim 39, wherein the main memory further comprises a plurality of Bloom filters each associated with a run, the method further comprising allocating a memory budget among the Bloom filters to minimize an I/O cost of point lookups.

### Claim 42 (depends on 41)

The method of claim 41, further comprising assigning a false positive rate to the Bloom filter at each level based at least in part on a number of entries in the corresponding run, and minimizing the point-lookup cost by (i) defining a memory budget, (ii) determining false positive rates of the Bloom filters that minimize the point-lookup cost given the defined memory budget, and (iii) assigning the determined false positive rates to the Bloom filters.
