-
Notifications
You must be signed in to change notification settings - Fork 308
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
Track-caller panics #975
Track-caller panics #975
Conversation
So I tried the benchmarks in the repo just to see if there were any glaring issues but the results seemed very noisy and an even mix of faster than master or slower than master. I'll create some more directed benchmarks and try to figure out what the impact is |
If we can find, a non-microbenchmark like mentioned #972 |
Okay so I created this microbenchmark of slicing: use criterion::{black_box, criterion_group, criterion_main, Criterion};
use ndarray::{s, Array3};
use ndarray_rand::RandomExt;
use ndarray_rand::rand_distr::Uniform;
fn slice_benchmark(c: &mut Criterion) {
let data: Array3<f64> = Array3::random((64,64,64), Uniform::new(0., 10.));
c.bench_function("slice", |b| b.iter(|| {
data.slice(black_box(s![.., 24..50, ..])).shape();
}));
}
criterion_group!(benches, slice_benchmark);
criterion_main!(benches); Results: 0.15.0 This PR Results folder here: |
Personally, I reckon the shift in the results between the two is probably down to something else scheduled by my OS taking some cycles away and these two versions can be considered equivalent in performance (just from this benchmark). Whether this microbenchmark is good enough to check the impact of track caller is down to someone more familiar with ndarray internals 🙂 |
Any thoughts about the benchmark @bluss ? |
The maintainers have asked for judicious use of the track caller attribute and applying it everywhere is funny to me 🙂 because it's basically the literal opposite by the dictionary of what judicious means. Maintainers have asked for a holistic benchmark - maybe a real program that uses ndarray for a lot of varied operations. I hope it explains what I mean. If the contributor doesn't want to be judicious or whatever, then the maintainer instead has to judge line by line if the additions make sense. And I don't have the investment to do that at the moment, sorry. In short this PR is stalling a bit since it seems to go a bit against every instruction that I have given to try to guide its resolution. |
A general nice github feature: please use a line like "Fixes #972" to the PR description when making a change that closes an issue. Issues should be closed automatically on merge, that's the nice thing. PR titles and descriptions should also be updated to reflect the current state of the PR, before merge. (Now that might be moot here - but using this tip makes you a better PR-maker as a whole). |
So I didn't apply it everywhere the PR title is a bit inaccurate in that sense. I only applied it on public API functions figuring only panics that can be caused directly by user code should be tracked. But I'll go through them and aim to reduce the scope further. Oh I misread the non-microbenchmark as microbenchmark sorry that ones on me. I was looking at some projects like linfa to see if I could find bigger example projects that used some methods that panicked but I didn't find anything that looked useful. I'll go back to that. |
db87903
to
ab03657
Compare
Updated to master and conflicts resolved, I hope. |
ab03657
to
2cb374a
Compare
Squashed to clean up history. Current merge queue config will create a merge commit at the end too. |
Thanks, sorry for the delay. |
Add track caller to any function, method, trait that has a documented panics section. I also used cargo fmt to tidy up my semi-auto track_caller labelling so there may be other changes but they'll just be formatting.
Still need to assess the performance impact of all these track callers!
Fixes #972