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

Side by Side Diff: src/mark-compact.cc

Issue 18635006: Fix estimation of released pages when collecting evacuation candidates. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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
« no previous file with comments | « src/heap.cc ('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 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 774
775 if (over_reserved > reserved / 3 && over_reserved >= 2 * space->AreaSize()) { 775 if (over_reserved > reserved / 3 && over_reserved >= 2 * space->AreaSize()) {
776 // If over-usage is very high (more than a third of the space), we 776 // If over-usage is very high (more than a third of the space), we
777 // try to free all mostly empty pages. We expect that almost empty 777 // try to free all mostly empty pages. We expect that almost empty
778 // pages are even easier to compact so bump the limit even more. 778 // pages are even easier to compact so bump the limit even more.
779 mode = REDUCE_MEMORY_FOOTPRINT; 779 mode = REDUCE_MEMORY_FOOTPRINT;
780 max_evacuation_candidates *= 2; 780 max_evacuation_candidates *= 2;
781 } 781 }
782 782
783 if (FLAG_trace_fragmentation && mode == REDUCE_MEMORY_FOOTPRINT) { 783 if (FLAG_trace_fragmentation && mode == REDUCE_MEMORY_FOOTPRINT) {
784 PrintF("Estimated over reserved memory: %.1f / %.1f MB (threshold %d)\n", 784 PrintF("Estimated over reserved memory: %.1f / %.1f MB (threshold %d), "
785 "evacuation candidate limit: %d\n",
785 static_cast<double>(over_reserved) / MB, 786 static_cast<double>(over_reserved) / MB,
786 static_cast<double>(reserved) / MB, 787 static_cast<double>(reserved) / MB,
787 static_cast<int>(kFreenessThreshold)); 788 static_cast<int>(kFreenessThreshold),
789 max_evacuation_candidates);
788 } 790 }
789 791
790 intptr_t estimated_release = 0; 792 intptr_t estimated_release = 0;
791 793
792 Candidate candidates[kMaxMaxEvacuationCandidates]; 794 Candidate candidates[kMaxMaxEvacuationCandidates];
793 795
794 max_evacuation_candidates = 796 max_evacuation_candidates =
795 Min(kMaxMaxEvacuationCandidates, max_evacuation_candidates); 797 Min(kMaxMaxEvacuationCandidates, max_evacuation_candidates);
796 798
797 int count = 0; 799 int count = 0;
798 int fragmentation = 0; 800 int fragmentation = 0;
799 Candidate* least = NULL; 801 Candidate* least = NULL;
800 802
801 PageIterator it(space); 803 PageIterator it(space);
802 if (it.has_next()) it.next(); // Never compact the first page. 804 if (it.has_next()) it.next(); // Never compact the first page.
803 805
804 while (it.has_next()) { 806 while (it.has_next()) {
805 Page* p = it.next(); 807 Page* p = it.next();
806 p->ClearEvacuationCandidate(); 808 p->ClearEvacuationCandidate();
807 809
808 if (FLAG_stress_compaction) { 810 if (FLAG_stress_compaction) {
809 unsigned int counter = space->heap()->ms_count(); 811 unsigned int counter = space->heap()->ms_count();
810 uintptr_t page_number = reinterpret_cast<uintptr_t>(p) >> kPageSizeBits; 812 uintptr_t page_number = reinterpret_cast<uintptr_t>(p) >> kPageSizeBits;
811 if ((counter & 1) == (page_number & 1)) fragmentation = 1; 813 if ((counter & 1) == (page_number & 1)) fragmentation = 1;
812 } else if (mode == REDUCE_MEMORY_FOOTPRINT) { 814 } else if (mode == REDUCE_MEMORY_FOOTPRINT) {
813 // Don't try to release too many pages. 815 // Don't try to release too many pages.
814 if (estimated_release >= ((over_reserved * 3) / 4)) { 816 if (estimated_release >= over_reserved) {
815 continue; 817 continue;
816 } 818 }
817 819
818 intptr_t free_bytes = 0; 820 intptr_t free_bytes = 0;
819 821
820 if (!p->WasSwept()) { 822 if (!p->WasSwept()) {
821 free_bytes = (p->area_size() - p->LiveBytes()); 823 free_bytes = (p->area_size() - p->LiveBytes());
822 } else { 824 } else {
823 PagedSpace::SizeStats sizes; 825 PagedSpace::SizeStats sizes;
824 space->ObtainFreeListStatistics(p, &sizes); 826 space->ObtainFreeListStatistics(p, &sizes);
825 free_bytes = sizes.Total(); 827 free_bytes = sizes.Total();
826 } 828 }
827 829
828 int free_pct = static_cast<int>(free_bytes * 100) / p->area_size(); 830 int free_pct = static_cast<int>(free_bytes * 100) / p->area_size();
829 831
830 if (free_pct >= kFreenessThreshold) { 832 if (free_pct >= kFreenessThreshold) {
831 estimated_release += 2 * p->area_size() - free_bytes; 833 estimated_release += free_bytes;
832 fragmentation = free_pct; 834 fragmentation = free_pct;
833 } else { 835 } else {
834 fragmentation = 0; 836 fragmentation = 0;
835 } 837 }
836 838
837 if (FLAG_trace_fragmentation) { 839 if (FLAG_trace_fragmentation) {
838 PrintF("%p [%s]: %d (%.2f%%) free %s\n", 840 PrintF("%p [%s]: %d (%.2f%%) free %s\n",
839 reinterpret_cast<void*>(p), 841 reinterpret_cast<void*>(p),
840 AllocationSpaceName(space->identity()), 842 AllocationSpaceName(space->identity()),
841 static_cast<int>(free_bytes), 843 static_cast<int>(free_bytes),
(...skipping 3475 matching lines...) Expand 10 before | Expand all | Expand 10 after
4317 while (buffer != NULL) { 4319 while (buffer != NULL) {
4318 SlotsBuffer* next_buffer = buffer->next(); 4320 SlotsBuffer* next_buffer = buffer->next();
4319 DeallocateBuffer(buffer); 4321 DeallocateBuffer(buffer);
4320 buffer = next_buffer; 4322 buffer = next_buffer;
4321 } 4323 }
4322 *buffer_address = NULL; 4324 *buffer_address = NULL;
4323 } 4325 }
4324 4326
4325 4327
4326 } } // namespace v8::internal 4328 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698