Remove an expensive lock from Timer

The Timer destructor would grab a global mutex in order to update
execution time. Add a class to define a category once, statically; the
class adds itself to an atomic singly linked list, and thus subsequent
updates only need to use an atomic rather than grab a lock and perform a
hashtable lookup.

Differential Revision: https://reviews.llvm.org/D32823
Patch by Scott Smith <scott.smith@purestorage.com>.

llvm-svn: 303058
This commit is contained in:
Pavel Labath
2017-05-15 13:02:37 +00:00
parent 3030bf0c81
commit f9d1647657
28 changed files with 183 additions and 127 deletions

View File

@@ -727,8 +727,9 @@ size_t ObjectFileELF::GetModuleSpecifications(
uint32_t core_notes_crc = 0;
if (!gnu_debuglink_crc) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
lldb_private::Timer scoped_timer(
LLVM_PRETTY_FUNCTION,
func_cat,
"Calculating module crc32 %s with size %" PRIu64 " KiB",
file.GetLastPathComponent().AsCString(),
(file.GetByteSize() - file_offset) / 1024);