[PATCH] D102633: [clang-scan-deps] Improvements to thread usage

Sylvain Audi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 17 08:27:29 PDT 2021


saudi created this revision.
saudi added reviewers: arphaman, dexonsmith, Bigcheese.
saudi added projects: clang, LLVM.
saudi requested review of this revision.
Herald added a subscriber: cfe-commits.

Switching back to `std::thread` to simplify the logic, as `ThreadPool` adds a layer of task management. However, keeping the `ThreadPoolStrategy` use, to benefit the `ThreadPool` improvements from https://reviews.llvm.org/D71775

This patch partly reverts https://reviews.llvm.org/D74569

Added a few optimizations:

  - Prevent from spawning more threads than there are files to process;
  - Perform computations on the main thread too, to save one thread spawn. This way, `clang-scan-deps -j1` will be really single-threaded, and the code path is the same as when LLVM threads are disabled.
- Call `reserve()` to `std::vector`s which size is known when initializing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102633

Files:
  clang/test/ClangScanDeps/Inputs/num-workers-1cmd.json
  clang/test/ClangScanDeps/Inputs/num-workers-2cmds.json
  clang/test/ClangScanDeps/num-workers.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102633.345890.patch
Type: text/x-patch
Size: 5222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210517/82de7462/attachment.bin>


More information about the cfe-commits mailing list