-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use clap in miri-script #4036
Use clap in miri-script #4036
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for trying this! I agree it is quite elegant.
However, it also doubles our build times for the script. The script hopefully doesn't get built too often, so this is mostly a thing for first-time users -- they get no feedback while miri-script
itself is built. Ideally we'd build it on stable Rust so it wouldn't be rebuilt a lot, but we need some nightly cargo features for the diagnostic integration...
Overall I am leaning slightly in favor of this, just to make maintenance of the script easier. I'd still be curious how this would look like without the derive; is there a good example somewhere of what using the clap builder directly looks like?
Also @rust-lang/miri what do you all think? |
I see a regression from 2.5s to 3s, which would be fine with me. I like clap, and think it's worth a bit of compile time overhead, but doubling the compile time of miri-script seems a bit steep. I'd quite like to know what the compile time is without using the proc macro (maybe you can just |
I am measuring a slowdown from 4s to 5.2s. |
what command do you use to build? I can write a small script to measure the build times a bit more systematically. maybe I got an outlier. |
|
Using this script: #!/usr/bin/env python
import argparse
import shutil
import subprocess
import sys
import time
parser = argparse.ArgumentParser(
prog='ProgramName',
description='What the program does',
epilog='Text at the bottom of help')
parser.add_argument('-c', '--count', type=int, default=10)
if __name__ == "__main__":
args = parser.parse_args()
total_time = 0
for _ in range(args.count):
shutil.rmtree('miri-script/target', ignore_errors=True)
start_time = time.time()
subprocess.run(['./miri', '--help'], capture_output=True)
end_time = time.time()
total_time += end_time - start_time
print('.', end='')
sys.stdout.flush()
print('total time = {}, average execution time = {}'.format(total_time, total_time / args.count)) (don't judge my python skills too much) I get that without the changes i have
And with the changes
So less than 5s but also more than 3s that @saethlin observed (comparing with their results since we seem to have similar baselines). |
Absolute times are obviously going to differ. What's the relative slowdown? Seems to be 40% for you, 30% for me, 20% for saethlin. |
☔ The latest upstream changes (presumably #4041) made this pull request unmergeable. Please resolve the merge conflicts. |
Yes, these are the relative slowdowns. I compared with saethlin's numbers since we had similar baselines. What would be the threshold for an acceptable slowdown? |
IMO that is the wrong question. The right question is, how low can we get the slowdown while still getting most of the benefits of using clap (or some other similar library)? |
Ok, then I will try to make a poc using the builder api when I have a bit more time on my hands. In the meantime I built
If I interpret this correctly I don't expect the builder API to save us much time after the first compilation. But then, as long as As for how the builder API looks like, there is an example in the tutorial. Most notably, we lose some compile time checks (but of course this might be a feature in our case). For example instead of |
It gets rebuild whenever the compiler changes, which is |
Now that we decided to go with the @rustbot author |
I see that this now has conflicts. Not sure if you prefer to rebase it now or go through the review first beforehand. I also see that the checks do not run, and I am not sure why. @rustbot ready |
Please rebase first. Github doesn't run the checks if there are conflicts (since the checks are run against your PR merged with master). |
☔ The latest upstream changes (presumably #4089) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please post what the --help
output looks like? We might want to tweak the doc comments now that they are more user-visible.
miri-script/src/main.rs
Outdated
Ok(()) | ||
} | ||
Self::Bench { .. } | Self::RustcPull { .. } | Self::RustcPush { .. } => | ||
Err(anyhow::Error::msg("unexpected \"--\" found in arguments")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the bail!
macro fro anyhow.
Also please update the PR title and commit message to make it clear that this is not an experiment any more. @rustbot author |
This is what the help message looks like:
|
Co-authored-by: Ralf Jung <post@ralfj.de>
I have resolved the conflicts and done a pass over all the help texts. I noticed some things that were missing ( Should be good to go now :) |
FWIW this did change the behavior for some flags. Something like |
Use clap in miri-script, following discussion in #3592.
Simplify the code by using the derive API from clap. This way we can just declare how the cli parser should behave, instead of implementing it ourselves.
This come with a slowdown to the compilation time of miri-script, but it is acceptable compared to the benefits.