-
Notifications
You must be signed in to change notification settings - Fork 311
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
Version 0.4.0 #496
Version 0.4.0 #496
Conversation
* Disable warnings about HTML reports and standalone support. * Include 'html_reports' in the set of stable features. * Suppress html and csv if the feature flags are missing. * Make the CSV dependency optional. * Group optional dependencies in cargo manifest. * Test both with all features and no features.
Some tools (e.g., rhysd/github-actions-benchmark) that parse the output of criterion do not correctly parse the standard output if it contains an unexpected string, such as an error message. The fix in this commit ensures that the tool will work correctly in environments where gnuplot is not installed (e.g., GitHub Actions runners). Also, from the conventions of the command line interface, it is preferable that such error messages be output to stderr.
* Make the plotters dependency optional. * Turn rayon into an optional dependency. * Add cli flag for discarding baselines rather than saving them to disk. * Disable plotting if html_reports is disabled. * Support testing with and without the html_reports flag.
* Accept subsecond durations from the command line. * Replace 'to_nanos' with 'as_nanos'. 'as_nanos' stabilized in 1.33.
* Add --quiet flag. When enabled, only a single line is printed per benchmark. * Print warnings and errors to stderr.
@@ -17,6 +17,7 @@ license = "Apache-2.0/MIT" | |||
exclude = ["book/*"] |
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 think it would be good to set version = "0.4.0" now.
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.
Would that make it easier for people to test this branch?
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.
It was easier for me to test with it left as-is, because I could use [patch.crates-io]
to insert it into other dependencies like criterion-cycles-per-byte
and pprof
.
Cargo.toml
Outdated
@@ -26,21 +27,24 @@ serde_derive = "1.0" | |||
serde_cbor = "0.11" | |||
atty = "0.2" | |||
clap = { version = "2.33", default-features = false } |
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.
My initial feedback: This branch with default-features=false
and opting into no optional features is a drop-in replacement for 0.3.4 for me insofar as my benchmarks build and run using this version, simply with this change:
[dev-dependencies]
-criterion = "0.3.5"
+criterion = { git = "https://github.com/bheisler/criterion.rs", branch = "version-0.4", commit = "7b8030b1223adacebf81b8e1cb3286a83e7a2470", default-features=false}
How practical would it be to move the anes
, atty
, clap
, criterion-plot
, and serde_cbor
(at least) dependencies out of the "no default features" configuration?
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.
Here's the cargo-tree of dependencies with default-features=false
:
│ ├── anes v0.1.6
│ ├── atty v0.2.14
│ │ └── winapi v0.3.9
│ ├── cast v0.2.7
│ │ [build-dependencies]
│ │ └── rustc_version v0.4.0
│ │ └── semver v1.0.4
│ ├── clap v2.33.3
│ │ ├── bitflags v1.3.2
│ │ ├── textwrap v0.11.0
│ │ │ └── unicode-width v0.1.8
│ │ └── unicode-width v0.1.8
│ ├── criterion-plot v0.4.3 (https://github.com/bheisler/criterion.rs?branch=version-0.4#7b8030b1)
│ │ ├── cast v0.2.7 (*)
│ │ └── itertools v0.10.1
│ │ └── either v1.6.1
│ ├── itertools v0.10.1 (*)
│ ├── lazy_static v1.4.0
│ ├── num-traits v0.2.14
│ │ [build-dependencies]
│ │ └── autocfg v1.0.1
│ ├── oorandom v11.1.3
│ ├── regex v1.5.4
│ │ └── regex-syntax v0.6.25
│ ├── serde v1.0.128
│ ├── serde_cbor v0.11.2
│ │ ├── half v1.7.1
│ │ └── serde v1.0.128
│ ├── serde_derive v1.0.128 (proc-macro)
│ │ ├── proc-macro2 v1.0.28
│ │ │ └── unicode-xid v0.2.2
│ │ ├── quote v1.0.9
│ │ │ └── proc-macro2 v1.0.28 (*)
│ │ └── syn v1.0.75
│ │ ├── proc-macro2 v1.0.28 (*)
│ │ ├── quote v1.0.9 (*)
│ │ └── unicode-xid v0.2.2
│ ├── serde_json v1.0.66
│ │ ├── itoa v0.4.8
│ │ ├── ryu v1.0.5
│ │ └── serde v1.0.128
│ ├── tinytemplate v1.2.1
│ │ ├── serde v1.0.128
│ │ └── serde_json v1.0.66 (*)
│ └── walkdir v2.3.2
│ ├── same-file v1.0.6
│ │ └── winapi-util v0.1.5
│ │ └── winapi v0.3.9
│ ├── winapi v0.3.9
│ └── winapi-util v0.1.5 (*)
Some comments:
│ ├── cast v0.2.7
│ │ [build-dependencies]
│ │ └── rustc_version v0.4.0
│ │ └── semver v1.0.4
Not sure that cast
is really carrying its weight considering the overhead it adds to the build. Either we could try to remove cast
or we could work with the cast
developers to simplify its build dependencies; I filed japaric/cast.rs#35 to that effect.
│ ├── clap v2.33.3
│ │ ├── bitflags v1.3.2
│ │ ├── textwrap v0.11.0
│ │ │ └── unicode-width v0.1.8
│ │ └── unicode-width v0.1.8
I don't fully understand how important clap::value_t
is or how difficult it would be to replace, but I noticed if we could avoid using clap::value_t
then we wouldn't need to depend on clap
when the cargo-clippy
feature isn't selected. So I think it is worth trying to find an alternative to value_t
.
│ ├── serde v1.0.128
│ ├── serde_cbor v0.11.2
│ │ ├── half v1.7.1
│ │ └── serde v1.0.128
│ ├── serde_derive v1.0.128 (proc-macro)
│ │ ├── proc-macro2 v1.0.28
│ │ │ └── unicode-xid v0.2.2
│ │ ├── quote v1.0.9
│ │ │ └── proc-macro2 v1.0.28 (*)
│ │ └── syn v1.0.75
│ │ ├── proc-macro2 v1.0.28 (*)
│ │ ├── quote v1.0.9 (*)
│ │ └── unicode-xid v0.2.2
│ ├── serde_json v1.0.66
│ │ ├── itoa v0.4.8
│ │ ├── ryu v1.0.5
│ │ └── serde v1.0.128
Serde is a very heavy dependency. Granted, most of my projects use it anyway, so eliminating serde and serde-derive wouldn't have as wide an impact as removing other dependencies. However, I think finding a way to remove serde_cbor
or serde_json
(perhaps just default to one or the other) or both (In my CI jobs, I don't want any serializatoin at all since I don't do anything with serialized output; I just want to verify that the benchmarks still build and run) would be a good win.
│ └── walkdir v2.3.2
│ ├── same-file v1.0.6
│ │ └── winapi-util v0.1.5
│ │ └── winapi v0.3.9
│ ├── winapi v0.3.9
│ └── winapi-util v0.1.5 (*)
Again, in the pretty common situation where in CI where we're only verifying that the benchmarks compile and run correctly, and where we don't want any persistence anyway, we should be able to eliminate all the functionality that does file I/O and then eliminate this pretty heavy dependency.
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.
It should be possible to make serde
an optional dependency and have functionality degrade gracefully (ie. running/testing benchmarks should still work but saving/loading baselines would print an error message). I'll gladly review such a PR.
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.
How practical would it be to move the
anes
,atty
,clap
,criterion-plot
, andserde_cbor
(at least) dependencies out of the "no default features" configuration?
criterion-plot
is scheduled to be removed entirely (either in version 0.4 or 0.5). serde
could be optional but it would take a fair bit of work/refactoring. I guess anes
and atty
could be optional but they're so tiny that I don't really see the point. clap
is quite vital, though, and I don't see how criterion could work without it.
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'll gladly review such a PR.
OK, when I have time, I will try that. Will you be merging this PR (#496) soon? It would be easier for me to make my PRs on top of this one.
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'll gladly review such a PR.
OK, when I have time, I will try that. Will you be merging this PR (#496) soon? It would be easier for me to make my PRs on top of this one.
Probably won't be merged any time soon. You can submit your PR directly against this branch: Checkout version-0.4
, push a new branch, and create a PR (or draft PR) with the target being version-0.4
from the drop-down menu.
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 had intended for command-line parsing and output and the like to start shifting over to cargo-criterion
with the 0.4 release, so I think clap
and anes
and related crates should be behind the cargo-bench-support
feature. That code would need to still be available in criterion-rs
for the time being to give users time to migrate over to cargo-criterion
(that's the purpose of the cargo-bench-support
feature).
With the PR as it is today, here is the effect on one of my projects: +name = "anes"
-name = "bstr"
-name = "crossbeam-channel"
-name = "crossbeam-deque"
-name = "crossbeam-epoch"
-name = "crossbeam-utils"
-name = "csv"
-name = "csv-core"
-name = "memchr"
-name = "memoffset"
-name = "num_cpus"
-name = "plotters"
-name = "plotters-backend"
-name = "plotters-svg"
-name = "rayon"
-name = "rayon-core"
-name = "regex-automata"
-name = "scopeguard" A net reduction of 16 dependencies. |
cast.rs 0.3.0 has been released with fewer dependencies. |
I tested db880ab on several of my projects, by adding the following patch: [patch.crates-io]
criterion = { git = "https://github.com/bheisler/criterion.rs", rev = "db880abe2ff8b3c1c208d2e8ead4e21fbe1e05a4" } No issues at all; it's a drop-in replacement and I didn't have to alter any code. Even the projects that use I also confirmed (after removing |
#497 confuses me: it says that the I noticed this while looking into making Since feature flags should always be additive, I think that implies we should also have a |
Opened #541 to add |
* Enable --quick mode. * Add basic user guide for the new 'quick mode'.
* Document WASM support with wasmer, wasmtime, nodejs, and browsers.
Clap v3 is a new major version of clap with several deprecations and breaking changes, all of which are addressed within this commit.
OK, so I've taken a look over this. Most of it looks great. I'm a bit skeptical about the quick mode, but I could be convinced if people find it useful and reliable. If it's going to be added to I'm a lot skeptical about vendoring critcmp, especially into this repo as opposed to If we are going to add this feature, I'd rather work with BurntSushi to have just one copy of that code. Would he be open to providing it as a library crate we can pull in? Or, a hacky sort of solution, could we have Many of these changes should be made to |
BurntSushi doesn't want to maintain the code (neither as a library or as an executable). If we want the functionality to be part of the documented workflow for criterion then we have to maintain it ourselves. I'm volunteering to be responsible for it. You're completely right that it doesn't belong in criterion.rs. How would you feel about me maintaining it as part of cargo-criterion? I think it's either that or we delete it and don't mention it in the documentation. |
Hm, I didn't realize it was abandoned. One of the long-term problems I've had in maintaining Criterion-rs is that - since I haven't been writing (or benchmarking) much Rust code aside from sporadically maintaining Criterion - I don't really feel like I have a strong vision or opinion on how the workflow should evolve. Well, aside from introducing cargo-criterion to reduce compile- and link-time, as previously mentioned. If you think critcmp is a worthy addition to that workflow, I'd be okay with merging it into cargo-criterion. |
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.
Just a couple of things I noticed when working on #599
src/lib.rs
Outdated
.help("Limit the baselines used in tabulated results.") | ||
.help("")) |
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.
.help("Limit the baselines used in tabulated results.") | |
.help("")) | |
.help("Limit the baselines used in tabulated results.")) |
src/lib.rs
Outdated
}; | ||
|
||
let args = critcmp::app::Args { | ||
baselines: matches.values_of_lossy("baselines").unwrap_or_default(), |
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.
Parsing this causes a panic at runtime
thread 'main' panicked at 'Must use `Arg::allow_invalid_utf8` with `_os` lookups at `[hash: 570E2D9D9139F734]`', /.../cargo/registry/src/github.com-1ecc6299db9ec823/clap-3.2.12/src/parser/matches/arg_matches.rs:1732:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
This may be one of the errors that gets caught by debug_assert()
* Delete critcmp code (it belongs in cargo-criterion) * Bump MSRV to 1.57 due to os_str_bytes. * Mention MSRV bump in CHANGELOG.
@bheisler I removed the critcmp code. Let me know if there's anything else we need to look at before 0.4 can be released. |
Only nice-to-haves, I think. I'll try and check over everything and hopefully publish 0.4.0 this weekend. |
Unfortunately a bunch of things came up and I was not able to get to it during the weekend, but I haven't forgotten. |
No worries! Things happen — I'm sure everyone can understand that. |
Thanks for your patience, everyone. I've merged and published 0.4.0. |
@@ -425,4 +525,4 @@ more details | |||
[0.3.3]: https://github.com/bheisler/criterion.rs/compare/0.3.2...0.3.3 | |||
[0.3.4]: https://github.com/bheisler/criterion.rs/compare/0.3.3...0.3.4 | |||
[0.3.5]: https://github.com/bheisler/criterion.rs/compare/0.3.4...0.3.5 | |||
[0.3.5]: https://github.com/bheisler/criterion.rs/compare/0.3.5...0.3.6 | |||
[0.3.5]: https://github.com/bheisler/criterion.rs/compare/0.3.5...0.3.6 |
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 should be [0.3.6]
Changes:
Criterion::can_plot
function has been removed.Criterion::bench_function_over_inputs
function has been removed.Criterion::bench_functions
function has been removed.Criterion::bench
function has been removed.--feature csv_output
is now required for csv output.--feature html_reports
is now required for html output.--discard-baseline
flag.rayon
andplotters
are optional (and default) dependencies.anes
crate.