Repository navigation
Resolves Issue 4810, cumSum and cumProd performance - #4819
Conversation
dcd1f26 to
e8c0146
Compare
e-kayrakli
left a comment
There was a problem hiding this comment.
Thanks, Andy! And I apologize for the delay. Looking at the diff, it is a good bet that this will improve performance. The parts that you are replacing has two potential performance issues:
- You create
csand return it after some edits. This will make compiler's job difficult removing an array out of the operation. Whereas just+ scan xcan have better chance at the compiler avoiding a redundant array copy. - Even with
includeInitial==falsewhich is the faster option no matter what,cs[0..] = (+ scan x):t;is an assignment into an array slice rather than an array (regardless of the slice being the full array, practically speaking). That will take a different codepath in the modules that can handle more complicated scenarios that slice assignment may bring. Imaginably, that will cost some time. Moreover, that line also has a cast, which should be unnecessary, I think.
In any case chapel-lang/chapel#27828 will put this branch in the performance playground allowing us to collect some data. You can finalize the PR after we know for sure that this will recover performance.
|
As for the performance experiments:
This is very tiny to be able to make a judgement on the performance. Your data is 16KB. For example, that's 1/8th of an Apple M1's L1 cache. Even though some of your runs do not go through the Arkouda interface, you are still running a Python interpreter, whose data might be larger than that amount meaning that the performance you'll get will depend entirely on what's in the cache. Another challenge with working with data that can fit in (especially L1 cache) is if you are using your personal machine, OS will do a lot of time-sharing between processes which will share L1. So, your performance stability will be at the mercy of the OS. I still think there's a good chance your script can detect the difference. Two things to make sure that you can do that:
In any case, though, I don't think you have to do any of that. Hopefully, starting tomorrow, we'll get good results on the playground and you can just work with that. |
This PR puts Bears-R-Us/arkouda#4819 in the Arkouda perf playground. We expect [Scan regressions](Bears-R-Us/arkouda#4810) to recover. [Trivial, not reviewed]
e91a6cc to
f6a7bc5
Compare
f6a7bc5 to
95b70c6
Compare
Closes #4810
Update to update:
Based on Engin's recent feedback, this should now be ready for review. The final changes are very simple. In the 1D case, it reverts to the original code. The rest of the comments below are now out of date.
Update: I added plotting to the performance tool. Enter any value as a 3rd argument and it will plot the measured time for all of the trials. Still not sure this is helpful.
I commented out the console logging because that has more affect on runtime than the calculations do.
Bottom Line Up Front: I'm trying to nail down the performance problem noted in Issue 4810. So far I'm not succeeding. This PR has both old and new versions, and some performance measuring code. (The benchmark doesn't run the old ones, because there are no corresponding numpy names for them.)
The old versions are: ak.oldcumsum and ak.oldcumprod. The new ones are: ak.cumsum and ak.cumprod.
I've attached a python program, pperformance.py, meant to time the old vs. new.
What do I test? I test all four functions via their python interfaces (ak.oldcumsum, ak.oldcumprod, ak.cumsum, ak.cumprod) and I also do tests that directly invoke the four chapel procs via generic_msg (these runs ignore the output). This meant to reduce the effect of the python interpreter on the timing.
The input data is not random. It's ak.arange(size) + 1. Since it's always the same, the test results should be consistent. They're not. Run it and see. According to this performance tool, the new versions are almost always worse than the old ones, even though the code is virtually identical.
Here's the test program:
pperformance.py
Some background: when I wrote PR 4755, I updated the chapel proc cumSum and cumProd to implement the more complicated functions cumulative_sum and cumulative_prod. These allow multi-dim, axis slicing, and the boolean includeInitial. When the input rank is 1 and the flag is False, cumulative_sum should give the same results as cumsum. Similarly for cumulative_prod and cumprod.