[compiler-rt] r276343 - [sanitizer] better allocator stats (with rss)
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 14:38:40 PDT 2016
Author: kcc
Date: Thu Jul 21 16:38:40 2016
New Revision: 276343
URL: http://llvm.org/viewvc/llvm-project?rev=276343&view=rev
Log:
[sanitizer] better allocator stats (with rss)
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h?rev=276343&r1=276342&r2=276343&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h Thu Jul 21 16:38:40 2016
@@ -20,6 +20,7 @@
#include "sanitizer_list.h"
#include "sanitizer_mutex.h"
#include "sanitizer_lfstack.h"
+#include "sanitizer_procmaps.h"
namespace __sanitizer {
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h?rev=276343&r1=276342&r2=276343&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h Thu Jul 21 16:38:40 2016
@@ -144,6 +144,13 @@ class SizeClassAllocator64 {
UnmapWithCallback(SpaceBeg(), kSpaceSize + AdditionalSize());
}
+ static void FillMemoryProfile(uptr start, uptr rss, bool file, uptr *stats,
+ uptr stats_size) {
+ for (uptr class_id = 0; class_id < stats_size; class_id++)
+ if (stats[class_id] == start)
+ stats[class_id] = rss;
+ }
+
void PrintStats() {
uptr total_mapped = 0;
uptr n_allocated = 0;
@@ -157,15 +164,24 @@ class SizeClassAllocator64 {
Printf("Stats: SizeClassAllocator64: %zdM mapped in %zd allocations; "
"remains %zd\n",
total_mapped >> 20, n_allocated, n_allocated - n_freed);
+ uptr rss_stats[kNumClasses];
+ for (uptr class_id = 0; class_id < kNumClasses; class_id++)
+ rss_stats[class_id] = SpaceBeg() + kRegionSize * class_id;
+ GetMemoryProfile(FillMemoryProfile, rss_stats, kNumClasses);
for (uptr class_id = 1; class_id < kNumClasses; class_id++) {
RegionInfo *region = GetRegionInfo(class_id);
if (region->mapped_user == 0) continue;
- Printf(" %02zd (%zd): total: %zd K allocs: %zd remains: %zd\n",
+ uptr in_use = region->n_allocated - region->n_freed;
+ uptr avail_chunks = region->allocated_user / SizeClassMap::Size(class_id);
+ Printf(" %02zd (%zd): mapped: %zdK allocs: %zd frees: %zd inuse: %zd"
+ " avail: %zd rss: %zdK\n",
class_id,
SizeClassMap::Size(class_id),
region->mapped_user >> 10,
region->n_allocated,
- region->n_allocated - region->n_freed);
+ region->n_freed,
+ in_use, avail_chunks,
+ rss_stats[class_id] >> 10);
}
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=276343&r1=276342&r2=276343&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Thu Jul 21 16:38:40 2016
@@ -27,6 +27,7 @@
#include "sanitizer_libc.h"
#include "sanitizer_mutex.h"
#include "sanitizer_placement_new.h"
+#include "sanitizer_procmaps.h"
#include "sanitizer_stacktrace.h"
#include "sanitizer_symbolizer.h"
@@ -884,6 +885,10 @@ bool IsProcessRunning(pid_t pid) {
int WaitForProcess(pid_t pid) { return -1; }
+// FIXME implement on this platform.
+void GetMemoryProfile(fill_profile_f cb, uptr *stats, uptr stats_size) { }
+
+
} // namespace __sanitizer
#endif // _WIN32
More information about the llvm-commits
mailing list