-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add the start of a basic benchmarking suite. #9955
Conversation
r? @Eh2406 (rust-highfive has picked a reviewer for you, use r? to override) |
Looks like this has committed a lot of files! (1571) So many that my browser crashes trying to review the change. Is this intentional? If so should we have it in repo or find some way to make it opt in? |
Hm, yea, that is a lot. Those are all the |
">700" of them are |
Ok, I pushed an update that uses compressed workspaces. That should be much lighter, though it still adds nearly 500k of data. 😦 |
Passing thought: instead of tarballs, which may end up being somewhat painful to maintain, perhaps editing the Cargo.toml's to point to a single (empty) lib.rs might make sense? It looks like across the current tarballs there are 775 .rs files, 780 .toml, and 9 .lock files -- keeping the .toml and .lock files easily accessible seems like a win to me (for understanding the benchmarks, at least), while merging all the .rs files seems both not too hard and relatively impactful - roughly 2x less files. That'll probably also shrink the .tgz files checked in here, I imagine. FWIW with perf.rust-lang.org we initially had all the benchmarks in a separate repository but that ended up being quite painful, so we gave up on that and moved them all in-tree. (There we have much less ability to delete files, though, other than tests and such). |
Yea, I was reluctant to move to compressed files because it is a bit harder to see them and see changes in PRs. My thinking of why compressed files may not be too bad:
I briefly considered having it just fetch the repos from GitHub, but things like firefox are too large even with a shallow fetch. But yea, I agree storing compressed files is not great. |
Yeah, it's a good point that they are highly unlikely to change. I guess one question might be "should this be in rust-lang/cargo", or should we have a rust-lang/cargo-perf (like rustc-perf)? I think it probably isn't worth worrying over creating a new repository and such for the ~380 KB added in this PR, particularly as it's likely to be static data, and we're not anticipating major investment & expansion at this time. It can also be moved out in the future. |
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.
This looks great to me, thanks for adding this! I think the capture
tool is especially useful here and makes it pretty flexible into the future. I agree that it'd be good to add more here but that's all fine to have as later PRs.
I personally think it's ok to add a few tarballs here and not try to uncompress them. One thing I might add, though, is could the git commit that they were created from get added to the tarball? Ideally that'd make it easier to deterministically reproduce them in the future. If things become unwieldy otherwise we can always move them out to a separate repository or something like that.
For CI, is it possible to execute the actual benchmarks, but perhaps with just one iteration? Ideally I'd like to make sure that things don't panic at runtime in addition to at least being able to compile.
According to the docs the incantation for that is
Yes, but even if we do they will still be making the history bigger. Witch makes CI slower for us and rustc. Evan so I think it makes sense to have them in tree. Theoretically, if there is a lock file then all the processing should be Over all I like this, and big thank you to @ehuss for making it! |
I pushed an update with a few changes:
|
// TODO: There doesn't seem to be a way to register ws_resolve as | ||
// a setup function that only gets run once. This can't be placed | ||
// outside of `bench_function` because then it wouldn't get | ||
// filtered when passing command-line filters. | ||
// | ||
// https://github.com/bheisler/criterion.rs/issues/514 implies it | ||
// is not possible. Unfortunately this means that this runs | ||
// unnecessarily for every "sample". |
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.
This is the part I was having trouble with. I don't see a way around it, but maybe I am confused on how this all works. It seems to always do 100 samples, with only 1 iteration per sample. I kinda want the opposite, but there is a minimum of 10 samples.
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.
I wonder if a lazy_static
would work well here. Yes the first call would be slow, but that is why criterion has warm-up calls. Not shore that it would be better.
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.
Oh, good idea! I just pushed an update that actually just uses an Option
to initialize it only once. That helps the benchmarks run quite a bit faster.
I also disabled servo on windows, since it fails with paths that are too long. |
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.
Looks great to me! @Eh2406 did you have anything else you wanted to add?
I want to give this a try and another look over. I hope to do so this weekend. Sorry for the delay. |
Over all I love it! It does not make a big impact to checkout size, so happy to have it in tree. A plain call to
I wonder if we could ignore patches? Or replace them with skeletons stored in the I tried looking at a flame graph, and a bout 1/3 of time is spent in |
I added
I had a suspicion that was why the firefox resolve was so slow. I think keeping the git dependencies is worth it to illuminate issues exactly like this. It's the fact that it is scanning an entire git repo every time that is hurting performance, and if we just used the skeletons it wouldn't be benchmarking the real-world behavior. It might be a good idea into looking at caching the locations of packages in a git repo so it doesn't need to walk the entire tree and parse every Cargo.toml. I think that could be a very big win. |
Thank you! |
📌 Commit e4da5b2 has been approved by |
☀️ Test successful - checks-actions |
Update cargo 6 commits in c7957a74bdcf3b11e7154c1a9401735f23ebd484..7fbbf4e8f23e3c24b8afff541dcb17e53eb5ff88 2021-10-11 20:17:07 +0000 to 2021-10-19 02:16:48 +0000 - Make future-incompat-report output more user-friendly (rust-lang/cargo#9953) - Fix fetching git repos after a force push. (rust-lang/cargo#9979) - Add rustc-link-args to doctest build (rust-lang/cargo#9916) - Add the start of a basic benchmarking suite. (rust-lang/cargo#9955) - Use forms for issue templates. (rust-lang/cargo#9970) - Add rust_metadata to SerializedPackage (rust-lang/cargo#9967)
This adds the start of a basic benchmarking suite for cargo. This is fairly rough, but I figure it will change and evolve over time based on what we decide to add and how we use it.
There is some documentation in the
benches/README.md
file which gives an overview of what is here and how to use it.Closes #9935