-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Some Clippy lints #642
Some Clippy lints #642
Conversation
@@ -1552,8 +1558,8 @@ where | |||
{ | |||
if let Some(slc) = self.as_slice_memory_order_mut() { | |||
// FIXME: Use for loop when slice iterator is perf is restored | |||
for i in 0..slc.len() { | |||
f(&mut slc[i]); | |||
for x in slc.iter_mut() { |
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.
Are the performance issues solved now? This comment was from several years ago
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.
The commit adding the comment (86415f7) says
Use counted loop in unordered_foreach_mut
This improves the generated code for the inner loop we use for
.assign_scalar() and other array operations with a single scalar.The old code would generate something that looked like it assumed the
element being written to and the iterator's pointer could alias another. This
new version is unrolled and vectorized to a larger degree, but it does
still not produce memset for some inputs like rust could do in january 2016.name before ns/iter after ns/iter diff ns/iter
diff %
assign_scalar_2d_corder 1,631 868 -763 -46.78%
assign_scalar_2d_cutout 1,704 1,332 -372 -21.83%
assign_scalar_2d_forder 1,628 869 -759 -46.62%
assign_zero_2d_corder 1,602 855 -747 -46.63%
assign_zero_2d_cutout 1,703 1,335 -368 -21.61%
assign_zero_2d_forder 1,618 858 -760 -46.97%before: Using the slice iterator
after: using indexed loop.
I tried switching the implementation to use for_each
and got the same results for these benchmarks as the range-based implementation, so I think that would work well. (I didn't try a for
loop.)
if let Some(slc) = self.as_slice_memory_order_mut() {
slc.iter_mut().for_each(f);
} else {
for row in self.inner_rows_mut() {
row.into_iter_().fold((), |(), elt| f(elt));
}
}
(Fwiw, I tried switching the .fold
to .for_each
too, but that hurt performance on the *_cutout
benchmarks. That may be worth looking into. (Do we need to implement for_each
for IterMut
instead of relying on the default implementation?))
b8317ca
to
ac4eeb4
Compare
I've ended up pushing through and either correcting them all or ignoring them. A couple I need help on - they're 'allowed' for the moment, but my rust understanding wasn't enough to solve the issue in a reasonable way. |
Hi team - any thoughts here? Would be great to get some of this merged before we start getting conflicts Happy to split into an 'easy' PR and one that requires more discussion if anything requires that |
The behavior should be identical.
`Send` and `Sync` are automatically implemented, so manual implementations aren't necessary.
This avoids any issues associated with deriving `PartialEq` but manually implementing `Hash`.
Yes @alex179ohm - I think those are covered by this PR, is that correct? |
# Conflicts: # src/impl_views.rs
Add comment on axis as remainder.
@max-sixty, no |
I think this wants a semver version, so |
If this is still an open issue, shall I remove that change so we can merge? I'm cognizant that this touches a lot of code and keen to avoid merge conflicts |
@max-sixty All clippy warnings are fixed on your clippy branch? If so it could be fine add clippy on the CI/travis build pipeline |
Ask and ye shall receive: https://github.com/rust-ndarray/ndarray/pull/642/files?file-filters%5B%5D=.sh#diff-407dae7942292c08ef6b0f9b2b8c2677R17 |
I agree that this PR touches a lot of code and it would be better to get it merged sooner rather than later (even more so because several people try to have a go at it, and we end up with duplicate effort). |
Great, done @LukeMathWalker |
Merged @max-sixty 👍 Can you open an issue to track the remaining lints? |
Great - @LukeMathWalker - here: #657 Let me know if I missed anything |
I'm trying to get familiar with the repo and thought this was a reasonable way to start.
It's not complete - there are a lot of
immediately dereferencing a reference
arounds!
invocations (some I explicitly ignored), and some around usingassert_eq
on f32 & f64.It's not yet possible to set Clippy rules for a whole workspace - it's required to do crate-by-crate - so there are some standard
ignore
pieces copied and pasted. I'm not sure how to do this for the test path which don't have alib.rs
ormod.rs
.