fix race condition for test MulticlassTreeFeaturizedLRTest#4950
Conversation
| mapper = | ||
| (in TInput src, ref Single dst) => | ||
| { | ||
| ulong temp = 0; |
There was a problem hiding this comment.
Very nice find! :-) Can you please add some comments about this change? Otherwise some future developer might want to "optimize" this and move it back.
Also, this pattern deserves more investigation. Do we have other mappers that are using variables set outside the mapper function definition? #Resolved
There was a problem hiding this comment.
There was a problem hiding this comment.
No similar issue found from other mappers but mapper are not only function used in multi-threading condition and it is impossible to view for all similar issue.
In reply to: 394130751 [](ancestors = 394130751)
There was a problem hiding this comment.
I'm not aware of such a tool. It would be easier to write a more targeted tool that identified variables captured by a lambda so they could be reviewed for cases like this. #Resolved
There was a problem hiding this comment.
| (in TInput src, ref Single dst) => | ||
| { | ||
| // Attention: this method will be used in multipe threading, | ||
| // don't put temp variable outside of this method to avoid race condition |
There was a problem hiding this comment.
Nitpick: The comment is slightly confusing. Can you please rephrase it? Say, something like:
This method is called from multiple threads. Do not move the temp variable outside this method. If you do, the variable is shared between the threads and results in a race condition. #Resolved
There was a problem hiding this comment.
Isnt there a test that can be enabled back because of this fix? #Resolved
There was a problem hiding this comment.
No, the test (MulticlassTreeFeaturizedLRTest) is not disabled but I see several fail on machine learning full test set.
As test machine only has 2 cores so the failure rate is not that high but if we run the test locally the failure rate is more than 10 percent.
In reply to: 394607002 [](ancestors = 394607002)
There was a problem hiding this comment.
method in TreeEnsembleFeaturizerTransform will be called from multi-threading, make variable "temp" as local variable to avoid race condition.