Skip to content

Special case for "fat" ledger. Use compaction + CompactionFilter #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

taco-paco
Copy link
Contributor

@taco-paco taco-paco commented Jun 24, 2025

Combining CompactionFilter + ManualCompaction.

Greptile Summary

Implements an optimized cleanup mechanism for large ('fat') ledgers by combining RocksDB's CompactionFilter with manual compaction processes for efficient data purging.

  • Added PurgedSlotFilterFactory in database/cf_descriptors.rs to automatically filter old slots during compaction
  • Introduced atomic oldest_slot tracking in database/rocks_db.rs to safely manage data retention thresholds
  • Added get_lowest_slot() and set_lowest_cleanup_slot() in store/api.rs to coordinate manual deletion with automatic compaction
  • Implemented truncate_fat_ledger method in ledger_truncator.rs with performance measurements for compaction operations

@taco-paco taco-paco marked this pull request as ready for review June 24, 2025 14:05
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 files reviewed, 3 comments
Edit PR Review Bot Settings | Greptile

Comment on lines +258 to +260
pub fn set_oldest_slot(&self, slot: Slot) {
self.oldest_slot.store(slot, Ordering::Relaxed);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: using Ordering::Relaxed here could lead to inconsistencies in a multi-threaded environment. Consider using Ordering::SeqCst for slot threshold changes

@@ -20,6 +21,7 @@ use crate::{
pub const DEFAULT_TRUNCATION_TIME_INTERVAL: Duration =
Duration::from_secs(2 * 60);
const PERCENTAGE_TO_TRUNCATE: u8 = 10;
const FILLED_PERCENTAGE_LIMIT: u8 = 100 - PERCENTAGE_TO_TRUNCATE;

struct LedgerTrunctationWorker<T> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: Typo in struct name: 'LedgerTrunctationWorker' should be 'LedgerTruncationWorker'

Suggested change
struct LedgerTrunctationWorker<T> {
struct LedgerTruncationWorker<T> {

@taco-paco taco-paco force-pushed the fix/ledger/delete-using-compaction-filter branch from f1ba00e to ee5d428 Compare June 25, 2025 03:08
@taco-paco taco-paco force-pushed the fix/ledger/delete-using-compaction-filter branch from 37dc7a1 to a5cda6f Compare June 25, 2025 06:28
Copy link
Contributor

@GabrielePicco GabrielePicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@bmuddha bmuddha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks legit overall

@@ -111,71 +111,74 @@ pub fn init_commit_accounts_ticker(
})
}

#[allow(unused_variables)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not delete the method altogether?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants