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

Fixes #629 - python GetSubstructureMatch thread safety #637

Merged

Conversation

bp-kelley
Copy link
Contributor

Never/ever call the Python API when the GIL is released.

Also releases the GIL during GetSubstructMatches.

Any ideas how to add a test case for this? Do we know when to test threading?

@bp-kelley
Copy link
Contributor Author

If RDK_THREADSAFE_SSS is not set, should we release the GIL at all? The default is to always release the GIL which seems... optimistic.

@bp-kelley
Copy link
Contributor Author

I checked the rest of the GIL releases, it appears this one was the only borked one, I'll write some MT tests over the next few days.

@greglandrum
Copy link
Member

I've never done enough multi-threading in python to really have much of a grasp of this stuff. When I've wanted to do parallel work, I've tended to use things like multiprocessing.

I believe it only makes sense to release the GIL around substructure matching if RDK_THREADSAFE_SSS is set. If that flag is not set and there is a recursive SMARTS component of the query, it will generate incorrect results if that query is being applied to multiple molecules at the same time.

@greglandrum
Copy link
Member

Re: testing
I was not able to come up with a reliable testing scenario that exposed the bug across platforms. We could fix the GIL code, try putting in something basic in terms of testing, and hope for the best?

MatchVectType matches;
SubstructMatch(mol,query,matches,true,useChirality,useQueryQueryMatches);
{
NOGIL gil;
Copy link
Member

Choose a reason for hiding this comment

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

How about modifying the NOGIL definition so that it only does anything if the thread safety flag (RDK_BUILD_THREADSAFE_SSS) is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's my plan.


Brian Kelley

On Oct 14, 2015, at 12:25 AM, Greg Landrum notifications@github.com wrote:

In Code/GraphMol/Wrap/Mol.cpp:

 MatchVectType matches;
  • SubstructMatch(mol,query,matches,true,useChirality,useQueryQueryMatches);
  • {
  •  NOGIL gil;
    
    How about modifying the NOGIL definition so that it only does anything if the thread safety flag (RDK_BUILD_THREADSAFE_SSS) is set?


Reply to this email directly or view it on GitHub.

@greglandrum greglandrum merged commit 52732df into rdkit:master Oct 15, 2015
@bp-kelley bp-kelley deleted the fix/python-getsubstructmatch-threadsafety branch October 15, 2015 18:25
@greglandrum greglandrum modified the milestone: 2015_09_1 Oct 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants