This avoid O(N) in __lsan_unregister_root_region.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This avoid O(N^2) in __lsan_unregister_root_region.
O(N) ?
Is there a pessimistic case where size(root_regions) is in the scale of 1000+ ?
Yes. N^2 is for entire app
Is there a pessimistic case where size(root_regions) is in the scale of 1000+ ?
Yes, it should make a difference of 1000+ but I don't know such examples. But it should be possible.
I was debugging perf regression and suspected this place.
But the real reason was request calls MemoryMappingLayout which is already fixed.
Thanks!
compiler-rt/lib/lsan/lsan_common.cpp | ||
---|---|---|
524–536 | Add a space after using RootRegions. Add a comment like // A map that contains (region, count) pairs. Regions are non-overlapping. | |
528 | We can just use alignas instead of ALIGNED. Actually, static RootRegions *regions = new RootRegions();. The function-local static variable is constructed when executed for the first time. #include <assert.h> #include <stdio.h> struct A { A() { puts("a"); } ~A() { assert(0); } }; static A& foo() { puts("foo"); static A *a = new A; return *a; } int main() { puts("main"); foo(); foo(); } |
compiler-rt/lib/lsan/lsan_common.cpp | ||
---|---|---|
524–536 | Sorry, I mean add a blank line after using RootRegions |
compiler-rt/lib/lsan/lsan_common.cpp | ||
---|---|---|
524–536 |
when in practice they should not be overlapping, we didn't enforce that before, I don't see good reason to enforce now. | |
528 | we don't have cxa_guard for static |
We can just use alignas instead of ALIGNED.
Actually, static RootRegions *regions = new RootRegions();. The function-local static variable is constructed when executed for the first time.