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

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

Issue 850663002: Oilpan: fix computation of ThreadState::m_collectionRate. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: compute m_collectionRate in postGC() Created 5 years, 11 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 | « 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 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 if (sweepForbidden()) 850 if (sweepForbidden())
851 return; 851 return;
852 852
853 ThreadState::SweepForbiddenScope scope(this); 853 ThreadState::SweepForbiddenScope scope(this);
854 { 854 {
855 TRACE_EVENT0("blink_gc", "ThreadState::completeSweep"); 855 TRACE_EVENT0("blink_gc", "ThreadState::completeSweep");
856 for (int i = 0; i < NumberOfHeaps; i++) 856 for (int i = 0; i < NumberOfHeaps; i++)
857 m_heaps[i]->completeSweep(); 857 m_heaps[i]->completeSweep();
858 } 858 }
859 859
860 if (isMainThread()) {
861 // FIXME: Heap::markedObjectSize() may not be accurate because other
862 // threads may not have finished sweeping.
863 m_collectionRate = 1.0 * Heap::markedObjectSize() / m_allocatedObjectSiz eBeforeSweeping;
864 } else {
865 // FIXME: We should make m_lowCollectionRate available in non-main
866 // threads.
867 m_collectionRate = 1.0;
868 }
869
870 setGCState(gcState() == Sweeping ? NoGCScheduled : GCScheduled); 860 setGCState(gcState() == Sweeping ? NoGCScheduled : GCScheduled);
871 } 861 }
872 862
873 void ThreadState::prepareRegionTree() 863 void ThreadState::prepareRegionTree()
874 { 864 {
875 // Add the regions allocated by this thread to the region search tree. 865 // Add the regions allocated by this thread to the region search tree.
876 for (PageMemoryRegion* region : m_allocatedRegionsSinceLastGC) 866 for (PageMemoryRegion* region : m_allocatedRegionsSinceLastGC)
877 Heap::addPageMemoryRegion(region); 867 Heap::addPageMemoryRegion(region);
878 m_allocatedRegionsSinceLastGC.clear(); 868 m_allocatedRegionsSinceLastGC.clear();
879 } 869 }
880 870
881 void ThreadState::flushHeapDoesNotContainCacheIfNeeded() 871 void ThreadState::flushHeapDoesNotContainCacheIfNeeded()
882 { 872 {
883 if (m_shouldFlushHeapDoesNotContainCache) { 873 if (m_shouldFlushHeapDoesNotContainCache) {
884 Heap::flushHeapDoesNotContainCache(); 874 Heap::flushHeapDoesNotContainCache();
885 m_shouldFlushHeapDoesNotContainCache = false; 875 m_shouldFlushHeapDoesNotContainCache = false;
886 } 876 }
887 } 877 }
888 878
889 void ThreadState::preGC() 879 void ThreadState::preGC()
890 { 880 {
891 ASSERT(!isInGC()); 881 ASSERT(!isInGC());
892 setGCState(GCRunning); 882 setGCState(GCRunning);
893 makeConsistentForSweeping(); 883 makeConsistentForSweeping();
894 prepareRegionTree(); 884 prepareRegionTree();
895 flushHeapDoesNotContainCacheIfNeeded(); 885 flushHeapDoesNotContainCacheIfNeeded();
886 if (isMainThread())
887 m_allocatedObjectSizeBeforeGC = Heap::allocatedObjectSize() + Heap::mark edObjectSize();
896 } 888 }
897 889
898 void ThreadState::postGC(GCType gcType) 890 void ThreadState::postGC(GCType gcType)
899 { 891 {
900 ASSERT(isInGC()); 892 ASSERT(isInGC());
901 setGCState(gcType == GCWithSweep ? EagerSweepScheduled : LazySweepScheduled) ; 893 setGCState(gcType == GCWithSweep ? EagerSweepScheduled : LazySweepScheduled) ;
894 if (isMainThread() && m_allocatedObjectSizeBeforeGC) {
895 // FIXME: Heap::markedObjectSize() may not be accurate because other
896 // threads may not have finished sweeping.
897 m_collectionRate = 1.0 * Heap::markedObjectSize() / m_allocatedObjectSiz eBeforeGC;
haraken 2015/01/14 01:36:26 Heap::markedObjectSize() is accumulated in the (la
sof 2015/01/14 06:14:27 Thanks, I realized the same overnight. Sorry about
sof 2015/01/14 09:53:24 Now tidied, to some extent. The lagging sweeps acr
898 ASSERT(m_collectionRate >= 0. && m_collectionRate <= 1.);
899 } else {
900 // FIXME: We should make m_collectionRate available in non-main threads.
901 m_collectionRate = 1.0;
902 }
903
902 for (int i = 0; i < NumberOfHeaps; i++) 904 for (int i = 0; i < NumberOfHeaps; i++)
903 m_heaps[i]->prepareForSweep(); 905 m_heaps[i]->prepareForSweep();
904 } 906 }
905 907
906 void ThreadState::prepareHeapForTermination() 908 void ThreadState::prepareHeapForTermination()
907 { 909 {
908 checkThread(); 910 checkThread();
909 for (int i = 0; i < NumberOfHeaps; ++i) 911 for (int i = 0; i < NumberOfHeaps; ++i)
910 m_heaps[i]->prepareHeapForTermination(); 912 m_heaps[i]->prepareHeapForTermination();
911 } 913 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 } 1032 }
1031 } 1033 }
1032 1034
1033 void ThreadState::postGCProcessing() 1035 void ThreadState::postGCProcessing()
1034 { 1036 {
1035 checkThread(); 1037 checkThread();
1036 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled) 1038 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled)
1037 return; 1039 return;
1038 1040
1039 m_didV8GCAfterLastGC = false; 1041 m_didV8GCAfterLastGC = false;
1040 if (isMainThread())
1041 m_allocatedObjectSizeBeforeSweeping = Heap::allocatedObjectSize();
1042 1042
1043 #if ENABLE(GC_PROFILE_HEAP) 1043 #if ENABLE(GC_PROFILE_HEAP)
1044 // We snapshot the heap prior to sweeping to get numbers for both resources 1044 // We snapshot the heap prior to sweeping to get numbers for both resources
1045 // that have been allocated since the last GC and for resources that are 1045 // that have been allocated since the last GC and for resources that are
1046 // going to be freed. 1046 // going to be freed.
1047 bool gcTracingEnabled; 1047 bool gcTracingEnabled;
1048 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); 1048 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled);
1049 if (gcTracingEnabled) 1049 if (gcTracingEnabled)
1050 snapshot(); 1050 snapshot();
1051 #endif 1051 #endif
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 return gcInfo; 1162 return gcInfo;
1163 } 1163 }
1164 } 1164 }
1165 if (needLockForIteration) 1165 if (needLockForIteration)
1166 threadAttachMutex().unlock(); 1166 threadAttachMutex().unlock();
1167 return nullptr; 1167 return nullptr;
1168 } 1168 }
1169 #endif 1169 #endif
1170 1170
1171 } // namespace blink 1171 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698