[libcxx-commits] [libcxx] [ASan][libc++] Optimize `__annotate_delete` for the default allocator (PR #76176)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 9 16:38:38 PST 2024
AdvenamTacet wrote:
I just ran a small benchmark with flags `-stdlib=libc++ -fsanitize=address -O3`.
```cpp
#ifdef VECTOR_FAST
#include "vector-optimized.hpp"
#endif
#ifdef VECTOR_MAIN
#include "vector-main.hpp"
#endif
int main() {
uint32_t sum = 0;
for(uint32_t i = 2; i < 100'000; ++i) {
std::vector<uint64_t> v(1'000'000, i);
sum += v[i/2];
v.clear();
}
return sum != 0 ? 0 : -1;
}
```
Example results (quite representative):
```bash
# Optimized times:
real 3m6.008s
user 0m25.815s
sys 2m39.491s
# Times from upstream mian:
real 3m32.434s
user 0m27.063s
sys 3m4.495s
```
It gives around 13% of speedup on that benchmark.
```python
In [1]: 1 - (3*60+3.008) / (3*60+32.434)
Out[1]: 0.13851831627705535
```
I don't see many potential issues, maybe problems after replacing default allocator with some problematic allocator?
It only affects strictly ASan related functions, so readability is arguably untouched.
Performance is consistently better.
What do you think?
https://github.com/llvm/llvm-project/pull/76176
More information about the libcxx-commits
mailing list