-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improve performance of flatten in DenseMatrix #3400
base: develop
Are you sure you want to change the base?
Conversation
Thanks David. I've run the benchmark comparing
|
Thanks for reviewing this Jos, let me check what happened and report back. |
Hi, I was missing a parenthesis. Was using
Faster by 25% on my end, could you please validate? I think the initial improvement I was showing was comparing to develop before #3354 |
Thanks David, I get the same results as you when running the benchmark. I have a couple of thoughts:
|
Hi Jos! Thank you for reviewing this!
I will make a new benchmark between arrays including your example, compare using I completely understand if in the end the added complexity of a second algorithm isn't worth it. I expect something positive from comparing apples to apples on the following days. |
Hi Jos, I included a new commit, with your code proposal for regular arrays and modified the code for rectangular arrays to take a boolean as an argument instead of the maximum depth.
As a summary your code proposal is 36% faster than dev for arrays in general, for rectangular arrays the specialized algorithm shows 52% improvement. As you mentioned the improvement is lost in the creation of a Matrix, in the end it improves 18%. I tested your proposed algorithm for arrays in general using it also for matrices and the improvement is 14% (instead of 18%). Compared to the previous commit, with changes only in the algorithm for rectangular arrays but using
It had the same 52% improvement, I think just by luck it shows 21% improvement for Matrices (vs 18% of the new commit) A nice improvement of using a boolean indicating if it's rectangular, is that you don't need to know the size of the array, just that it is rectangular, as it's the case for the function My conclusions:
|
Hi, this improves the performance of flattening matrices by 60%.