| 876 | } |
| 877 | |
| 878 | void AsyncDataCache::possibleSsdSave(uint64_t bytes) { |
| 879 | constexpr int32_t kMinSavePages = 4096; // Save at least 16MB at a time. |
| 880 | if (ssdCache_ == nullptr) { |
| 881 | return; |
| 882 | } |
| 883 | |
| 884 | ssdSaveable_ += bytes; |
| 885 | if (memory::AllocationTraits::numPages(ssdSaveable_) > |
| 886 | std::max<int32_t>(kMinSavePages, cachedPages_ / 8)) { |
| 887 | // Do not start a new save if another one is in progress. |
| 888 | if (!ssdCache_->startWrite()) { |
| 889 | return; |
| 890 | } |
| 891 | LOG(INFO) << "possibleSsdSave:" << ssdSaveable_ << "--" |
| 892 | << memory::AllocationTraits::kPageSize << "--" |
| 893 | << ssdSaveable_ / memory::AllocationTraits::kPageSize << "--" |
| 894 | << std::max<int32_t>(kMinSavePages, cachedPages_ / 8); |
| 895 | saveToSsd(); |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | void AsyncDataCache::saveToSsd() { |
| 900 | std::vector<CachePin> pins; |
no test coverage detected