Skip to content

Fix external memory race condition. - #4980

Merged
trivialfis merged 9 commits into
dmlc:masterfrom
trivialfis:file-lock
Oct 25, 2019
Merged

trivialfis merged 9 commits into
dmlc:masterfrom
trivialfis:file-lock

Conversation

@trivialfis

@trivialfis trivialfis commented Oct 24, 2019 •

Copy link
Copy Markdown
Member

Closes #4619 , unblocks #4975 .

The file lock is not necessary for colmaker, only added to be safe. Removed, it causes dead lock on Windows.
Root cause for the fixed issue is, despite its name, threadedIter is not thread safe.

@trivialfis

Copy link
Copy Markdown
Member Author

Em... Seems dead lock on Windows.

@chyunsu3

Copy link
Copy Markdown
Collaborator

@trivialfis Is there a good way to make threadedIter actually thread-safe? I thought you and I did some work on it before?

@trivialfis

trivialfis commented Oct 24, 2019 •

Copy link
Copy Markdown
Member Author

@hcho3 Probably. But after many attempts, I have only come to "having a vague intuition about what it's and general flow". For exactly how it works I have no idea. There might be an easier way to do parallel programming. But if you understand the implementation in dmlc core well please share some insight. I will try to make it more robust once I can catch up.

@trivialfis

Copy link
Copy Markdown
Member Author

@hcho3 Do we want to merge this one for now? You have more experience with dmlc-core I will let you decide. ;-)

@chyunsu3

Copy link
Copy Markdown
Collaborator

@trivialfis Let's merge this for now. I'd like to take another look at ThreadedIter this weekend.

@trivialfis

Copy link
Copy Markdown
Member Author

@hcho3 I will merge this one later unless you think otherwise. From the look of it, thread iter is not designed to be thread safe. For a good implementation of thread primitives, I recommend the tbb library, it has many programming patterns that makes parallel programming robust.

@trivialfis

Copy link
Copy Markdown
Member Author

Wait. Somehow it's failing on the threading PR on Windows..

@chyunsu3

chyunsu3 commented Oct 25, 2019 •

Copy link
Copy Markdown
Collaborator

@trivialfis I see that you removed file locking from this PR. Now this PR only contains a change about GetColDensity(). Does this PR still "fix external memory race condition," as the name of the PR suggests? Otherwise, we should rename this PR.

@chyunsu3

Copy link
Copy Markdown
Collaborator

Somehow it's failing on the threading PR on Windows..

where is the failure?

@trivialfis

Copy link
Copy Markdown
Member Author

@chyunsu3

chyunsu3 commented Oct 25, 2019 •

Copy link
Copy Markdown
Collaborator

From the look of it, thread iter is not designed to be thread safe

@trivialfis Can you elaborate a little bit more? I can use your insight here.

I do share your sentiment here; for me it was unsafe concurrent accesses to raw pointers that got me worried the most.

In the end, we may be better off re-writing ThreadedIter entirely.

@trivialfis

Copy link
Copy Markdown
Member Author

Yes. It fixed the race condition on colmaker.

@chyunsu3 chyunsu3 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for your clarification.

@trivialfis

Copy link
Copy Markdown
Member Author

@hcho3

Can you elaborate a little bit more

See the third error message posted on: #4619 it explicitly asked me not to do something concurrently.

In the end, we may be better off re-writing ThreadedIter entirely.

Agreed. But that might be as huge as the JSON PR. So we need some plans and preferably we can share some ideas/algorithms/design patters on how to do it, otherwise we might build another pile of bugs.

@chyunsu3

chyunsu3 commented Oct 25, 2019 •

Copy link
Copy Markdown
Collaborator

@trivialfis Thanks for the pointer. I agree about the need for planning. My experience is that writing thread-safe code takes lots of care (*). Let me first consider TBB, and ask whether an in-house implementation of ThreadedIter is called for. I will start a RFC for this.

(*) https://www.manning.com/books/c-plus-plus-concurrency-in-action points out many common pitfalls in multi-threaded C++ programming.

@trivialfis
trivialfis merged commit 6ec7e30 into dmlc:master Oct 25, 2019
@trivialfis
trivialfis deleted the file-lock branch October 25, 2019 08:11
@lock lock Bot locked as resolved and limited conversation to collaborators Jan 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

External memory race condition.

3 participants