summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoonsoo Kim <iamjoonsoo.kim@lge.com>2013-10-10 10:06:33 +0900
committerAliaksey Kandratsenka <alk@tut.by>2013-10-26 23:28:31 -0700
commitcc002ea19363e1ebbd7f3e809d116ab81a6862cd (patch)
tree62e9d5b2b0e420ca3147689029df61b2e4782df6
parent3e9a33e8c708ccf3ec91e3a3b14e924f5f79e4a6 (diff)
downloadgperftools-cc002ea19363e1ebbd7f3e809d116ab81a6862cd.tar.gz
skip unnecessary check during double-check SizeClass intergrity
On initialization step, tcmalloc double-checks SizeClass integrity with all possible size values, 0 to kMaxSize. This causes tremendous overhead for short-lived applications. For example, consider following command. 'find -exec grep something {} \;' Actual work of each grep is really small, but double-check requires more work. To reduce this overhead, it is best to remove double-check entirely. But we cannot be sure the integrity without double-checking, so alternative is needed. This patch doesn't remove double-check, instead, try to skip unnecessary check based on ClassIndex() implementation. This reduce much overhead and the code has same coverage as previous double-check. Following is the result of this patch. time LD_PRELOAD=libtcmalloc_minimal.so find ./ -exec grep "SOMETHING" {} \; * Before real 0m3.675s user 0m1.000s sys 0m0.640s * This patch real 0m2.833s user 0m0.056s sys 0m0.220s * Remove double-check entirely real 0m2.675s user 0m0.072s sys 0m0.184s
-rw-r--r--src/common.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/common.cc b/src/common.cc
index 50fbcf2..bd4f6ed 100644
--- a/src/common.cc
+++ b/src/common.cc
@@ -188,7 +188,7 @@ void SizeMap::Init() {
}
// Double-check sizes just to be safe
- for (size_t size = 0; size <= kMaxSize; size++) {
+ for (size_t size = 0; size <= kMaxSize;) {
const int sc = SizeClass(size);
if (sc <= 0 || sc >= kNumClasses) {
Log(kCrash, __FILE__, __LINE__,
@@ -203,6 +203,11 @@ void SizeMap::Init() {
Log(kCrash, __FILE__, __LINE__,
"Bad (class, size, requested)", sc, s, size);
}
+ if (size <= kMaxSmallSize) {
+ size += 8;
+ } else {
+ size += 128;
+ }
}
// Initialize the num_objects_to_move array.