537 lines
23 KiB
Rust
537 lines
23 KiB
Rust
#![deny(clippy::all)]
|
|
|
|
use std::env;
|
|
use std::process::ExitCode;
|
|
|
|
use curate_etl::bench::{
|
|
run_adj_benchmark, run_bars_benchmark, run_corporate_actions_benchmark, run_events_benchmark,
|
|
run_fx_benchmark, run_parquet_adj_benchmark, run_parquet_bars_benchmark,
|
|
run_parquet_corporate_actions_benchmark, run_parquet_events_benchmark,
|
|
run_parquet_fx_benchmark, run_parquet_shorts_benchmark, run_provider_mapping_benchmark,
|
|
run_shorts_benchmark, run_split_benchmark, run_curate_bars_benchmark,
|
|
};
|
|
use curate_etl::cli::{format_usage, format_usage_stderr, parse_args, CliAction};
|
|
|
|
const NAME: &str = env!("CARGO_PKG_NAME");
|
|
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
|
|
fn main() -> ExitCode {
|
|
let args: Vec<String> = env::args().skip(1).collect();
|
|
|
|
match parse_args(&args) {
|
|
Ok(CliAction::Help) => {
|
|
println!("{}", format_usage(NAME, VERSION));
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::Version) => {
|
|
println!("{NAME} {VERSION}");
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchSplit(rows)) => {
|
|
let report = match run_split_benchmark(rows) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: benchmark fixture failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-split");
|
|
println!(
|
|
" table: keys={} keys_with_splits={} events={} build={:.2} ms",
|
|
report.key_count,
|
|
report.table_keys_with_splits,
|
|
report.table_event_count,
|
|
report.build_elapsed_ms
|
|
);
|
|
println!(
|
|
" run: rows={} elapsed={:.2} ms throughput={:.0} rows/s latency={:.2} ns/row checksum={:.3}",
|
|
report.rows,
|
|
report.elapsed_ms,
|
|
report.rows_per_sec,
|
|
report.ns_per_row,
|
|
report.checksum
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchAdj(events)) => {
|
|
let report = match run_adj_benchmark(events) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: adj benchmark failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-adj");
|
|
println!(
|
|
" input: events={} splits={} dividends={} keys={}",
|
|
report.events, report.split_events_in, report.dividend_events_in, report.key_count
|
|
);
|
|
println!(
|
|
" build: rows_out={} keys_out={} elapsed={:.2} ms throughput={:.0} events/s latency={:.2} ns/event checksum={:.3} (0x{:016x})",
|
|
report.rows_out,
|
|
report.keys_out,
|
|
report.build_elapsed_ms,
|
|
report.events_per_sec,
|
|
report.ns_per_event,
|
|
report.checksum,
|
|
report.checksum.to_bits()
|
|
);
|
|
println!(
|
|
" stats: split_noops={} zero_div={} missing_prev_close={} currency_mismatch={} not_below_prev_close={}",
|
|
report.stats.split_noops_dropped,
|
|
report.stats.dividend_zero_cash_dropped,
|
|
report.stats.dividends_missing_prev_close,
|
|
report.stats.dividends_currency_mismatch,
|
|
report.stats.dividends_not_below_prev_close
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchCorporateActions(events)) => {
|
|
let report = match run_corporate_actions_benchmark(events) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: corporate_actions benchmark failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-corporate-actions");
|
|
println!(
|
|
" input: events={} splits={} dividends={} delistings={} keys={}",
|
|
report.events,
|
|
report.splits_in,
|
|
report.dividends_in,
|
|
report.delistings_in,
|
|
report.key_count
|
|
);
|
|
println!(
|
|
" build: rows_out={} keys_out={} elapsed={:.2} ms throughput={:.0} events/s latency={:.2} ns/event checksum=0x{:016x}",
|
|
report.rows_out,
|
|
report.keys_out,
|
|
report.build_elapsed_ms,
|
|
report.events_per_sec,
|
|
report.ns_per_event,
|
|
report.checksum
|
|
);
|
|
println!(
|
|
" stats: split_noops={} zero_div={} delist_no_outcome={} otc_transfers={} delistings={} declared={} ex_fallback={} declared_after_ex={} delist_date={}",
|
|
report.stats.split_noops_dropped,
|
|
report.stats.dividend_zero_cash_dropped,
|
|
report.stats.delist_without_outcome,
|
|
report.stats.otc_delist_transfers_out,
|
|
report.stats.delistings_out,
|
|
report.stats.known_at_declared_date,
|
|
report.stats.known_at_ex_date_fallback,
|
|
report.stats.declared_after_ex_date,
|
|
report.stats.known_at_delist_date
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchBars(rows)) => {
|
|
let report = match run_bars_benchmark(rows) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: bars_1d benchmark failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-bars");
|
|
println!(
|
|
" input: rows={} qm_rows={} splits={} keys={}",
|
|
report.rows, report.qm_rows_in, report.split_event_count, report.key_count
|
|
);
|
|
println!(
|
|
" build: rows_out={} keys_out={} elapsed={:.2} ms throughput={:.0} rows/s latency={:.2} ns/row checksum=0x{:016x}",
|
|
report.rows_out,
|
|
report.keys_out,
|
|
report.build_elapsed_ms,
|
|
report.rows_per_sec,
|
|
report.ns_per_row,
|
|
report.checksum
|
|
);
|
|
println!(
|
|
" stats: invalid_ohlc={} inconsistent_ohlc={} invalid_vol={} dup_collapsed={} dup_conflict={} checked={} within_tol={} mismatched={} unchecked={} max_rel_diff={:.6} samples={}",
|
|
report.stats.dropped_invalid_ohlc,
|
|
report.stats.dropped_inconsistent_ohlc,
|
|
report.stats.dropped_invalid_volume,
|
|
report.stats.duplicate_collapsed,
|
|
report.stats.duplicate_conflict_dropped,
|
|
report.stats.volume_checked,
|
|
report.stats.volume_within_tolerance,
|
|
report.stats.volume_mismatched,
|
|
report.stats.volume_unchecked,
|
|
report.stats.max_rel_diff,
|
|
report.mismatch_samples_out
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchFx(rows)) => {
|
|
let report = run_fx_benchmark(rows);
|
|
println!("curate-etl bench-fx");
|
|
println!(
|
|
" input: rows={} eod_rows={} te_rows={}",
|
|
report.rows, report.eod_rows_in, report.te_rows_in
|
|
);
|
|
println!(
|
|
" build: rows_out={} eod_out={} te_out={} elapsed={:.3} ms throughput={:.0} rows/s latency={:.2} ns/row",
|
|
report.rows_out,
|
|
report.stats.eod_rows_out,
|
|
report.stats.te_rows_out,
|
|
report.build_elapsed_ms,
|
|
report.build_rows_per_sec,
|
|
report.build_ns_per_row
|
|
);
|
|
println!(
|
|
" lookup: lookups={} hits={} elapsed={:.2} ms throughput={:.0} lookups/s latency={:.2} ns/lookup checksum=0x{:016x}",
|
|
report.lookups,
|
|
report.lookup_hits,
|
|
report.lookup_elapsed_ms,
|
|
report.lookups_per_sec,
|
|
report.ns_per_lookup,
|
|
report.checksum
|
|
);
|
|
println!(
|
|
" stats: eod_invalid={} eod_inconsistent={} eod_dup_collapsed={} eod_dup_conflict={} te_invalid={} te_inconsistent={} te_dup_collapsed={} te_dup_conflict={} te_superseded={} overlap_checked={} within_tol={} mismatched={} max_overlap_rel={:.6}",
|
|
report.stats.eod.dropped_invalid_ohlc,
|
|
report.stats.eod.dropped_inconsistent_ohlc,
|
|
report.stats.eod.duplicate_collapsed,
|
|
report.stats.eod.duplicate_conflict_dropped,
|
|
report.stats.te.dropped_invalid_ohlc,
|
|
report.stats.te.dropped_inconsistent_ohlc,
|
|
report.stats.te.duplicate_collapsed,
|
|
report.stats.te.duplicate_conflict_dropped,
|
|
report.stats.te_superseded_by_eod,
|
|
report.stats.overlap_checked,
|
|
report.stats.overlap_within_tolerance,
|
|
report.stats.overlap_mismatched,
|
|
report.stats.max_overlap_rel
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchShorts(rows)) => {
|
|
let report = match run_shorts_benchmark(rows) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: shorts benchmark failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-shorts");
|
|
println!(" input: rows={} keys={}", report.rows, report.key_count);
|
|
println!(
|
|
" build: rows_out={} keys_out={} elapsed={:.2} ms throughput={:.0} rows/s latency={:.2} ns/row checksum=0x{:016x}",
|
|
report.rows_out,
|
|
report.keys_out,
|
|
report.build_elapsed_ms,
|
|
report.rows_per_sec,
|
|
report.ns_per_row,
|
|
report.checksum
|
|
);
|
|
println!(
|
|
" stats: invalid_shares={} nulled_net_change={} nulled_pct_float={} dup_collapsed={} dup_conflict={}",
|
|
report.stats.dropped_invalid_shares_short,
|
|
report.stats.nulled_invalid_net_change,
|
|
report.stats.nulled_invalid_pct_float,
|
|
report.stats.duplicate_collapsed,
|
|
report.stats.duplicate_conflict_dropped
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchEvents(rows)) => {
|
|
let report = run_events_benchmark(rows);
|
|
println!("curate-etl bench-events");
|
|
println!(
|
|
" input: rows={} filings={} earnings={} keys={}",
|
|
report.rows, report.filings_in, report.earnings_in, report.key_count
|
|
);
|
|
println!(
|
|
" build: rows_out={} filings_out={} earnings_out={} keys_out={} elapsed={:.2} ms throughput={:.0} rows/s latency={:.2} ns/row checksum=0x{:016x}",
|
|
report.rows_out,
|
|
report.stats.filings_out,
|
|
report.stats.earnings_out,
|
|
report.keys_out,
|
|
report.build_elapsed_ms,
|
|
report.rows_per_sec,
|
|
report.ns_per_row,
|
|
report.checksum
|
|
);
|
|
println!(
|
|
" stats: malformed_ts={} unknown_zone={} invalid_dt={} filing_dup={} linked={} lagged_1605={} earnings_oor={} earnings_dup={} earnings_conflict={}",
|
|
report.stats.filings_skipped_malformed_timestamp,
|
|
report.stats.filings_skipped_unknown_zone,
|
|
report.stats.filings_skipped_invalid_date_time,
|
|
report.stats.filings_duplicate_collapsed,
|
|
report.stats.earnings_linked_to_filing,
|
|
report.stats.earnings_lagged_1605,
|
|
report.stats.earnings_skipped_out_of_range,
|
|
report.stats.earnings_duplicate_collapsed,
|
|
report.stats.earnings_duplicate_conflict_dropped
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchProviderMapping(lookups)) => {
|
|
let report = match run_provider_mapping_benchmark(lookups) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: provider_mapping benchmark failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-provider-mapping");
|
|
println!(
|
|
" table: keys={} ranges={} multi_range_keys={} build={:.2} ms throughput={:.0} rows/s",
|
|
report.key_count,
|
|
report.range_count,
|
|
report.multi_range_keys,
|
|
report.build_elapsed_ms,
|
|
report.build_rows_per_sec
|
|
);
|
|
println!(
|
|
" lookup: lookups={} hits={} misses={} elapsed={:.2} ms throughput={:.0} lookups/s latency={:.2} ns/lookup checksum=0x{:016x}",
|
|
report.lookups,
|
|
report.hits,
|
|
report.misses,
|
|
report.lookup_elapsed_ms,
|
|
report.lookups_per_sec,
|
|
report.ns_per_lookup,
|
|
report.checksum
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchParquetBars(rows)) => {
|
|
let report = match run_parquet_bars_benchmark(rows) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: parquet bars benchmark failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-parquet-bars");
|
|
println!(
|
|
" input: rows={} listings={} raw_row_bytes={}",
|
|
report.rows, report.listing_count, report.raw_row_bytes
|
|
);
|
|
println!(
|
|
" output: files={} row_groups={} bytes={} read_back_rows={}",
|
|
report.files_written,
|
|
report.row_groups_written,
|
|
report.bytes_written,
|
|
report.read_back_rows
|
|
);
|
|
println!(
|
|
" perf: elapsed={:.2} ms throughput={:.0} rows/s write={:.2} MB/s size={:.2} bytes/row compression={:.2}x",
|
|
report.elapsed_ms,
|
|
report.rows_per_sec,
|
|
report.mb_per_sec,
|
|
report.bytes_per_row,
|
|
report.compression_ratio
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchParquetShorts(rows)) => {
|
|
let report = match run_parquet_shorts_benchmark(rows) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: parquet shorts benchmark failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-parquet-shorts");
|
|
println!(
|
|
" input: rows={} listings={} raw_row_bytes={}",
|
|
report.rows, report.listing_count, report.raw_row_bytes
|
|
);
|
|
println!(
|
|
" output: files={} row_groups={} bytes={} read_back_rows={}",
|
|
report.files_written,
|
|
report.row_groups_written,
|
|
report.bytes_written,
|
|
report.read_back_rows
|
|
);
|
|
println!(
|
|
" perf: elapsed={:.2} ms throughput={:.0} rows/s write={:.2} MB/s size={:.2} bytes/row compression={:.2}x",
|
|
report.elapsed_ms,
|
|
report.rows_per_sec,
|
|
report.mb_per_sec,
|
|
report.bytes_per_row,
|
|
report.compression_ratio
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchParquetEvents(rows)) => {
|
|
let report = match run_parquet_events_benchmark(rows) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: parquet events benchmark failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-parquet-events");
|
|
println!(
|
|
" input: rows={} listings={} avg_raw_row_bytes={:.1}",
|
|
report.rows, report.listing_count, report.avg_raw_row_bytes
|
|
);
|
|
println!(
|
|
" output: files={} row_groups={} bytes={} read_back_rows={}",
|
|
report.files_written,
|
|
report.row_groups_written,
|
|
report.bytes_written,
|
|
report.read_back_rows
|
|
);
|
|
println!(
|
|
" perf: elapsed={:.2} ms throughput={:.0} rows/s write={:.2} MB/s size={:.2} bytes/row compression={:.2}x",
|
|
report.elapsed_ms,
|
|
report.rows_per_sec,
|
|
report.mb_per_sec,
|
|
report.bytes_per_row,
|
|
report.compression_ratio
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchParquetFx(rows)) => {
|
|
let report = match run_parquet_fx_benchmark(rows) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: parquet fx benchmark failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-parquet-fx");
|
|
println!(
|
|
" input: rows={} pairs={} raw_row_bytes={}",
|
|
report.rows, report.pair_count, report.raw_row_bytes
|
|
);
|
|
println!(
|
|
" output: files={} row_groups={} bytes={} read_back_rows={}",
|
|
report.files_written,
|
|
report.row_groups_written,
|
|
report.bytes_written,
|
|
report.read_back_rows
|
|
);
|
|
println!(
|
|
" perf: elapsed={:.2} ms throughput={:.0} rows/s write={:.2} MB/s size={:.2} bytes/row compression={:.2}x",
|
|
report.elapsed_ms,
|
|
report.rows_per_sec,
|
|
report.mb_per_sec,
|
|
report.bytes_per_row,
|
|
report.compression_ratio
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchParquetAdj(rows)) => {
|
|
let report = match run_parquet_adj_benchmark(rows) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: parquet adj benchmark failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-parquet-adj");
|
|
println!(
|
|
" input: rows={} listings={} raw_row_bytes={}",
|
|
report.rows, report.listing_count, report.raw_row_bytes
|
|
);
|
|
println!(
|
|
" output: files={} row_groups={} bytes={} read_back_rows={}",
|
|
report.files_written,
|
|
report.row_groups_written,
|
|
report.bytes_written,
|
|
report.read_back_rows
|
|
);
|
|
println!(
|
|
" perf: elapsed={:.2} ms throughput={:.0} rows/s write={:.2} MB/s size={:.2} bytes/row compression={:.2}x",
|
|
report.elapsed_ms,
|
|
report.rows_per_sec,
|
|
report.mb_per_sec,
|
|
report.bytes_per_row,
|
|
report.compression_ratio
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchParquetCorporateActions(rows)) => {
|
|
let report = match run_parquet_corporate_actions_benchmark(rows) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: parquet corporate_actions benchmark failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-parquet-corporate-actions");
|
|
println!(
|
|
" input: rows={} listings={} raw_row_bytes={}",
|
|
report.rows, report.listing_count, report.raw_row_bytes
|
|
);
|
|
println!(
|
|
" output: files={} row_groups={} bytes={} read_back_rows={}",
|
|
report.files_written,
|
|
report.row_groups_written,
|
|
report.bytes_written,
|
|
report.read_back_rows
|
|
);
|
|
println!(
|
|
" perf: elapsed={:.2} ms throughput={:.0} rows/s write={:.2} MB/s size={:.2} bytes/row compression={:.2}x",
|
|
report.elapsed_ms,
|
|
report.rows_per_sec,
|
|
report.mb_per_sec,
|
|
report.bytes_per_row,
|
|
report.compression_ratio
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Ok(CliAction::BenchCurateBars(rows)) => {
|
|
let report = match run_curate_bars_benchmark(rows) {
|
|
Ok(report) => report,
|
|
Err(err) => {
|
|
eprintln!("error: curate-bars benchmark failed: {err}");
|
|
return ExitCode::FAILURE;
|
|
}
|
|
};
|
|
println!("curate-etl bench-curate-bars");
|
|
println!(
|
|
" input: rows={} qm_rows={} splits={} keys={}",
|
|
report.rows, report.qm_rows_in, report.split_event_count, report.key_count
|
|
);
|
|
println!(
|
|
" stage: rows_out={} listings_out={} elapsed={:.2} ms throughput={:.0} rows/s latency={:.2} ns/row extrap_846M={:.1}s ({:.2}m) checksum=0x{:016x}",
|
|
report.rows_out,
|
|
report.listings_out,
|
|
report.stage_elapsed_ms,
|
|
report.stage_rows_per_sec,
|
|
report.stage_ns_per_row,
|
|
report.stage_extrap_846m_secs,
|
|
report.stage_extrap_846m_secs / 60.0,
|
|
report.checksum
|
|
);
|
|
println!(
|
|
" parquet: files={} row_groups={} bytes={} read_back_rows={} elapsed={:.2} ms throughput={:.0} rows/s",
|
|
report.files_written,
|
|
report.row_groups_written,
|
|
report.bytes_written,
|
|
report.read_back_rows,
|
|
report.parquet_elapsed_ms,
|
|
report.parquet_rows_per_sec
|
|
);
|
|
println!(
|
|
" total: elapsed={:.2} ms throughput={:.0} rows/s extrap_846M={:.1}s ({:.2}m)",
|
|
report.total_elapsed_ms,
|
|
report.total_rows_per_sec,
|
|
report.total_extrap_846m_secs,
|
|
report.total_extrap_846m_secs / 60.0
|
|
);
|
|
println!(
|
|
" stats: unmapped={} missing_curr={} ts_oor={} coll_collapsed={} coll_dropped={} mismatch_samples={}",
|
|
report.stats.dropped_unmapped,
|
|
report.stats.dropped_missing_currency,
|
|
report.stats.dropped_ts_out_of_range,
|
|
report.stats.listing_collision_collapsed,
|
|
report.stats.listing_collision_dropped,
|
|
report.mismatch_samples_out
|
|
);
|
|
ExitCode::SUCCESS
|
|
}
|
|
Err(msg) => {
|
|
eprintln!("error: {msg}");
|
|
eprintln!("{}", format_usage_stderr(NAME));
|
|
ExitCode::FAILURE
|
|
}
|
|
}
|
|
}
|