Skip to content
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

Improved CLI: explicit CLI flags for compaction settings #7061

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions crates/top/rerun/src/commands/rrd/merge_compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,53 @@ pub struct CompactCommand {

#[arg(short = 'o', long = "output", value_name = "dst.(rrd|rbl)")]
path_to_output_rrd: String,

/// What is the threshold, in bytes, after which a Chunk cannot be compacted any further?
///
/// Overrides RERUN_CHUNK_MAX_BYTES if set.
#[arg(long = "max-bytes")]
max_bytes: Option<u64>,

/// What is the threshold, in rows, after which a Chunk cannot be compacted any further?
///
/// Overrides RERUN_CHUNK_MAX_ROWS if set.
#[arg(long = "max-rows")]
max_rows: Option<u64>,

/// What is the threshold, in rows, after which a Chunk cannot be compacted any further?
///
/// This specifically applies to _non_ time-sorted chunks.
///
/// Overrides RERUN_CHUNK_MAX_ROWS_IF_UNSORTED if set.
#[arg(long = "max-rows-if-unsorted")]
max_rows_if_unsorted: Option<u64>,
}

impl CompactCommand {
pub fn run(&self) -> anyhow::Result<()> {
let Self {
path_to_input_rrds,
path_to_output_rrd,
max_bytes,
max_rows,
max_rows_if_unsorted,
} = self;

let mut store_config = ChunkStoreConfig::from_env().unwrap_or_default();
// NOTE: We're doing headless processing, there's no point in running subscribers, it will just
// (massively) slow us down.
store_config.enable_changelog = false;

if let Some(max_bytes) = max_bytes {
store_config.chunk_max_bytes = *max_bytes;
}
if let Some(max_rows) = max_rows {
store_config.chunk_max_rows = *max_rows;
}
if let Some(max_rows_if_unsorted) = max_rows_if_unsorted {
store_config.chunk_max_rows_if_unsorted = *max_rows_if_unsorted;
}

merge_and_compact(&store_config, path_to_input_rrds, path_to_output_rrd)
}
}
Expand Down
10 changes: 8 additions & 2 deletions crates/top/rerun/src/commands/rrd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ pub enum RrdCommands {

/// Compacts the contents of one or more .rrd/.rbl files and writes the result to a new file.
///
/// Use the usual environment variables to control the compaction thresholds:
/// Uses the usual environment variables to control the compaction thresholds:
/// `RERUN_CHUNK_MAX_ROWS`,
/// `RERUN_CHUNK_MAX_ROWS_IF_UNSORTED`,
/// `RERUN_CHUNK_MAX_BYTES`.
///
/// Example: `RERUN_CHUNK_MAX_ROWS=4096 RERUN_CHUNK_MAX_BYTES=1048576 rerun rrd compact /my/recordings/*.rrd -o output.rrd`
/// Unless explicit flags are passed, in which case they will override environment values.
///
/// Examples:
///
/// * `RERUN_CHUNK_MAX_ROWS=4096 RERUN_CHUNK_MAX_BYTES=1048576 rerun rrd compact /my/recordings/*.rrd -o output.rrd`
///
/// * `rerun rrd compact --max-rows 4096 --max-bytes=1048576 /my/recordings/*.rrd -o output.rrd`
Compact(CompactCommand),

/// Merges the contents of multiple .rrd/.rbl files, and writes the result to a new file.
Expand Down
Loading