[PATCH] D14537: sanitizer: speedup coverage by 33%
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 10 04:25:09 PST 2015
dvyukov created this revision.
dvyukov added a reviewer: kcc.
dvyukov added a subscriber: llvm-commits.
Atomic RMW is not necessary in InitializeGuardArray. It is supposed to run when no user code runs. And if user code runs concurrently, then the atomic RMW won't help anyway. So replace it with non-atomic RMW.
InitializeGuardArray takes more than 50% of time during re2 fuzzing:
real 0m47.215s
51.56% a.out a.out [.] __sanitizer_reset_coverage
6.68% a.out a.out [.] __sanitizer_cov
3.41% a.out a.out [.] __sanitizer::internal_bzero_aligned16(void*, unsigned long)
1.79% a.out a.out [.] __asan::Allocator::Allocate(unsigned long, unsigned long,
With this change:
real 0m31.661s
26.21% a.out a.out [.] __sanitizer_reset_coverage
10.12% a.out a.out [.] __sanitizer_cov
5.38% a.out a.out [.] __sanitizer::internal_bzero_aligned16(void*, unsigned long)
2.53% a.out a.out [.] __asan::Allocator::Allocate(unsigned long, unsigned long,
That's 33% speedup.
http://reviews.llvm.org/D14537
Files:
lib/sanitizer_common/sanitizer_coverage_libcdep.cc
Index: lib/sanitizer_common/sanitizer_coverage_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_coverage_libcdep.cc
+++ lib/sanitizer_common/sanitizer_coverage_libcdep.cc
@@ -226,7 +226,8 @@
Enable(); // Make sure coverage is enabled at this point.
s32 n = guards[0];
for (s32 j = 1; j <= n; j++) {
- uptr idx = atomic_fetch_add(&pc_array_index, 1, memory_order_relaxed);
+ uptr idx = atomic_load_relaxed(&pc_array_index);
+ atomic_store_relaxed(&pc_array_index, idx + 1);
guards[j] = -static_cast<s32>(idx + 1);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14537.39803.patch
Type: text/x-patch
Size: 610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151110/2b22d5e5/attachment.bin>
More information about the llvm-commits
mailing list