Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: third_party/tcmalloc/chromium/src/sampler.cc

Issue 7050034: Merge google-perftools r109 (the current contents of third_party/tcmalloc/vendor) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/tcmalloc/chromium/src/sampler.h ('k') | third_party/tcmalloc/chromium/src/span.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 // --- 30 // ---
31 // All Rights Reserved. 31 // All Rights Reserved.
32 // 32 //
33 // Author: Daniel Ford 33 // Author: Daniel Ford
34 34
35 #include "sampler.h" 35 #include "sampler.h"
36 36
37 #include <algorithm> // For min() 37 #include <algorithm> // For min()
38 #include <cmath> 38 #include <math.h>
39 #include "base/commandlineflags.h"
39 40
40 using std::min; 41 using std::min;
41 42
42 // The approximate gap in bytes between sampling actions. 43 // The approximate gap in bytes between sampling actions.
43 // I.e., we take one sample approximately once every 44 // I.e., we take one sample approximately once every
44 // tcmalloc_sample_parameter bytes of allocation 45 // tcmalloc_sample_parameter bytes of allocation
45 // i.e. about once every 512KB. 46 // i.e. about once every 512KB if value is 1<<19.
46 #ifdef NO_TCMALLOC_SAMPLES 47 #ifdef NO_TCMALLOC_SAMPLES
47 DEFINE_int64(tcmalloc_sample_parameter, 0, 48 DEFINE_int64(tcmalloc_sample_parameter, 0,
48 "Unused: code is compiled with NO_TCMALLOC_SAMPLES"); 49 "Unused: code is compiled with NO_TCMALLOC_SAMPLES");
49 #else 50 #else
50 DEFINE_int64(tcmalloc_sample_parameter, 51 DEFINE_int64(tcmalloc_sample_parameter,
51 EnvToInt64("TCMALLOC_SAMPLE_PARAMETER", 0), 52 EnvToInt64("TCMALLOC_SAMPLE_PARAMETER", 0),
52 "The approximate gap in bytes between sampling actions. " 53 "The approximate gap in bytes between sampling actions. "
53 "This must be between 1 and 1<<58."); 54 "This must be between 1 and 2^58.");
54 // Note: there are other places in this file where the number 19 occurs.
55 #endif 55 #endif
56 56
57 namespace tcmalloc { 57 namespace tcmalloc {
58 58
59 // Statics for Sampler 59 // Statics for Sampler
60 double Sampler::log_table_[1<<kFastlogNumBits]; 60 double Sampler::log_table_[1<<kFastlogNumBits];
61 61
62 // Populate the lookup table for FastLog2. 62 // Populate the lookup table for FastLog2.
63 // This approximates the log2 curve with a step function. 63 // This approximates the log2 curve with a step function.
64 // Steps have height equal to log2 of the mid-point of the step. 64 // Steps have height equal to log2 of the mid-point of the step.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // For faster performance (save ~1/20th exec time), replace 121 // For faster performance (save ~1/20th exec time), replace
122 // min(0.0, FastLog2(q) - 26) by (Fastlog2(q) - 26.000705) 122 // min(0.0, FastLog2(q) - 26) by (Fastlog2(q) - 26.000705)
123 // The value 26.000705 is used rather than 26 to compensate 123 // The value 26.000705 is used rather than 26 to compensate
124 // for inaccuracies in FastLog2 which otherwise result in a 124 // for inaccuracies in FastLog2 which otherwise result in a
125 // negative answer. 125 // negative answer.
126 return static_cast<size_t>(min(0.0, (FastLog2(q) - 26)) * (-log(2.0) 126 return static_cast<size_t>(min(0.0, (FastLog2(q) - 26)) * (-log(2.0)
127 * FLAGS_tcmalloc_sample_parameter) + 1); 127 * FLAGS_tcmalloc_sample_parameter) + 1);
128 } 128 }
129 129
130 } // namespace tcmalloc 130 } // namespace tcmalloc
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/sampler.h ('k') | third_party/tcmalloc/chromium/src/span.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698