Support chained attributes in thread unsafe detection#79
Conversation
- Correctly detect calls to thread-unsafe functions when the function call comes from a chained attribute with length three or more. - Do the same for walking down functions in search for assignments to `__thread_unsafe__`. - Do a minor refactor to make code easier to reason about.
|
Good catch! Did you check whether this impacts the time to collect tests in scipy or scikit-learn? Just to double-check that we don't repeat the slowdown we caused in the 0.4 release. I think this is still using the memoization I added to fix that issue so I'd be surprised if the performance impact is significant. It may also be worth doing a before/after on both scipy and scikit-learn to see if this is marking any tests as thread-unsafe that were not marked before. |
Limiting it to length <=2 was definitely on purpose, because arbitrary depth ast walking is prohibitively expensive. |
I thought that was about the number of functions we analyze when searching for This is about things like |
Ah okay, thanks for the explanation. If you can treat this separately and it doesn't impact collection time, then that sounds good. |
|
So here's the results of testing this on SciPy:
scikit-learn:
My feeling is this is an okay trade-off. It also makes sense that no new tests were marked as thread-unsafe, because:
|
|
Sorry for the pause here. Given Ralf indicated the changes are OK for SciPy, let's pull this in. |
__thread_unsafe__.This is the first of a series of PRs aiming to make thread-unsafe detection a bit more stable. The final purpose is to be able to support #73 (disallow stuff at the module level), but going over a few improvements/fixes first, so that that becomes easier to implement.