 Chromium Code Reviews
 Chromium Code Reviews Issue 7671034:
  doubly-linked free-lists for thread caches and page heaps  (Closed) 
  Base URL: http://git.chromium.org/git/chromium.git@trunk
    
  
    Issue 7671034:
  doubly-linked free-lists for thread caches and page heaps  (Closed) 
  Base URL: http://git.chromium.org/git/chromium.git@trunk| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2011, 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 | 
| 11 // copyright notice, this list of conditions and the following disclaimer | 11 // copyright notice, this list of conditions and the following disclaimer | 
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 const int batch_size = Static::sizemap()->num_objects_to_move(cl); | 146 const int batch_size = Static::sizemap()->num_objects_to_move(cl); | 
| 147 | 147 | 
| 148 const int num_to_move = min<int>(list->max_length(), batch_size); | 148 const int num_to_move = min<int>(list->max_length(), batch_size); | 
| 149 void *start, *end; | 149 void *start, *end; | 
| 150 int fetch_count = Static::central_cache()[cl].RemoveRange( | 150 int fetch_count = Static::central_cache()[cl].RemoveRange( | 
| 151 &start, &end, num_to_move); | 151 &start, &end, num_to_move); | 
| 152 | 152 | 
| 153 ASSERT((start == NULL) == (fetch_count == 0)); | 153 ASSERT((start == NULL) == (fetch_count == 0)); | 
| 154 if (--fetch_count >= 0) { | 154 if (--fetch_count >= 0) { | 
| 155 size_ += byte_size * fetch_count; | 155 size_ += byte_size * fetch_count; | 
| 156 list->PushRange(fetch_count, SLL_Next(start), end); | 156 // Pop the top of the list and add the rest to the freelist | 
| 
jar (doing other things)
2011/08/20 02:40:30
nit: This file they do use periods at the end of t
 
bxx
2011/08/24 00:19:24
Done.  Although they do not consistently use perio
 | |
| 157 void *next = start; | |
| 
jar (doing other things)
2011/08/20 02:40:30
Perhaps a better name than |next| would be |second
 
bxx
2011/08/24 00:19:24
Done.
 | |
| 158 start = FL_Pop(&next); | |
| 159 list->PushRange(fetch_count, next, end); | |
| 157 } | 160 } | 
| 158 | 161 | 
| 159 // Increase max length slowly up to batch_size. After that, | 162 // Increase max length slowly up to batch_size. After that, | 
| 160 // increase by batch_size in one shot so that the length is a | 163 // increase by batch_size in one shot so that the length is a | 
| 161 // multiple of batch_size. | 164 // multiple of batch_size. | 
| 162 if (list->max_length() < batch_size) { | 165 if (list->max_length() < batch_size) { | 
| 163 list->set_max_length(list->max_length() + 1); | 166 list->set_max_length(list->max_length() + 1); | 
| 164 } else { | 167 } else { | 
| 165 // Don't let the list get too long. In 32 bit builds, the length | 168 // Don't let the list get too long. In 32 bit builds, the length | 
| 166 // is represented by a 16 bit int, so we need to watch out for | 169 // is represented by a 16 bit int, so we need to watch out for | 
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 void ThreadCache::set_overall_thread_cache_size(size_t new_size) { | 496 void ThreadCache::set_overall_thread_cache_size(size_t new_size) { | 
| 494 // Clip the value to a reasonable range | 497 // Clip the value to a reasonable range | 
| 495 if (new_size < kMinThreadCacheSize) new_size = kMinThreadCacheSize; | 498 if (new_size < kMinThreadCacheSize) new_size = kMinThreadCacheSize; | 
| 496 if (new_size > (1<<30)) new_size = (1<<30); // Limit to 1GB | 499 if (new_size > (1<<30)) new_size = (1<<30); // Limit to 1GB | 
| 497 overall_thread_cache_size_ = new_size; | 500 overall_thread_cache_size_ = new_size; | 
| 498 | 501 | 
| 499 RecomputePerThreadCacheSize(); | 502 RecomputePerThreadCacheSize(); | 
| 500 } | 503 } | 
| 501 | 504 | 
| 502 } // namespace tcmalloc | 505 } // namespace tcmalloc | 
| OLD | NEW |