Skip to content
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

Merged
merged 38 commits into from
Jul 11, 2019
Merged

Some Clippy lints #642

merged 38 commits into from
Jul 11, 2019

Conversation

max-sixty
Copy link
Contributor

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 around s! invocations (some I explicitly ignored), and some around using assert_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 a lib.rs or mod.rs.

@@ -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() {
Copy link
Contributor Author

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

Copy link
Member

@jturner314 jturner314 Jul 20, 2019

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?))

@max-sixty max-sixty force-pushed the clippy branch 2 times, most recently from b8317ca to ac4eeb4 Compare June 13, 2019 20:39
@max-sixty
Copy link
Contributor Author

max-sixty commented Jun 13, 2019

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.
And a few need a review - I'm sure my solutions won't be optimal is some of the cases.

@max-sixty
Copy link
Contributor Author

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

alex179ohm added a commit to alex179ohm/ndarray that referenced this pull request Jul 4, 2019
alex179ohm added a commit to alex179ohm/ndarray that referenced this pull request Jul 4, 2019
@alex179ohm alex179ohm mentioned this pull request Jul 4, 2019
alex179ohm added a commit to alex179ohm/ndarray that referenced this pull request Jul 4, 2019
@max-sixty
Copy link
Contributor Author

Yes @alex179ohm - I think those are covered by this PR, is that correct?

@LukeMathWalker LukeMathWalker mentioned this pull request Jul 4, 2019
31 tasks
# Conflicts:
#	src/impl_views.rs
alex179ohm added a commit to alex179ohm/ndarray that referenced this pull request Jul 5, 2019
alex179ohm added a commit to alex179ohm/ndarray that referenced this pull request Jul 5, 2019
Add comment on axis as remainder.
@alex179ohm
Copy link

@max-sixty, no
Unfortunately, the nice-semver error still remain until the 0.13 will be released

@max-sixty
Copy link
Contributor Author

Unfortunately, the nice-semver error still remain until the 0.13 will be released

I think this wants a semver version, so 0.13.0, not necessarily a released version. That change is in this PR

alex179ohm added a commit to alex179ohm/ndarray that referenced this pull request Jul 5, 2019
alex179ohm added a commit to alex179ohm/ndarray that referenced this pull request Jul 5, 2019
alex179ohm added a commit to alex179ohm/ndarray that referenced this pull request Jul 6, 2019
@max-sixty
Copy link
Contributor Author

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

@alex179ohm
Copy link

@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

@max-sixty
Copy link
Contributor Author

max-sixty commented Jul 9, 2019

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

@LukeMathWalker
Copy link
Member

LukeMathWalker commented Jul 10, 2019

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).
I know @jturner314 cannot put much time in ndarray right now, so I would propose to set aside #642 (comment) until we have time to go back at it. You can use a deny statement to make the linting pass, so that we can merge the rest. What do you think @max-sixty?

@max-sixty
Copy link
Contributor Author

Great, done @LukeMathWalker

@LukeMathWalker LukeMathWalker merged commit 98bf3b6 into rust-ndarray:master Jul 11, 2019
@LukeMathWalker
Copy link
Member

Merged @max-sixty 👍 Can you open an issue to track the remaining lints?
@alex179ohm - should I close the other PR or are there additional changes there that we need to review?

@max-sixty
Copy link
Contributor Author

Great - @LukeMathWalker - here: #657

Let me know if I missed anything

@max-sixty max-sixty deleted the clippy branch July 11, 2019 15:50
jturner314 added a commit to jturner314/ndarray that referenced this pull request Jul 20, 2019
jturner314 added a commit to jturner314/ndarray that referenced this pull request Jul 20, 2019
@jturner314 jturner314 mentioned this pull request Jul 20, 2019
LukeMathWalker pushed a commit that referenced this pull request Aug 4, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants