Skip to content

Conversation

@Yuvraj-cyborg
Copy link
Contributor

Which issue does this PR close?

Closes - #19482
(Part of #19072 )

Rationale for this change

The structopt crate is deprecated and has been superseded by clap with its derive feature.
This migration:

  • Removes a deprecated dependency
  • Potentially improves compilation times for the benchmarks crate
  • Keeps the codebase up-to-date with modern Rust ecosystem practices

What changes are included in this PR?

  • Updated Cargo.toml to use clap = { version = "4.5.53", features = ["derive"] } instead of structopt

  • Migrated all benchmark source files to use clap's derive macros:

  • #[derive(StructOpt)]#[derive(Parser/Args/Subcommand)]

  • #[structopt(...)]#[arg(...)] for fields

  • #[structopt(...)]#[command(...)] for struct/enum-level attributes

  • StructOpt::from_args()Parser::parse()

  • Removed parse(from_os_str) as PathBuf works natively in clap

  • Changed short flag strings to chars ('p' instead of "p")

Are these changes tested?

Yes

Are there any user-facing changes?

No. The CLI interface remains identical - this is a drop-in replacement of the underlying argument parsing library.

@Yuvraj-cyborg
Copy link
Contributor Author

cc: @alamb @Jefffrey @martin-g @timsaucer

@Yuvraj-cyborg
Copy link
Contributor Author

@Jefffrey could u review this one !?

@Jefffrey
Copy link
Contributor

I'll try take a look when I have time

#[structopt(name = "IMDB", about = "IMDB Dataset Processing.")]
#[derive(Debug, Parser)]
#[command(name = "IMDB", about = "IMDB Dataset Processing.")]
enum ImdbOpt {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unconventional - #[derive(Parser)] + enum.

Let's keep it consistent with the other binaries, e.g.:

#[derive(Debug, Parser)]
struct Cli {
    #[command(subcommand)]
    command: ImdbOpt,
}

#[derive(Debug, Subcommand)]
enum ImdbOpt {
    Benchmark(BenchmarkSubCommandOpt),
    Convert(imdb::ConvertOpt),
}
...

/// Default value is the small files for join x table, small table, medium table, big table files in the h2o benchmark
/// This is the small csv file case
#[structopt(
short = "join-paths",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻
This seems to have been a bug in the old impl. I guess structopt ignored it and used the first letter of the field name (j)
It is good that Clap uses a char for short!

#[structopt(name = "Memory Profiling Utility")]
#[derive(Debug, Parser)]
#[command(name = "Memory Profiling Utility")]
struct MemProfileOpt {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Shall it rename it to Cli to make it consistent with the other binaries ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants