This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Excessive memory usage by associative arrays
- From: Sergey Klyaus <myautneko at gmail dot com>
- To: systemtap <systemtap at sourceware dot org>
- Date: Mon, 19 Jan 2015 20:58:17 +0400
- Subject: Excessive memory usage by associative arrays
- Authentication-results: sourceware.org; auth=none
Hello!
OS: CentOS 7.0 with stock kernel
SystemTap: 2.4
I created script that contains plenty of associative arrays and
statistics. OOM Killer kills stapio even before module is initialized.
I've added debug print to a _stp_map_new and noticed that it
allocation is really huge:
- By default MAXMAPENTRIES is 2048
- Each string is stored statically and MAP_STRING_LENGTH is 256 (i
have 2 keys so its 256)
- Plus statistics data gives us 1088 bytes per entry
- SystemTap initializes map on per-cpu basis and do it with
for_each_possible_cpu() (128 in my case)
So this simple script:
stap -e ' global a;
probe timer.s(1) {
a["aaaa", "bbbb"] <<< 1;
}
probe timer.s(60) {
println(@count(a["aaaa", "bbbb"]));
}'
would eat about 300 Mb of memory.
Of course, I may reduce MAXMAPENTRIES, but I think there is something
wrong with such greedy allocation...
For the record, similiar DTrace script works perfectly (after I
removed leak of records :) ).
Thanks in advance.
BR, Sergey.