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 cache with gc #8851

Merged
merged 18 commits into from
Feb 28, 2023
Merged

Fix cache with gc #8851

merged 18 commits into from
Feb 28, 2023

Conversation

trivialfis
Copy link
Member

@trivialfis trivialfis commented Feb 27, 2023

Close #8683 .

The previous cache uses static thread local memory implemented as part of the standard library. However, the Scala binding uses a different thread to call the dispose method, which calls into the booster destructor. As a result, the constructor and destructor are invoked by different threads, violating the cache cleanup process.

A short-lived lock is required for enabling thread safety with the new DMatrix cache.

  • Make DMatrixCache thread safe.
  • Remove the use of thread-local memory.

@@ -52,4 +54,63 @@ TEST(DMatrixCache, Basic) {
}
}
}

TEST(DMatrixCache, MultiThread) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I have run this test a few thousand times using the gtest_repeat, along with thread sanitizer.

@trivialfis trivialfis merged commit d54ef56 into dmlc:master Feb 28, 2023
@trivialfis trivialfis deleted the fix-cache-with-gc branch February 28, 2023 16:39
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.

[CI] Flaky JVM test.
2 participants