[PATCH] D38481: Use sched_getaffinity instead of std::thread::hardware_concurrency when available

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 16:11:04 PDT 2017


ruiu added a comment.

Thank you for doing this.

Off-topic: there seems to be many things we can do utilize multiple cores more efficiently. One thing I want to fix is the large variance of lld's execution time. Currently, lld sometimes takes unreasonably long time to finish even though that rarely happens. I'd guess the kernel does a bad job at scheduling threads. I wonder if we could do something -- e.g. pinning each thread to an available core.



================
Comment at: include/llvm/Support/Threading.h:140
+  /// not available.
+  unsigned get_available_threads();
+
----------------
It sounds like it returns a list of std::thread objects or something. How about `hardware_concurrency`? We have `heavyweight_hardware_concurrency` function just above this declaration, and compared to that name, I don't think that's a bad name.


https://reviews.llvm.org/D38481





More information about the llvm-commits mailing list