| 52 | } |
| 53 | |
| 54 | bool MigrationController::ExtractDRAMPage(DRAMPageStats& stats, |
| 55 | Profiler& profiler) { |
| 56 | if (dram_heap_.empty()) { |
| 57 | int dirts = 0; |
| 58 | for (unordered_map<uint64_t, PTTEntry>::iterator it = entries_.begin(); |
| 59 | it != entries_.end(); ++it) { |
| 60 | double wr = it->second.epoch_writes / page_blocks_; |
| 61 | dram_heap_.push_back({it->first, it->second.state, wr}); |
| 62 | |
| 63 | total_dram_writes_ += it->second.epoch_writes; |
| 64 | dirts += (it->second.epoch_writes ? 1 : 0); |
| 65 | } |
| 66 | assert(dirts == dirty_entries_); |
| 67 | dirty_dram_pages_ += dirty_entries_; |
| 68 | |
| 69 | make_heap(dram_heap_.begin(), dram_heap_.end()); |
| 70 | } |
| 71 | profiler.AddTableOp(); |
| 72 | |
| 73 | if (dram_heap_.empty()) return false; |
| 74 | |
| 75 | stats = dram_heap_.front(); |
| 76 | pop_heap(dram_heap_.begin(), dram_heap_.end()); |
| 77 | dram_heap_.pop_back(); |
| 78 | return true; |
| 79 | } |
| 80 | |
| 81 | void MigrationController::Clear(Profiler& profiler) { |
| 82 | profiler.AddPageMoveInter(dirty_entries_); // epoch write-backs |