Skip to content

Replace deprecated structopt with clap in benchmarks crate #19482

@Yuvraj-cyborg

Description

@Yuvraj-cyborg

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

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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions