Fix thread-safety in C API's PredictSingleRow #3771
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The single row predictor methods in the C APi are not thread safe as reported in #3751 and #3675. This fixes both reports. Thank you https://github.com/tarunreddy1018 for the detailed reports!
By using a unique lock instead of the shared lock the timings are very similar, but predictions are correct.
Remarks for future work:
threading on these calls is worth it in performance gains.
See #3751 for timings of the small benchmark and the benchmark gist https://gist.github.com/AlbertoEAF/5972db15a27c294bab65b97e1bc4c315