-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[clang-scan-deps] Move command-line generation out of critical section #158187
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
Conversation
The first call to getBuildArguments() can be costly. Although the original author’s comment states that it should be called outside the critical section, it is currently invoked within the locked region. (Original comment introduced in commit 3b1a686.) This change moves it outside the critical section to match the original intent and reduce lock contention.
|
@llvm/pr-subscribers-clang Author: Naveen Seth Hanig (naveen-seth) ChangesThe first call to This change moves it outside the critical section to match the original intent and reduce lock contention. Full diff: https://github.com/llvm/llvm-project/pull/158187.diff 1 Files Affected:
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index f10b73278381b..0e2758d123edc 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -429,12 +429,12 @@ class FullDeps {
auto Res = Modules.insert(I, {{MD.ID, InputIndex}, std::move(MD)});
NewMDs.push_back(&Res->second);
}
- // First call to \c getBuildArguments is somewhat expensive. Let's call it
- // on the current thread (instead of the main one), and outside the
- // critical section.
- for (ModuleDeps *MD : NewMDs)
- (void)MD->getBuildArguments();
}
+ // First call to \c getBuildArguments is somewhat expensive. Let's call it
+ // on the current thread (instead of the main one), and outside the
+ // critical section.
+ for (ModuleDeps *MD : NewMDs)
+ (void)MD->getBuildArguments();
}
bool roundTripCommand(ArrayRef<std::string> ArgStrs,
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, good catch! The pointers in NewMDs should be stable, since they're stored in std::unordered_map, so doing this outside of the critical section should be fine, I think.
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/19218 Here is the relevant piece of the build log for the reference |
The first call to
getBuildArguments()can be costly. Although the original author’s comment (from commit 3b1a686) states that it should be called outside the critical section, it is currently invoked from within the locked region.This change moves it outside the critical section to match the original
intent and reduce lock contention.