Skip to content

Commit f2d9576

Browse files
digantdesaipytorchmergebot
authored andcommitted
[pthreadpool] Set max threadlimit to tsan limit (pytorch#89453)
Summary: This will make sure we don't run into an internal assert for clang tsan which has a cap of 63 on concurrently held lock count. Seems like it is failing with 64 since the comparison is `<`, so setting it to 63 here. ``` llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector.h:67 "((n_all_locks_)) < (((sizeof(all_locks_with_contexts_)/sizeof((all_locks_with_contexts_)[0]))))" ``` Created from CodeHub with https://fburl.com/edit-in-codehub Test Plan: CI Sandcastle run Reviewed By: kimishpatel, salilsdesai Differential Revision: D41444710 Pull Request resolved: pytorch#89453 Approved by: https://github.com/mcr229
1 parent 772b726 commit f2d9576

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

caffe2/utils/threadpool/ThreadPool.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,13 @@ size_t getDefaultNumThreads() {
103103

104104
/*
105105
* For llvm-tsan, holding limit for the number of locks for a single thread
106-
* is 64. pthreadpool's worst case is the number of threads in a pool. So we
107-
* want to limit the threadpool size to 64 when running with tsan. However,
108-
* sometimes it is tricky to detect if we are running under tsan, for now
109-
* capping the default threadcount to the tsan limit unconditionally.
106+
* is 63 (because of comparison < 64 instead of <=). pthreadpool's worst
107+
* case is the number of threads in a pool. So we want to limit the threadpool
108+
* size to 64 when running with tsan. However, sometimes it is tricky to
109+
* detect if we are running under tsan, for now capping the default
110+
* threadcount to the tsan limit unconditionally.
110111
*/
111-
int tsanThreadLimit = 64;
112+
int tsanThreadLimit = 63;
112113
numThreads = std::min(numThreads, tsanThreadLimit);
113114

114115
return numThreads;

0 commit comments

Comments
 (0)