[all-commits] [llvm/llvm-project] 64b453: tsan: speed up pthread_setname_np

Dmitry Vyukov via All-commits all-commits at lists.llvm.org
Mon Nov 15 22:51:20 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 64b45399e5c547dc59ea3c72891fccdda7284eaa
      https://github.com/llvm/llvm-project/commit/64b45399e5c547dc59ea3c72891fccdda7284eaa
  Author: Dmitry Vyukov <dvyukov at google.com>
  Date:   2021-11-16 (Tue, 16 Nov 2021)

  Changed paths:
    M compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
    A compiler-rt/test/tsan/bench_threads.cpp

  Log Message:
  -----------
  tsan: speed up pthread_setname_np

pthread_setname_np does linear search over all thread descriptors
to map pthread_t to the thread descriptor. This has O(N^2) complexity
and becomes much worse in the new tsan runtime that keeps all ever
existed threads in the thread registry.
Replace linear search with direct access if pthread_setname_np
is called for the current thread (a very common case).

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D113916




More information about the All-commits mailing list