Cleanup chunk_by count method and add tests#159389
Conversation
|
r? @Darksonn rustbot has assigned @Darksonn. Use Why was this reviewer chosen?The reviewer was selected based on:
|
e4cf709 to
f5048ba
Compare
chunk_by count method and add tests
This comment has been minimized.
This comment has been minimized.
f5048ba to
f24d014
Compare
f24d014 to
db839f3
Compare
|
@rustbot ready |
|
Would you mind just verifying that the new implementation is still able to vectorize the count? There was some sensitivity to that in the initial code. Unfortunately the existing perf suite doesn't measure this call site. My original PR used the |
|
Good point, @obi1kenobi @rustbot author |
db839f3 to
e282056
Compare
|
All comments addressed, except I'm not able to test vectorization at this time. @obi1kenobi perhaps you would be willing to test that? @rustbot ready |
|
On my current x86-64 machine this is a perf regression predominantly for short inputs, both with and without vectorization.
Looking at the assembly, the proposed new code has extra branches and conditional-moves, plus a few extra arithmetic instructions. Here's a flavor of the extra instructions: I can include a full diff of the assembly if you'd like, but it's a bit noisy because registers got renamed. I don't have my macOS machine handy at the moment (where I originally benchmarked this) but given the generated assembly is more complex, I expect directionally similar results. (For reference, #158866 was a ~2x win on macOS but a 4-5.8x win on this x86-64 machine, largely attributable to the macOS arm cores having more effective ILP in scalar mode than my x86-64 CPU). I'm not a reviewer or decision-maker on this PR. But personally, I don't really find the new code any easier to read than the prior code. I think the extra tests are great though! |
|
Given @obi1kenobi's analysis, I think we should keep the existing code. But I'd be happy to approve adding the tests. |
|
Also, did you even change the code since this comment? #159389 (comment) |
View all comments
Cleanup
chunk_bycount method (introduced in #158866) to usearray_windowsfor improved readability.EDIT: also added tests for
chunk_by.