Skip to content
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

fix: Possible multithreading issue when two scores may come in parallel they may not safely fill pointer values #799

Merged
merged 10 commits into from Feb 10, 2020

Conversation

JoanFM
Copy link
Contributor

@JoanFM JoanFM commented Feb 10, 2020

fix: Possible multithreading issue when two scores may come in parallel they may not safely fill pointer values

Two threads can fill up scoredDataOutPtr in parallel and mix up their values

@imatiach-msft
Copy link
Contributor

@JoanFM it looks like this needs to be merged with latest? I think I also see some code that has been merged already in the other PR.

@JoanFM
Copy link
Contributor Author

JoanFM commented Feb 10, 2020

@JoanFM it looks like this needs to be merged with latest? I think I also see some code that has been merged already in the other PR.

Yes, I am merging it


private def getNumClasses: Int = {
val numClassesOut = lightgbmlib.new_intp()
LightGBMUtils.validate(
lightgbmlib.LGBM_BoosterGetNumClasses(boosterPtr, numClassesOut),
"Booster NumClasses")
lightgbmlib.intp_value(numClassesOut)
val out = lightgbmlib.intp_value(numClassesOut)
lightgbmlib.delete_intp(numClassesOut)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch to delete the pointer here!

@imatiach-msft
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@codecov
Copy link

codecov bot commented Feb 10, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@5626a2a). Click here to learn what that means.
The diff coverage is 14.28%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #799   +/-   ##
=========================================
  Coverage          ?   43.83%           
=========================================
  Files             ?      241           
  Lines             ?     9704           
  Branches          ?      529           
=========================================
  Hits              ?     4254           
  Misses            ?     5450           
  Partials          ?        0
Impacted Files Coverage Δ
...rosoft/ml/spark/train/ComputeModelStatistics.scala 0.97% <0%> (ø)
...oft/ml/spark/isolationforest/IsolationForest.scala 16.66% <16.66%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5626a2a...f0cbff5. Read the comment docs.

@imatiach-msft imatiach-msft merged commit 290f5cf into microsoft:master Feb 10, 2020
@JoanFM JoanFM deleted the sync branch February 11, 2020 18:20
ocworld pushed a commit to AhnLab-OSS/mmlspark that referenced this pull request Mar 24, 2020
…el they may not safely fill pointer values (microsoft#799)

* Move transient var to transient lazy val

* Try guaranteeing NativeLibrary is loaded everytime it is needed but only loaded once

* Forgot some lightGBMlibConstants

* Add freeing of resources, handle all memory in BoosterHandler

* Remove serialization from BoosterHandler, some documentation and minor changes. By boosterHandler not being serializable, it forces Serializable objects to declare it as transient

* Style forbigs implementing finalize method, Java does not guarantee order of finalization so it is dangerous. I wonder how is it guaranteed that the memory will be cleared though

* Add finalize method to call free for Native C++ allocated memory

* predict normal correct constant

* Change implementation to a ThreadLocal based synchronization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants