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

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

Issue 9310021: [NOT TO COMMIT!] Merge Chromium-specific changes in tcmalloc thru. the original gperftools r136. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed some build inhibitor. Created 8 years, 10 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
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 const int batch_size = Static::sizemap()->num_objects_to_move(cl); 157 const int batch_size = Static::sizemap()->num_objects_to_move(cl);
158 158
159 const int num_to_move = min<int>(list->max_length(), batch_size); 159 const int num_to_move = min<int>(list->max_length(), batch_size);
160 void *start, *end; 160 void *start, *end;
161 int fetch_count = Static::central_cache()[cl].RemoveRange( 161 int fetch_count = Static::central_cache()[cl].RemoveRange(
162 &start, &end, num_to_move); 162 &start, &end, num_to_move);
163 163
164 ASSERT((start == NULL) == (fetch_count == 0)); 164 ASSERT((start == NULL) == (fetch_count == 0));
165 if (--fetch_count >= 0) { 165 if (--fetch_count >= 0) {
166 size_ += byte_size * fetch_count; 166 size_ += byte_size * fetch_count;
167 list->PushRange(fetch_count, SLL_Next(start), end); 167 // Pop the top of the list and add the rest to the freelist.
168 void *second = start;
169 start = FL_Pop(&second);
170 list->PushRange(fetch_count, second, end);
168 } 171 }
169 172
170 // Increase max length slowly up to batch_size. After that, 173 // Increase max length slowly up to batch_size. After that,
171 // increase by batch_size in one shot so that the length is a 174 // increase by batch_size in one shot so that the length is a
172 // multiple of batch_size. 175 // multiple of batch_size.
173 if (list->max_length() < batch_size) { 176 if (list->max_length() < batch_size) {
174 list->set_max_length(list->max_length() + 1); 177 list->set_max_length(list->max_length() + 1);
175 } else { 178 } else {
176 // Don't let the list get too long. In 32 bit builds, the length 179 // Don't let the list get too long. In 32 bit builds, the length
177 // is represented by a 16 bit int, so we need to watch out for 180 // is represented by a 16 bit int, so we need to watch out for
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 void ThreadCache::set_overall_thread_cache_size(size_t new_size) { 497 void ThreadCache::set_overall_thread_cache_size(size_t new_size) {
495 // Clip the value to a reasonable range 498 // Clip the value to a reasonable range
496 if (new_size < kMinThreadCacheSize) new_size = kMinThreadCacheSize; 499 if (new_size < kMinThreadCacheSize) new_size = kMinThreadCacheSize;
497 if (new_size > (1<<30)) new_size = (1<<30); // Limit to 1GB 500 if (new_size > (1<<30)) new_size = (1<<30); // Limit to 1GB
498 overall_thread_cache_size_ = new_size; 501 overall_thread_cache_size_ = new_size;
499 502
500 RecomputePerThreadCacheSize(); 503 RecomputePerThreadCacheSize();
501 } 504 }
502 505
503 } // namespace tcmalloc 506 } // namespace tcmalloc
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/thread_cache.h ('k') | third_party/tcmalloc/chromium/src/windows/addr2line-pdb.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698