Skip to content
Draft
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
34 changes: 34 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ members = [
"vortex-compressor",
"vortex-btrblocks",
"vortex-layout",
"vortex-morsel",
"vortex-scan",
"vortex-file",
"vortex-ipc",
Expand Down Expand Up @@ -325,6 +326,7 @@ vortex-pco = { version = "0.1.0", path = "./encodings/pco", default-features = f
vortex-proto = { version = "0.1.0", path = "./vortex-proto", default-features = false }
vortex-row = { version = "0.1.0", path = "./vortex-row", default-features = false }
vortex-runend = { version = "0.1.0", path = "./encodings/runend", default-features = false }
vortex-morsel = { version = "0.1.0", path = "./vortex-morsel", default-features = false }
vortex-scan = { version = "0.1.0", path = "./vortex-scan", default-features = false }
vortex-sequence = { version = "0.1.0", path = "encodings/sequence", default-features = false }
vortex-session = { version = "0.1.0", path = "./vortex-session", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions benchmarks/compress-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ vortex = { workspace = true }
vortex-arrow = { workspace = true }
vortex-bench = { workspace = true }
vortex-cuda = { workspace = true, optional = true }
vortex-morsel = { workspace = true }

[features]
cuda = ["dep:tempfile", "dep:vortex-cuda"]
Expand Down
142 changes: 82 additions & 60 deletions benchmarks/compress-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,67 +444,89 @@ async fn run_benchmark_for_dataset(
let compressor = get_compressor(*format, mode);

for op in ops {
let time = match op {
CompressOp::Compress => {
let result = benchmark_compress(
compressor.as_ref(),
&parquet_path,
iterations,
bench_name,
)
.await
.with_context(|| format!("compressing {bench_name} as {format}"))?;
compressed_sizes.insert(*format, result.compressed_size);
let all_runs_ns: Vec<u64> = result
.all_runs
.iter()
.map(|d| u64::try_from(d.as_nanos()).unwrap_or(u64::MAX))
.collect();
v3_records.push(v3::compression_time_record(
&result.timing,
v3_dataset,
v3_variant,
CompressOp::Compress,
all_runs_ns,
));
v3_records.push(v3::compression_size_record(
v3_dataset,
v3_variant,
*format,
result.compressed_size,
uncompressed_size.context("compression size requires Arrow memory size")?,
));
ratios.extend(result.ratios);
timings.push(result.timing);
result.time
let run = AssertUnwindSafe(async {
anyhow::Ok(match op {
CompressOp::Compress => {
let result = benchmark_compress(
compressor.as_ref(),
&parquet_path,
iterations,
bench_name,
)
.await
.with_context(|| format!("compressing {bench_name} as {format}"))?;
compressed_sizes.insert(*format, result.compressed_size);
let all_runs_ns: Vec<u64> = result
.all_runs
.iter()
.map(|d| u64::try_from(d.as_nanos()).unwrap_or(u64::MAX))
.collect();
v3_records.push(v3::compression_time_record(
&result.timing,
v3_dataset,
v3_variant,
CompressOp::Compress,
all_runs_ns,
));
v3_records.push(v3::compression_size_record(
v3_dataset,
v3_variant,
*format,
result.compressed_size,
uncompressed_size
.context("compression size requires Arrow memory size")?,
));
ratios.extend(result.ratios);
timings.push(result.timing);
result.time
}
CompressOp::Decompress => {
let result = benchmark_decompress(
compressor.as_ref(),
&parquet_path,
iterations,
&decompress_name,
)
.await
.with_context(|| format!("decompressing {bench_name} as {format}"))?;
let all_runs_ns: Vec<u64> = result
.all_runs
.iter()
.map(|d| u64::try_from(d.as_nanos()).unwrap_or(u64::MAX))
.collect();
v3_records.push(v3::compression_time_record(
&result.timing,
v3_dataset,
if mode.is_gpu() {
Some("gpu")
} else {
v3_variant
},
CompressOp::Decompress,
all_runs_ns,
));
timings.push(result.timing);
result.time
}
})
})
.catch_unwind()
.await;

let time = match run {
Ok(Ok(time)) => time,
Ok(Err(error)) => {
tracing::error!("dropping {op} result for {bench_name} as {format}: {error:#}");
progress.inc(1);
continue;
}
CompressOp::Decompress => {
let result = benchmark_decompress(
compressor.as_ref(),
&parquet_path,
iterations,
&decompress_name,
)
.await
.with_context(|| format!("decompressing {bench_name} as {format}"))?;
let all_runs_ns: Vec<u64> = result
.all_runs
.iter()
.map(|d| u64::try_from(d.as_nanos()).unwrap_or(u64::MAX))
.collect();
v3_records.push(v3::compression_time_record(
&result.timing,
v3_dataset,
if mode.is_gpu() {
Some("gpu")
} else {
v3_variant
},
CompressOp::Decompress,
all_runs_ns,
));
timings.push(result.timing);
result.time
Err(panic) => {
tracing::error!(
"dropping {op} result for {bench_name} as {format}: panicked: {}",
panic_message(&panic)
);
progress.inc(1);
continue;
}
};

Expand Down
48 changes: 31 additions & 17 deletions benchmarks/compress-bench/src/vortex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@ use std::time::Instant;
use anyhow::Result;
use async_trait::async_trait;
use bytes::Bytes;
use futures::StreamExt;
use futures::pin_mut;
use vortex::array::Canonical;
use vortex::array::IntoArray;
use vortex::array::VortexSessionExecute;
use vortex::dtype::FieldNames;
use vortex::expr::root;
use vortex::expr::select;
use vortex::file::OpenOptionsSessionExt;
use vortex::file::WriteOptionsSessionExt;
use vortex_arrow::ArrowSessionExt;
use vortex::utils::parallelism::get_available_parallelism;
use vortex_bench::Format;
use vortex_bench::SESSION;
use vortex_bench::compress::Compressor;
use vortex_bench::compress::read_projection;
use vortex_bench::conversions::parquet_to_vortex_chunks;
use vortex_morsel::MorselScan;
use vortex_morsel::build_plan;
use vortex_morsel::morsels;
use vortex_morsel::nodes::ConjunctMode;

const MORSEL_ROWS: u64 = 131_072;

/// Compressor implementation for Vortex format.
pub struct VortexCompressor;
Expand Down Expand Up @@ -63,26 +69,34 @@ impl Compressor for VortexCompressor {
// Now decompress
let start = Instant::now();
let data = Bytes::from(buf);
let mut scan = SESSION.open_options().open_buffer(data)?.scan()?;
let source_dtype = scan.dtype()?;
let file = SESSION.open_options().open_buffer(data)?;
let source_dtype = file.dtype().clone();
let root_columns = source_dtype
.as_struct_fields_opt()
.map_or(0, |fields| fields.nfields());
if let Some(cols) = read_projection(root_columns) {
let projection = if let Some(cols) = read_projection(root_columns) {
// Columns are named "0".."num_columns-1"; project the given subset.
let names: FieldNames = cols.iter().map(|i| i.to_string()).collect();
let projection = select(names, root())
.optimize_recursive(&source_dtype)?
.bind(&source_dtype)?;
scan = scan.with_projection(projection);
}
let schema = Arc::new(SESSION.arrow().to_arrow_schema(&scan.dtype()?)?);

let stream = scan.into_record_batch_stream(schema)?;
pin_mut!(stream);
select(names, root())
} else {
root()
};
let plan = Arc::new(build_plan(
file.footer().layout(),
&projection,
None,
ConjunctMode::Cascade,
)?);
let cut = morsels(&plan, MORSEL_ROWS);
let threads = get_available_parallelism().unwrap_or(1);
let (batches, _) = MorselScan::new(plan, file.segment_source(), SESSION.clone())
.with_threads(threads)
.with_morsels(cut)
.run()?;

while let Some(batch) = stream.next().await {
let _batch = batch?;
let mut ctx = SESSION.create_execution_ctx();
for batch in batches {
let _canonical = batch.execute::<Canonical>(&mut ctx)?;
}
Ok(start.elapsed())
}
Expand Down
1 change: 1 addition & 0 deletions docs/developer-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ internals/async-runtime
internals/vtables
internals/execution
internals/scan-planning
internals/scan-execution-models/index
internals/stats-pruning
internals/io
internals/serialization
Expand Down
Loading
Loading