datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

Replace deprecated structopt with clap in benchmarks crate

Open yuvichh opened this issue 11 months ago • 3 comments

Is your feature request related to a problem or challenge?

The benchmarks crate (datafusion-benchmarks) uses structopt for CLI argument parsing, which has been deprecated since 2021. The structopt README explicitly states:

As of clap v3, structopt is now part of clap. Instead of using structopt, use clap directly.

structopt has not been updated in years and adds unnecessary compile-time overhead compared to modern clap derive macros.

This is part of the larger effort to improve benchmark compilation times (#19072 ).

Describe the solution you'd like

Replace structopt with clap (version 4.x) in the benchmarks crate:

Update Cargo.toml:

- structopt = { version = "0.3", default-features = false }
+ clap = { version = "4", features = ["derive"] }

Update all benchmark source files to use clap instead of structopt:

  • Change use structopt::StructOpt → use clap::Parser
  • Change #[derive(StructOpt)] → #[derive(Parser)]
  • Change #[structopt(...)] → #[arg(...)] or #[command(...)]
  • Change StructOpt::from_args() → Parser::parse()

Files to update:

  • dfbench.rs
  • run.rs
  • clickbench.rs
  • h2o.rs
  • run.rs
  • cancellation.rs
  • sort_tpch.rs
  • hj.rs
  • nlj.rs
  • Any other files using structopt

Describe alternatives you've considered

  • Keep using structopt (Not recommended as it's deprecated and unmaintained)

Additional context

  • Migration guide from structopt to clap: https://github.com/clap-rs/clap/blob/master/CHANGELOG.md#migrating

Common attribute changes:

structopt clap
#[structopt(subcommand)] #[command(subcommand)]
#[structopt(long, short)] #[arg(long, short)]
#[structopt(about = "...")] #[command(about = "...")]
#[structopt(name = "...")] #[command(name = "...")]
#[structopt(default_value = "...")] #[arg(default_value = "...")]

Related to #19072 (Benchmarks binary compilation takes too long)

yuvichh avatar Dec 24 '25 20:12 yuvichh

@alamb @Jefffrey @martin-g

let me know if this improvement is needed !! cuz clap is pretty optimized . (Self assigning meanwhile)

yuvichh avatar Dec 24 '25 20:12 yuvichh

take

yuvichh avatar Dec 24 '25 20:12 yuvichh

I think it's worth exploring

Jefffrey avatar Dec 25 '25 01:12 Jefffrey