-
-
Save awreece/2657199 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ for t in build get main; do python parse.py $t.trace; done | |
# a trace of "go build file" | |
Malloc trace of 75809 mallocs over 5 cores | |
Cache line shared 2266 (2.99%) times | |
Cache line cold missed 12022 (15.86%) times | |
# a trace of "go get package" | |
Malloc trace of 163991 mallocs over 4 cores | |
Cache line shared 7507 (4.58%) times | |
Cache line cold missed 26232 (16.00%) times | |
# a trace of go.uik binary | |
Malloc trace of 25694 mallocs over 12 cores | |
Cache line shared 3784 (14.73%) times | |
Cache line cold missed 5219 (20.31%) times |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fileinput | |
import re | |
import sys | |
total_mallocs = 0 | |
cold_misses = 0 | |
false_shares = 0 | |
cache_line_size = 64 | |
cache = {} | |
core_map = {} | |
def update(core, ptr): | |
global total_mallocs | |
global cold_misses | |
global false_shares | |
line = ptr / cache_line_size | |
if line not in cache: | |
cold_misses += 1 | |
elif cache[line] != core: | |
false_shares += 1 | |
total_mallocs += 1 | |
core_map[core] = core | |
cache[line] = core | |
regex = re.compile(r'([^ ]*) ([^ ]*)] malloc ([^ ]*) -> ([^ ]*)\n') | |
for line in fileinput.input(sys.argv[1:]): | |
m = regex.match(line) | |
if m is not None: | |
g = m.groups() | |
update(int(g[1]), int(g[3],16)) | |
print "Malloc trace of %d mallocs over %d cores" % (total_mallocs, len(core_map)) | |
print "\tCache line shared %d (%.2f%%) times" % (false_shares, | |
float(false_shares) / | |
float(total_mallocs) * 100) | |
print "\tCache line cold missed %d (%.2f%%) times" % (cold_misses, | |
float(cold_misses) / | |
float(total_mallocs) * 100) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ hg diff | |
diff -r 9a55b03991e3 src/pkg/runtime/malloc.goc | |
--- a/src/pkg/runtime/malloc.goc Mon Apr 09 15:39:59 2012 -0400 | |
+++ b/src/pkg/runtime/malloc.goc Thu May 10 22:41:03 2012 -0400 | |
@@ -93,6 +93,7 @@ | |
} | |
} | |
+ runtime·printf("%D %d] malloc %d -> %p\n", runtime·nanotime(), m->id, size, v); | |
if(dogc && mstats.heap_alloc >= mstats.next_gc) | |
runtime·gc(0); | |
return v; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment