mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-22 09:13:06 +00:00
f4af9b5b1d
In commitc4a122ead6
("libdrgn: dwarf_info: scalably index all DIEs per name"), I noted that indexing the Linux kernel was slower with 80 threads than with 8. After experimenting on multiple systems, I determined that the slowdown was because of hyperthreading; limiting the number of threads to the number of cores (not hyperthreads) was usually faster, and never slower. Unfortunately, OpenMP doesn't have a convenient way to express this, so we have to parse sysfs and explicitly specify the number of threads ourselves. Compared to commitc4a122ead6
("libdrgn: dwarf_info: scalably index all DIEs per name"), this makes indexing the large C++ application half a second faster, and the Linux kernel 70 ms faster, all while using less resources. Signed-off-by: Omar Sandoval <osandov@osandov.com>
21 lines
358 B
C
21 lines
358 B
C
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
#ifndef DRGN_OPENMP_H
|
|
#define DRGN_OPENMP_H
|
|
|
|
#ifdef _OPENMP
|
|
#include <omp.h> // IWYU pragma: export
|
|
|
|
extern int drgn_num_threads;
|
|
#else
|
|
static inline int omp_get_thread_num(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
#define drgn_num_threads 1
|
|
#endif
|
|
|
|
#endif /* DRGN_OPENMP_H */
|