Changeset 28727 in webkit for trunk/JavaScriptCore/wtf/FastMalloc.cpp
- Timestamp:
- Dec 14, 2007, 4:25:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/FastMalloc.cpp
r28455 r28727 236 236 #endif 237 237 238 #ifndef PRIuS 239 #define PRIuS "zu" 240 #endif 241 238 242 // Calling pthread_getspecific through a global function pointer is faster than a normal 239 243 // call to the function on Mac OS X, and it's used in performance-critical code. So we … … 672 676 } 673 677 if (sc != kNumClasses) { 674 MESSAGE("wrong number of size classes: found % dinstead of %d\n",678 MESSAGE("wrong number of size classes: found %" PRIuS " instead of %d\n", 675 679 sc, int(kNumClasses)); 676 680 abort(); … … 691 695 const size_t sc = SizeClass(size); 692 696 if (sc == 0) { 693 MESSAGE("Bad size class % dfor %" PRIuS "\n", sc, size);697 MESSAGE("Bad size class %" PRIuS " for %" PRIuS "\n", sc, size); 694 698 abort(); 695 699 } 696 700 if (sc > 1 && size <= class_to_size[sc-1]) { 697 MESSAGE("Allocating unnecessarily large class % dfor %" PRIuS701 MESSAGE("Allocating unnecessarily large class %" PRIuS " for %" PRIuS 698 702 "\n", sc, size); 699 703 abort(); 700 704 } 701 705 if (sc >= kNumClasses) { 702 MESSAGE("Bad size class % dfor %" PRIuS "\n", sc, size);706 MESSAGE("Bad size class %" PRIuS " for %" PRIuS "\n", sc, size); 703 707 abort(); 704 708 } 705 709 const size_t s = class_to_size[sc]; 706 710 if (size > s) { 707 MESSAGE("Bad size %" PRIuS " for %" PRIuS " (sc = %d)\n", s, size, sc);711 MESSAGE("Bad size %" PRIuS " for %" PRIuS " (sc = %" PRIuS ")\n", s, size, sc); 708 712 abort(); 709 713 } 710 714 if (s == 0) { 711 MESSAGE("Bad size %" PRIuS " for %" PRIuS " (sc = % d)\n", s, size, sc);715 MESSAGE("Bad size %" PRIuS " for %" PRIuS " (sc = %" PRIuS ")\n", s, size, sc); 712 716 abort(); 713 717 } … … 1329 1333 if (scavenge_counter_ >= 0) return; // Not yet time to scavenge 1330 1334 1331 // Never delay scavenging for more than the following number of1332 // deallocated pages. With 4K pages, this comes to 4GB of1333 // deallocation.1334 static const int kMaxReleaseDelay = 1 << 20;1335 1336 1335 // If there is nothing to release, wait for so many pages before 1337 // scavenging again. With 4K pages, this comes to 1GB of memory. 1338 static const int kDefaultReleaseDelay = 1 << 18; 1339 1340 const double rate = FLAGS_tcmalloc_release_rate; 1341 if (rate <= 1e-6) { 1342 // Tiny release rate means that releasing is disabled. 1343 scavenge_counter_ = kDefaultReleaseDelay; 1344 return; 1345 } 1336 // scavenging again. With 4K pages, this comes to 16MB of memory. 1337 static const size_t kDefaultReleaseDelay = 1 << 8; 1346 1338 1347 1339 // Find index of free list to scavenge … … 1358 1350 DLL_Prepend(&slist->returned, s); 1359 1351 1360 // Compute how long to wait until we return memory. 1361 // FLAGS_tcmalloc_release_rate==1 means wait for 1000 pages 1362 // after releasing one page. 1363 const double mult = 1000.0 / rate; 1364 double wait = mult * static_cast<double>(s->length); 1365 if (wait > kMaxReleaseDelay) { 1366 // Avoid overflow and bound to reasonable range 1367 wait = kMaxReleaseDelay; 1368 } 1369 scavenge_counter_ = static_cast<int64_t>(wait); 1370 1371 scavenge_index_ = index; // Scavenge at index+1 next time 1352 scavenge_counter_ = max(64UL, min(kDefaultReleaseDelay, kDefaultReleaseDelay - (free_pages_ / kDefaultReleaseDelay))); 1353 // fprintf(stderr, "Released %zu pages at 0x%08zx to the system from index %zu. Delaying for %lld pages before scavenging next.\n", s->length, s->start << kPageShift, index, scavenge_counter_); 1354 1355 if (index == kMaxPages && !DLL_IsEmpty(&slist->normal)) 1356 scavenge_index_ = index - 1; 1357 else 1358 scavenge_index_ = index; 1372 1359 return; 1373 1360 } … … 1377 1364 // Nothing to scavenge, delay for a while 1378 1365 scavenge_counter_ = kDefaultReleaseDelay; 1366 // fprintf(stderr, "Nothing to scavenge. Delaying for %lld pages before scavenging next.\n", scavenge_counter_); 1379 1367 } 1380 1368
Note:
See TracChangeset
for help on using the changeset viewer.