-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
feat: Change locking strategy of Booster, allow for share and unique locks #2760
Conversation
… to upper and lower bound, move implementation to gdbt.cpp
Co-Authored-By: Nikita Titov <[email protected]>
…ython and a basic test
…to max_min_leafs
…ck to test with hardcoded value
…to max_min_leafs
…into read_write_locks
…to read_write_locks
@JoanFM agreed, I think it's ok to not use git submodules for now, especially if they are not updating their code frequently. However, long term I always try to reduce code duplication/forking since it increases maintenance costs. However, it sounds like this is not something we want to do right now. |
Hello @StrikerRUS @guolinke, after solving a couple of conflicts I have issues again with the r-package. |
ping @jameslamb for R's CI. |
Actually, all tests are failing, not just R ones. I believe the problem is in conflicts after #2992 was merged. For example, see compilation errors:
|
Thanks @StrikerRUS , Sorry, my bad, I did the conflict resolution on the browser and did not double check. I solved the issues now, but now there are some unused parameters, but I guess removing them would break a lot of the interfaces. |
Hi @StrikerRUS @guolinke @imatiach-msft, is there any issue blocking the merge of this PR? Thanks |
Thanks @JoanFM so much, looks good to me. ping @StrikerRUS for the final review. |
Everything looks good to me either! Actually, I gave my approval a few days ago: #2760 (review). Sorry for the confusion! I just wonder, should new functions in C API from the recently merged #2992 be enhanced with new locks? |
Hey @StrikerRUS, I think he did not add any new method inside the Booster object, am I right? If it is so, that PR should directly benefit from the new locking strategy. Buy yes it is important to keep up with these locks when new methods arise, and if possible ensure const-correctness for new methods. |
@JoanFM Yeah, seems you are right! Thanks a lot for your contribution and a great patience! |
For reference: yamc seems to be a pretty bad implementation with regards to the way it manages shared locks: it relies on an exclusive mutex on a state variable to implement the shared locking. |
@Ten0 are you interested in submitting a pull request changing the behavior you're talking about? Or writing up in more detail a proposal for some change that someone else could implement? We'd welcome your help in improving LightGBM if you see some opportunity for improvement. |
Hello! Thank you for your interest! |
I've finished the benchmarks and as it turns out, running our decision tree is expensive enough that the sub-optimal locking becomes negligible and allowing parallelism from #6024 is totally enough for us ATM, so I won't dedicate time to this. |
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
Changes introduced
I propose to have a different locking strategy that would allow to do singlePredictions in a parallel way.
I propose having shared lock for const methods and unique locks for non const that are potentially writing values.
I added const to the methods that do Prediction since they should not alter the Booster and should be able to access the mutex in shared mode.
I hope this can help.