Conversation
| /// vector clocks are not necessary | ||
| #[cfg(all(not(test), not(feature = "vector-clocks")))] | ||
| #[derive(Clone, Debug, PartialEq, Eq)] | ||
| pub struct VectorClock; |
There was a problem hiding this comment.
My suggestion is to remove this and cfg all usages of VectorClock
There was a problem hiding this comment.
it would be nice to not need a dummy implementation, but the issue with doing this is that there are other structs that have VectorClock's (e.g.
#[cfg...]'s.
the dummy implementation keeps this PR quite small and gives us probably 99% of the performance benefits
0e71f72 to
0c12dcd
Compare
| trybuild = "1.0" | ||
| pin-project = "1.1.3" | ||
| # The following line is necessary to ensure vector-clocks are used for integration tests | ||
| # To run performance tests without vector clocks using `cargo bench`, this line must be commented out |
There was a problem hiding this comment.
It is possible to do benching without vector clocks by introducing a feature (eg. bench-no-vector-clocks) and then gating vector clocks on all(any(test, feature = "vector-clocks"), not(feature = "bench-no-vector-clocks")
There was a problem hiding this comment.
Yup, this would allow you to run the benchmarks without vector clocks by enabling the feature at the command line rather than commenting this line out, which I agree is better. I can add it, but I am getting worried that this setup is a little counter-intuitive (feature is disabled by default, but always enabled for tests and benchmarks unless you use this other feature flag).
I'm starting to think it might be better to enable vector clocks by default, add it as a "required feature" for tests, and add a gated compile error to prevent ever using cargo test without the feature. I think this is slightly more intuitive: if the feature is enabled its enabled everywhere and if it is disabled, it is disabled everywhere (but should result in compile errors for testing). For example:
Sorry for the back and forth on this!
There was a problem hiding this comment.
I think default enabling vector clocks (or most features tbh) is a mistake:
- It is a "poweruser" feature with runtime performance costs.
- The default offerings should be sensible. This is not a sensible default (noone has ever used it).
- The standard recommendation will be "oh and yeah, disable this feature" which is just bad UX.
- Feature enablement is additive. Having it as a default makes accidental opt-in the standard, which is a pain for projects which span multiple packages.
- One should opt-in to the functionality one wants, not opt-out of the functionality one does not want.
This PR adds a feature flag for vector clocks to boost Shuttle's testing throughput when they are not needed.
This feature flag is disabled by default in production, but always enabled for tests because many tests leverage vector clocks for assertions to check correctness. In the micro-benchmarks for the Shuttle repository, this results in performance gains of 5-25%:
criterion.tar.gz
When disabled, the VectorClock struct is replaced by an empty struct for which all operations are i.e. a no-op.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.