-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
[jvm-packages] Removing synchronized predict #6021
Conversation
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.
this LGTM
@trivialfis do we still have to be locked in c++ layer when doing prediction? and is the fix for the problem mentioned in #5272 also applying to the normal prediction method (or we have to use in_place_pred? )
Inplace prediction is not used during training. For training it's always predicting on DMatrix.
Yes. Only inplace prediction is lock free at the moment. Normal prediction can be made to lock free, but it might create some overhead during training as there's a work space for prediction (should be minor). From my perspective, for low latency/low memory usage prediction inplace predict is a better choice, so I didn't try to clear the lock for normal predict.
The fix was for normal prediction, as there's no cache for inplace predict right now. I restructured the cache implementation. So training from checkpoint should not have any issue. |
Could you please rebase the branch to master? |
for xgb-spark, we are calling normal prediction, so it is eventually locked? not sure if removing synchronize can bring much improvements
IIUC, so now the normal prediction will not go over all trees even without a prediction cache? |
Yes.
Removing a lock in language binding is still an improvement as it's a duplicated lock.
It will rebuild the cache on first iteration, then works as usual. |
e276339
to
36d0dd7
Compare
Yeah. I did not know there's a lock internally for predict, so this won't give as much performance boost. Removing it still makes sense though, in case there's a future expensive op before the lock, Java client will benefit from it. @trivialfis Rebased. |
Thanks, best scenario would be having inplace predict implemented for java. Just that I'm not familiar with the language's ecosystem so not sure what data to support. |
Okay, the prediction contribution is not thread safe ... |
I will make that function thread safe later. |
predict
method is now thread safe, so the predict method need not be synchronized. There's nothing else that maintains state in the Java world.cc: @CodingCat