-
-
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
Increase performance of collection
deepMap and deepForEach with DenseMatrices
#3409
base: develop
Are you sure you want to change the base?
Conversation
I also would like to mention that currently the function That's why it is an argument here, but no implementation is made. The next step of addressing #3262 is for |
In this latest commit, the non indexed version of the iteration functions is implemented when possible, with these benefits (about 25% faster as a maximum) This includes an arity check for regular functions as stated at #3262 which I think was accurate and concerned about the big gap between I think this PR could open a discussion about a state of diminishing returns due to the indexed methods being previously optimized by various PR, if we compared with V13.1.1 before all the PR improving the indexed algorithms the benefits are huge. I'm open to any discussions this data might arise as I found #3262 intriguing, otherwise I think this PR could be implemented as such. |
Also I would like to know if it's better to pass an options object to skipIndex and skipZeroes and include that in the documentation for DenseMatrix methods or if it's better like individual boolean parameters. |
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.
We've made huge improvements since v13.1.1! I guess we've addressed all the low hanging fruit now, so maybe time to stop 😜. The 25% improvment in this PR is worth it I think, since map
and forEach
are used a lot.
I made a couple of inline comments, can you have a look at those?
Thanks, I looked into your comments and I will address them individually, in my notes I recall another bottleneck and that's it. The bottleneck occurs when the callback optimization is run twice and sometimes is not run. I'm considering adding attributes to callbacks and arrays, the eliminate the need to pass extra arguments in some functions. I will review this and maybe next week have a response. |
Would be good to have a look at that, but please do a quick check first to see if the callback optimization is indeed a bottleneck, I would expect the callback optimization to take a fraction of the time compared to running the callback for every element on a (large) matrix, so maybe there is not much to gain there. |
Thank's, my intuition was that maybe if it does a double In the latest commit most comments are addressed and these are the benchmarks. Just a few comments:
|
As a separate topic, at some point I would like to address the duplicate logic as suggested at #3266
I'm thinking of including that after this PR without affecting performance significantly. |
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.
I see bigger performance improvements than in your last chart, that is a good thing :)
Merging the PR now.
Hi, I think this is ready to merge. |
Hi, this PR increases performance of
deepMap
anddeepForEach
when iterating over a DenseMatrix in collections by using a non indexed version of._forEach
and also forcing the optimizeCallback function to return a function with one argument.