IP Library › Granted Patent US 12,705,225
Granted Patent B2
US 12,705,225 · App. 19/097,520 · Granted Aug 11, 2026

Compaction of documents in a high density data storage system

Inventors: Sarath Lakshman (Pandakkal, IN); Apaar Gupta (Domlur, IN); Rohan Ashok Suri (Maharashtra, IN); Scott David Lashley (Portland, OR); John Sae Liang (Palo Alto, CA); Srinath Duvuru (Portland, OR); David James Oliver Rigby (Manchester, GB)
Assignee: Couchbase, Inc.
G06F16/2246G06F12/0253G06F16/2358G06F16/24552G06F16/24561G06F16/93
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,705,225
App. No.
19/097,520
Filed
Apr 1, 2025
Granted
Aug 11, 2026
Kind
B2
Art Unit
2164
USPC
707/693
Abstract

A system stores multiple documents in a log-structured object store, each document associated with a sequence number and a document value. The log-structured object store includes multiple log segments, each storing documents within a defined sequence number range. A first log-structured merge-tree is maintained to map document keys to corresponding sequence numbers, while a second log-structured merge-tree maps sizes of stale documents to their sequence numbers. A ratio is determined between the size of stale documents and the total size of documents in at least one log segment. In response to the ratio exceeding a predetermined threshold, a compaction operation is initiated to delete stale documents and consolidate active documents into a reduced number of log segments using the reclaimed space. The first and second log-structured merge-trees are updated based on the compaction results to reflect the current state of the data.

Claims (46)

1 . A computer-implemented method for maintaining data in a data management system, the computer-implemented method comprising:

storing a plurality of documents in a log-structured object store, each document associated with a sequence number and a document value, wherein the log-structured object store comprises a plurality of log segments, each log segment storing a subset of documents that were written within a sequence number range;

maintaining, in a first log-structured merge-tree, mapping document keys associated with documents to corresponding sequence numbers, the documents including active documents and stale documents;

maintaining, in a second log-structured merge-tree, mapping sizes of stale documents to stale document sequence numbers;

determining a ratio between a size of stale documents and a total size of all documents stored in at least one log segment exceeds a predetermined threshold based on the first log-structured merge-tree and the second log-structured merge-tree;

performing a compaction operation on the log-structured object store, comprising:

deleting stale documents in the log-structured object store; and

consolidating active documents into fewer number of log segments using space freed up from the deleted stale documents; and

updating the first log-structured merge-tree and the second log-structured merge-tree based on the compacted log segment.

2 . The computer-implemented method of claim 1 , wherein the sequence numbers are monotonically increasing values assigned based on an order in which the documents were written to the log-structured object store.

3 . The computer-implemented method of claim 1 , wherein the compaction operation further comprises generating a sorted list of sequence numbers associated with stale documents and performing a sort-merge with the documents in the log segment to identify the stale documents.

4 . The computer-implemented method of claim 1 , further comprising maintaining an in-memory counter for each log segment, the in-memory counter tracking a cumulative size of stale documents in a respective log segment.

5 . The computer-implemented method of claim 1 , wherein performing the compaction operation further comprises rewriting a log segment while skipping documents identified by the second log-structured merge-tree as stale.

6 . The computer-implemented method of claim 1 , wherein the first log-structured merge-tree comprises a byKey index mapping document keys to sequence numbers, and the second log-structured merge-tree comprises a delete list storing key-value pairs of sequence number and document size.

7 . The computer-implemented method of claim 1 , wherein the documents are stored in the log-structured object store in a sequential, append-only manner.

8 . The computer-implemented method of claim 1 , further comprising determining a fragmentation value for a log segment based on the ratio between a cumulative size of stale documents and a total size of all documents in the log segment.

9 . The computer-implemented method of claim 1 , wherein the compaction operation is performed asynchronously by a background thread to avoid blocking write operations to the log-structured object store.

10 . The computer-implemented method of claim 1 , wherein updating the first log-structured merge-tree comprises updating document key to sequence number mappings for active documents consolidated during compaction.

11 . The computer-implemented method of claim 1 , further comprising maintaining a metadata snapshot of the first log-structured merge-tree and the second log-structured merge-tree for crash recovery, the metadata snapshot comprising a pointer to a last persisted write-ahead log offset.

12 . The computer-implemented method of claim 1 , wherein the log-structured object store comprises a tail log segment configured to store newly written documents, and wherein older segments are made immutable once a size threshold is reached.

13 . The computer-implemented method of claim 1 , wherein the second log-structured merge-tree is implemented using a sequence-indexed LSM Tree and supports range queries over sequence numbers corresponding to stale documents.

14 . A non-transitory computer readable storage medium storing instructions that when executed by one or more computer processors, cause the one or more computer processors to perform steps for maintaining data in a data management system, the steps comprising:

storing a plurality of documents in a log-structured object store, each document associated with a sequence number and a document value, wherein the log-structured object store comprises a plurality of log segments, each log segment storing a subset of documents that were written within a sequence number range;

maintaining, in a first log-structured merge-tree, mapping document keys associated with documents to corresponding sequence numbers, the documents including active documents and stale documents;

maintaining, in a second log-structured merge-tree, mapping sizes of stale documents to stale document sequence numbers;

determining a ratio between a size of stale documents and a total size of all documents stored in at least one log segment exceeds a predetermined threshold based on the first log-structured merge-tree and the second log-structured merge-tree;

performing a compaction operation on the log-structured object store, comprising:

deleting stale documents in the log-structured object store; and

consolidating active documents into fewer number of log segments using space freed up from the deleted stale documents; and

updating the first log-structured merge-tree and the second log-structured merge-tree based on the compacted log segment.

15 . The non-transitory computer readable storage medium of claim 14 , wherein the sequence numbers are monotonically increasing values assigned based on an order in which the documents were written to the log-structured object store.

16 . The non-transitory computer readable storage medium of claim 14 , wherein the compaction operation further comprises generating a sorted list of sequence numbers associated with stale documents and performing a sort-merge with the documents in the log segment to identify the stale documents.

17 . The non-transitory computer readable storage medium of claim 14 , further comprising maintaining an in-memory counter for each log segment, the in-memory counter tracking a cumulative size of stale documents in a respective log segment.

18 . The non-transitory computer readable storage medium of claim 14 , wherein performing the compaction operation further comprises rewriting a log segment while skipping documents identified by the second log-structured merge-tree as stale.

19 . The non-transitory computer readable storage medium of claim 14 , wherein the first log-structured merge-tree comprises a byKey index mapping document keys to sequence numbers, and the second log-structured merge-tree comprises a delete list storing key-value pairs of sequence number and document size.

20 . A computer system comprising:

one or more computer processors; and

a non-transitory computer readable storage medium storing instructions that when executed by one or more computer processors, cause the one or more computer processors to perform steps for maintaining data in a data management system, the steps comprising:

storing a plurality of documents in a log-structured object store, each document associated with a sequence number and a document value, wherein the log-structured object store comprises a plurality of log segments, each log segment storing a subset of documents that were written within a sequence number range;

maintaining, in a first log-structured merge-tree, mapping document keys associated with documents to corresponding sequence numbers, the documents including active documents and stale documents;

maintaining, in a second log-structured merge-tree, mapping sizes of stale documents to stale document sequence numbers;

determining a ratio between a size of stale documents and a total size of all documents stored in at least one log segment exceeds a predetermined threshold based on the first log-structured merge-tree and the second log-structured merge-tree;

performing a compaction operation on the log-structured object store, comprising:

deleting stale documents in the log-structured object store; and

consolidating active documents into fewer number of log segments using space freed up from the deleted stale documents; and

updating the first log-structured merge-tree and the second log-structured merge-tree based on the compacted log segment.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Apr 15, 2026
From: LAKSHMAN, SARATH; GUPTA, APAAR; SURI, ROHAN ASHOK; LASHLEY, SCOTT DAVID; LIANG, JOHN SAE; DUVURU, SRINATH; RIGBY, DAVID JAMES OLIVER
To: COUCHBASE, INC.
Reel/Frame 074376/0311 →
GRANT OF SECURITY INTEREST IN PATENTS Recorded Sep 25, 2025
From: COUCHBASE, INC.
To: APOLLO ADMINISTRATIVE AGENCY LLC, AS COLLATERAL AGENT
Reel/Frame 072925/0610 →
Priority Claims (1)
IN 202241041486 · Jul 20, 2022 · national
Continuity (2)
Continuation 18223541 · Jul 18, 2023
Related Publication 20250231924A1 · Jul 17, 2025
References Cited (20)
US 9460008B1 · Leshinsky et al. · 2016 [cited by applicant]
US 10013440B1 · Gupta et al. · 2018 [cited by applicant]
US 10445022B1 · Qui et al. · 2019 [cited by applicant]
US 11030242B1 · Borthakur et al. · 2021 [cited by applicant]
US 20100008254A1 · Schneyer et al. · 2010 [cited by applicant]
US 20100082547A1 · Mace et al. · 2010 [cited by applicant]
US 20160110403A1 · Lomet et al. · 2016 [cited by applicant]
US 20170109421A1 · Stearn et al. · 2017 [cited by applicant]
US 20180300350A1 · Mainali · 2018 [cited by examiner]
US 20210081396A1 · Tian · 2021 [cited by applicant]
US 20210382863A1 · Munipalle · 2021 [cited by examiner]
US 20210397345A1 · Jawahar · 2021 [cited by examiner]
US 20220245150A1 · Delbru et al. · 2022 [cited by applicant]
WO WO2020079271A1 · 2020 [cited by examiner]
WO WO2021061173A1 · 2021 [cited by examiner]
WO WO2022121274A1 · 2022 [cited by examiner]
O'Neil, P. et al. “The log-structured merge-tree (LSM-tree),” Acta Informatica, vol. 33, Jun. 1996, pp. 351-385. [cited by applicant]
PCT International Search Report and Written Opinion, PCT Application No. PCT/US2023/028103, Oct. 30, 2023, 16 pages. [cited by applicant]
Vo, H.T. et al. “Logbase: A scalable log-structured database system in the cloud,” Proceedings of the VLDB Endowment, vol. 5, No. 10, Jun. 30, 2012, pp. 1004-1015. [cited by applicant]
United States Office Action, U.S. Appl. No. 18/223,541, Sep. 5, 2024, 14 pages. [cited by applicant]