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

Side by Side Diff: third_party/WebKit/Source/platform/heap/ThreadState.cpp

Issue 2178393002: Fix BlinkGC triggering so it is more sensitive to PartitionAlloc only allocations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use MemoryPressureGC Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include <pthread_np.h> 69 #include <pthread_np.h>
70 #endif 70 #endif
71 71
72 namespace blink { 72 namespace blink {
73 73
74 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = nullptr; 74 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = nullptr;
75 uintptr_t ThreadState::s_mainThreadStackStart = 0; 75 uintptr_t ThreadState::s_mainThreadStackStart = 0;
76 uintptr_t ThreadState::s_mainThreadUnderestimatedStackSize = 0; 76 uintptr_t ThreadState::s_mainThreadUnderestimatedStackSize = 0;
77 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)]; 77 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)];
78 78
79 const size_t defaultAllocatedObjectSizeThreshold = 100 * 1024;
80
79 ThreadState::ThreadState(bool perThreadHeapEnabled) 81 ThreadState::ThreadState(bool perThreadHeapEnabled)
80 : m_thread(currentThread()) 82 : m_thread(currentThread())
81 , m_persistentRegion(wrapUnique(new PersistentRegion())) 83 , m_persistentRegion(wrapUnique(new PersistentRegion()))
82 #if OS(WIN) && COMPILER(MSVC) 84 #if OS(WIN) && COMPILER(MSVC)
83 , m_threadStackSize(0) 85 , m_threadStackSize(0)
84 #endif 86 #endif
85 , m_startOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart( ))) 87 , m_startOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart( )))
86 , m_endOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart()) ) 88 , m_endOfStack(reinterpret_cast<intptr_t*>(StackFrameDepth::getStackStart()) )
87 , m_safePointScopeMarker(nullptr) 89 , m_safePointScopeMarker(nullptr)
88 , m_atSafePoint(false) 90 , m_atSafePoint(false)
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 496
495 // If the estimatedSize is 0, we set a high growing rate to trigger a GC. 497 // If the estimatedSize is 0, we set a high growing rate to trigger a GC.
496 double growingRate = estimatedSize > 0 ? 1.0 * currentSize / estimatedSize : 100; 498 double growingRate = estimatedSize > 0 ? 1.0 * currentSize / estimatedSize : 100;
497 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "ThreadState::partitio nAllocEstimatedSizeKB", std::min(estimatedSize / 1024, static_cast<size_t>(INT_M AX))); 499 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "ThreadState::partitio nAllocEstimatedSizeKB", std::min(estimatedSize / 1024, static_cast<size_t>(INT_M AX)));
498 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "ThreadState::partitio nAllocGrowingRate", static_cast<int>(100 * growingRate)); 500 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink_gc"), "ThreadState::partitio nAllocGrowingRate", static_cast<int>(100 * growingRate));
499 return growingRate; 501 return growingRate;
500 } 502 }
501 503
502 // TODO(haraken): We should improve the GC heuristics. The heuristics affect 504 // TODO(haraken): We should improve the GC heuristics. The heuristics affect
503 // performance significantly. 505 // performance significantly.
504 bool ThreadState::judgeGCThreshold(size_t totalMemorySizeThreshold, double heapG rowingRateThreshold) 506 bool ThreadState::judgeGCThreshold(size_t allocatedObjectSizeThreshold, size_t t otalMemorySizeThreshold, double heapGrowingRateThreshold)
505 { 507 {
506 // If the allocated object size or the total memory size is small, don't tri gger a GC. 508 // If the allocated object size or the total memory size is small, don't tri gger a GC.
507 if (m_heap->heapStats().allocatedObjectSize() < 100 * 1024 || totalMemorySiz e() < totalMemorySizeThreshold) 509 if (m_heap->heapStats().allocatedObjectSize() < allocatedObjectSizeThreshold || totalMemorySize() < totalMemorySizeThreshold)
508 return false; 510 return false;
509 // If the growing rate of Oilpan's heap or PartitionAlloc is high enough, 511 // If the growing rate of Oilpan's heap or PartitionAlloc is high enough,
510 // trigger a GC. 512 // trigger a GC.
511 #if PRINT_HEAP_STATS 513 #if PRINT_HEAP_STATS
512 dataLogF("heapGrowingRate=%.1lf, partitionAllocGrowingRate=%.1lf\n", heapGro wingRate(), partitionAllocGrowingRate()); 514 dataLogF("heapGrowingRate=%.1lf, partitionAllocGrowingRate=%.1lf\n", heapGro wingRate(), partitionAllocGrowingRate());
513 #endif 515 #endif
514 return heapGrowingRate() >= heapGrowingRateThreshold || partitionAllocGrowin gRate() >= heapGrowingRateThreshold; 516 return heapGrowingRate() >= heapGrowingRateThreshold || partitionAllocGrowin gRate() >= heapGrowingRateThreshold;
515 } 517 }
516 518
517 bool ThreadState::shouldScheduleIdleGC() 519 bool ThreadState::shouldScheduleIdleGC()
518 { 520 {
519 if (gcState() != NoGCScheduled) 521 if (gcState() != NoGCScheduled)
520 return false; 522 return false;
521 return judgeGCThreshold(1024 * 1024, 1.5); 523 return judgeGCThreshold(defaultAllocatedObjectSizeThreshold, 1024 * 1024, 1. 5);
522 } 524 }
523 525
524 bool ThreadState::shouldScheduleV8FollowupGC() 526 bool ThreadState::shouldScheduleV8FollowupGC()
525 { 527 {
526 return judgeGCThreshold(32 * 1024 * 1024, 1.5); 528 return judgeGCThreshold(defaultAllocatedObjectSizeThreshold, 32 * 1024 * 102 4, 1.5);
527 } 529 }
528 530
529 bool ThreadState::shouldSchedulePageNavigationGC(float estimatedRemovalRatio) 531 bool ThreadState::shouldSchedulePageNavigationGC(float estimatedRemovalRatio)
530 { 532 {
531 // If estimatedRemovalRatio is low we should let IdleGC handle this. 533 // If estimatedRemovalRatio is low we should let IdleGC handle this.
532 if (estimatedRemovalRatio < 0.01) 534 if (estimatedRemovalRatio < 0.01)
533 return false; 535 return false;
534 return judgeGCThreshold(32 * 1024 * 1024, 1.5 * (1 - estimatedRemovalRatio)) ; 536 return judgeGCThreshold(defaultAllocatedObjectSizeThreshold, 32 * 1024 * 102 4, 1.5 * (1 - estimatedRemovalRatio));
535 } 537 }
536 538
537 bool ThreadState::shouldForceConservativeGC() 539 bool ThreadState::shouldForceConservativeGC()
538 { 540 {
539 // TODO(haraken): 400% is too large. Lower the heap growing factor. 541 // TODO(haraken): 400% is too large. Lower the heap growing factor.
540 return judgeGCThreshold(32 * 1024 * 1024, 5.0); 542 return judgeGCThreshold(defaultAllocatedObjectSizeThreshold, 32 * 1024 * 102 4, 5.0);
541 } 543 }
542 544
543 // If we're consuming too much memory, trigger a conservative GC 545 // If we're consuming too much memory, trigger a conservative GC
544 // aggressively. This is a safe guard to avoid OOM. 546 // aggressively. This is a safe guard to avoid OOM.
545 bool ThreadState::shouldForceMemoryPressureGC() 547 bool ThreadState::shouldForceMemoryPressureGC()
546 { 548 {
547 if (totalMemorySize() < 300 * 1024 * 1024) 549 if (totalMemorySize() < 300 * 1024 * 1024)
548 return false; 550 return false;
549 return judgeGCThreshold(0, 1.5); 551 return judgeGCThreshold(0, 0, 1.5);
550 } 552 }
551 553
552 void ThreadState::scheduleV8FollowupGCIfNeeded(BlinkGC::V8GCType gcType) 554 void ThreadState::scheduleV8FollowupGCIfNeeded(BlinkGC::V8GCType gcType)
553 { 555 {
554 ASSERT(checkThread()); 556 ASSERT(checkThread());
555 ThreadHeap::reportMemoryUsageForTracing(); 557 ThreadHeap::reportMemoryUsageForTracing();
556 558
557 #if PRINT_HEAP_STATS 559 #if PRINT_HEAP_STATS
558 dataLogF("ThreadState::scheduleV8FollowupGCIfNeeded (gcType=%s)\n", gcType = = BlinkGC::V8MajorGC ? "MajorGC" : "MinorGC"); 560 dataLogF("ThreadState::scheduleV8FollowupGCIfNeeded (gcType=%s)\n", gcType = = BlinkGC::V8MajorGC ? "MajorGC" : "MinorGC");
559 #endif 561 #endif
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 threadDump->AddScalar("dead_count", "objects", totalDeadCount); 1530 threadDump->AddScalar("dead_count", "objects", totalDeadCount);
1529 threadDump->AddScalar("live_size", "bytes", totalLiveSize); 1531 threadDump->AddScalar("live_size", "bytes", totalLiveSize);
1530 threadDump->AddScalar("dead_size", "bytes", totalDeadSize); 1532 threadDump->AddScalar("dead_size", "bytes", totalDeadSize);
1531 1533
1532 base::trace_event::MemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvide r::instance()->createMemoryAllocatorDumpForCurrentGC(heapsDumpName); 1534 base::trace_event::MemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvide r::instance()->createMemoryAllocatorDumpForCurrentGC(heapsDumpName);
1533 base::trace_event::MemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvi der::instance()->createMemoryAllocatorDumpForCurrentGC(classesDumpName); 1535 base::trace_event::MemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvi der::instance()->createMemoryAllocatorDumpForCurrentGC(classesDumpName);
1534 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->AddOwners hipEdge(classesDump->guid(), heapsDump->guid()); 1536 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->AddOwners hipEdge(classesDump->guid(), heapsDump->guid());
1535 } 1537 }
1536 1538
1537 } // namespace blink 1539 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698