diff --git a/velox/common/caching/AsyncDataCache.cpp b/velox/common/caching/AsyncDataCache.cpp index 517aaaf3603cd..0bd10d7954947 100644 --- a/velox/common/caching/AsyncDataCache.cpp +++ b/velox/common/caching/AsyncDataCache.cpp @@ -519,9 +519,9 @@ void CacheShard::updateStats(CacheStats& stats) { void CacheShard::appendSsdSaveable(std::vector& pins) { std::lock_guard l(mutex_); - // Do not add more than 70% of entries to a write batch.If SSD save - // is slower than storage read, we must not have a situation where - // SSD save pins everything and stops reading. + // Do not add more than 70% of entries to a write batch. If SSD save is slower + // than storage read, we must not have a situation where SSD save pins + // everything and stops reading. const int32_t limit = (entries_.size() * 100) / 70; VELOX_CHECK(cache_->ssdCache()->writeInProgress()); for (auto& entry : entries_) { diff --git a/velox/common/caching/SsdCache.cpp b/velox/common/caching/SsdCache.cpp index 5b11fe89eebfc..b84846f25ced6 100644 --- a/velox/common/caching/SsdCache.cpp +++ b/velox/common/caching/SsdCache.cpp @@ -52,8 +52,9 @@ SsdCache::SsdCache( files_.reserve(numShards_); // Cache size must be a multiple of this so that each shard has the same max // size. - uint64_t sizeQuantum = numShards_ * SsdFile::kRegionSize; - int32_t fileMaxRegions = bits::roundUp(maxBytes, sizeQuantum) / sizeQuantum; + const uint64_t sizeQuantum = numShards_ * SsdFile::kRegionSize; + const int32_t fileMaxRegions = + bits::roundUp(maxBytes, sizeQuantum) / sizeQuantum; for (auto i = 0; i < numShards_; ++i) { files_.push_back(std::make_unique( fmt::format("{}{}", filePrefix_, i), @@ -79,11 +80,12 @@ bool SsdCache::startWrite() { } // There were writes in progress, so compensate for the increment. writesInProgress_.fetch_sub(numShards_); + VELOX_CHECK_GE(writesInProgress_, 0); return false; } void SsdCache::write(std::vector pins) { - VELOX_CHECK_LE(numShards_, writesInProgress_); + VELOX_CHECK_GE(numShards_, writesInProgress_); TestValue::adjust("facebook::velox::cache::SsdCache::write", this); @@ -103,6 +105,7 @@ void SsdCache::write(std::vector pins) { ++numNoStore; continue; } + struct PinHolder { std::vector pins; @@ -110,8 +113,8 @@ void SsdCache::write(std::vector pins) { : pins(std::move(_pins)) {} }; - // We move the mutable vector of pins to the executor. These must - // be wrapped in a shared struct to be passed via lambda capture. + // We move the mutable vector of pins to the executor. These must be wrapped + // in a shared struct to be passed via lambda capture. auto pinHolder = std::make_shared(std::move(shards[i])); executor_->add([this, i, pinHolder, bytes, startTimeUs]() { try { @@ -127,9 +130,11 @@ void SsdCache::write(std::vector pins) { // Typically occurs every few GB. Allows detecting unusually slow rates // from failing devices. VELOX_SSD_CACHE_LOG(INFO) << fmt::format( - "Wrote {}MB, {} MB/s", - bytes >> 20, - static_cast(bytes) / (getCurrentTimeMicro() - startTimeUs)); + "Wrote {}, {}/s", + succinctBytes(bytes), + succinctBytes( + static_cast(bytes) / + (getCurrentTimeMicro() - startTimeUs))); } }); } @@ -174,13 +179,13 @@ void SsdCache::clear() { } std::string SsdCache::toString() const { - auto data = stats(); - uint64_t capacity = maxBytes(); + const auto data = stats(); + const uint64_t capacity = maxBytes(); std::stringstream out; - out << "Ssd cache IO: Write " << (data.bytesWritten >> 20) << "MB read " - << (data.bytesRead >> 20) << "MB Size " << (capacity >> 30) - << "GB Occupied " << (data.bytesCached >> 30) << "GB"; - out << (data.entriesCached >> 10) << "K entries."; + out << "Ssd cache IO: Write " << succinctBytes(data.bytesWritten) << " read " + << succinctBytes(data.bytesRead) << " Size " << succinctBytes(capacity) + << " Occupied " << succinctBytes(data.bytesCached); + out << " " << (data.entriesCached >> 10) << "K entries."; out << "\nGroupStats: " << groupStats_->toString(capacity); return out.str(); } diff --git a/velox/common/caching/SsdCache.h b/velox/common/caching/SsdCache.h index 20c5d6e0b87cf..d7857c235a30e 100644 --- a/velox/common/caching/SsdCache.h +++ b/velox/common/caching/SsdCache.h @@ -32,13 +32,9 @@ class SsdCache { /// next multiple of kRegionSize * 'numShards'. This means that all the shards /// have an equal number of regions. For 2 shards and 200MB size, the size /// rounds up to 256M with 2 shards each of 128M (2 regions). - /// If 'checkpointIntervalBytes' is non-0, the cache makes a durable + /// If 'checkpointIntervalBytes' is non-zero, the cache makes a durable /// checkpointed state that survives restart after each /// 'checkpointIntervalBytes' written. - /// If 'setNoCowFlagForSsdFiles' is true, the cache sets 'no copy on write' - /// flag to each file. This prevents the cache to go over the 'maxBytes', - /// eventually use up all disk space and stop working. Should be set to true - /// for file systems supporting COW (like brtfs). /// If 'disableFileCow' is true, the cache disables the file COW (copy on /// write) feature if the underlying filesystem (such as brtfs) supports it. /// This prevents the actual cache space usage on disk from exceeding the @@ -76,7 +72,7 @@ class SsdCache { /// have returned true. void write(std::vector pins); - /// Remove cached entries from all SsdFiles for files in the fileNum set + /// Removes cached entries from all SsdFiles for files in the fileNum set /// 'filesToRemove'. If successful, return true, and 'filesRetained' contains /// entries that should not be removed, ex., from pinned regions. Otherwise, /// return false and 'filesRetained' could be ignored. @@ -112,15 +108,15 @@ class SsdCache { private: const std::string filePrefix_; const int32_t numShards_; + // Stats for selecting entries to save from AsyncDataCache. + const std::unique_ptr groupStats_; + folly::Executor* const executor_; + std::vector> files_; // Count of shards with unfinished writes. - std::atomic writesInProgress_{0}; - - // Stats for selecting entries to save from AsyncDataCache. - std::unique_ptr groupStats_; - folly::Executor* executor_; - std::atomic isShutdown_{false}; + std::atomic_int32_t writesInProgress_{0}; + std::atomic_bool isShutdown_{false}; }; } // namespace facebook::velox::cache diff --git a/velox/common/caching/SsdFile.cpp b/velox/common/caching/SsdFile.cpp index e977f610ebe3a..a33b9639dc44d 100644 --- a/velox/common/caching/SsdFile.cpp +++ b/velox/common/caching/SsdFile.cpp @@ -145,7 +145,7 @@ SsdFile::SsdFile( oDirect = FLAGS_ssd_odirect ? O_DIRECT : 0; #endif // linux fd_ = open(fileName_.c_str(), O_CREAT | O_RDWR | oDirect, S_IRUSR | S_IWUSR); - if (FOLLY_UNLIKELY(fd_ < 0)) { + if (fd_ < 0) { ++stats_.openFileErrors; } // TODO: add fault tolerant handling for open file errors. @@ -161,23 +161,20 @@ SsdFile::SsdFile( } readFile_ = std::make_unique(fd_); - uint64_t size = lseek(fd_, 0, SEEK_END); - numRegions_ = size / kRegionSize; - if (numRegions_ > maxRegions_) { - numRegions_ = maxRegions_; - } + const uint64_t size = lseek(fd_, 0, SEEK_END); + numRegions_ = std::min(size / kRegionSize, maxRegions_); fileSize_ = numRegions_ * kRegionSize; - if (size % kRegionSize > 0 || size > numRegions_ * kRegionSize) { - ftruncate(fd_, fileSize_); + if ((size % kRegionSize > 0) || (size > numRegions_ * kRegionSize)) { + ::ftruncate(fd_, fileSize_); } // The existing regions in the file are writable. writableRegions_.resize(numRegions_); std::iota(writableRegions_.begin(), writableRegions_.end(), 0); tracker_.resize(maxRegions_); - regionSizes_.resize(maxRegions_); - erasedRegionSizes_.resize(maxRegions_); - regionPins_.resize(maxRegions_); - if (checkpointIntervalBytes_) { + regionSizes_.resize(maxRegions_, 0); + erasedRegionSizes_.resize(maxRegions_, 0); + regionPins_.resize(maxRegions_, 0); + if (checkpointIntervalBytes_ > 0) { initializeCheckpoint(); } } @@ -338,7 +335,7 @@ bool SsdFile::growOrEvictLocked() { << newSize; } - auto candidates = + const auto candidates = tracker_.findEvictionCandidates(3, numRegions_, regionPins_); if (candidates.empty()) { suspended_ = true; @@ -435,6 +432,7 @@ void SsdFile::write(std::vector& pins) { std::lock_guard l(mutex_); for (auto i = writeIndex; i < writeIndex + numWrittenEntries; ++i) { auto* entry = pins[i].checkedEntry(); + VELOX_CHECK_NULL(entry->ssdFile()); entry->setSsdFile(this, offset); const auto size = entry->size(); FileCacheKey key = { @@ -502,11 +500,9 @@ void SsdFile::verifyWrite(AsyncDataCacheEntry& entry, SsdRun ssdRun) { for (auto i = 0; i < data.numRuns(); ++i) { const auto run = data.runAt(i); const auto compareSize = std::min(bytesLeft, run.numBytes()); - auto badIndex = indexOfFirstMismatch( + const auto badIndex = indexOfFirstMismatch( run.data(), testData.get() + offset, compareSize); - if (badIndex != -1) { - VELOX_FAIL("Bad read back"); - } + VELOX_CHECK_EQ(badIndex, -1, "Bad read back"); bytesLeft -= run.numBytes(); offset += run.numBytes(); if (bytesLeft <= 0) { @@ -605,7 +601,7 @@ bool SsdFile::removeFileEntries( continue; } - entriesAgedOut++; + ++entriesAgedOut; erasedRegionSizes_[region] += ssdRun.size(); it = entries_.erase(it); @@ -613,7 +609,7 @@ bool SsdFile::removeFileEntries( std::vector toFree; toFree.reserve(numRegions_); - for (auto region = 0; region < numRegions_; region++) { + for (auto region = 0; region < numRegions_; ++region) { if (erasedRegionSizes_[region] > regionSizes_[region] * kMaxErasedSizePct / 100) { toFree.push_back(region); @@ -673,7 +669,7 @@ void SsdFile::deleteCheckpoint(bool keepLog) { if ((logRc != 0) || (checkpointRc != 0)) { ++stats_.deleteCheckpointErrors; VELOX_SSD_CACHE_LOG(ERROR) - << "Error in deleting log and checkpoint. log: " << logRc + << "Error in deleting log and checkpoint. log: " << logRc << " checkpoint: " << checkpointRc; } } @@ -721,48 +717,6 @@ void SsdFile::checkpoint(bool force) { return rc; }; - std::ofstream state; - auto checkpointPath = fileName_ + kCheckpointExtension; - state.exceptions(std::ofstream::failbit); - state.open(checkpointPath, std::ios_base::out | std::ios_base::trunc); - // The checkpoint state file contains: - // int32_t The 4 bytes of kCheckpointMagic, - // int32_t maxRegions, - // int32_t numRegions, - // regionScores from the 'tracker_', - // {fileId, fileName} pairs, - // kMapMarker, - // {fileId, offset, SSdRun} triples, - // kEndMarker. - state.write(kCheckpointMagic, sizeof(int32_t)); - state.write(asChar(&maxRegions_), sizeof(maxRegions_)); - state.write(asChar(&numRegions_), sizeof(numRegions_)); - - // Copy the region scores before writing out for tsan. - const auto scoresCopy = tracker_.copyScores(); - state.write(asChar(scoresCopy.data()), maxRegions_ * sizeof(uint64_t)); - std::unordered_set fileNums; - for (const auto& entry : entries_) { - const auto fileNum = entry.first.fileNum.id(); - if (fileNums.insert(fileNum).second) { - state.write(asChar(&fileNum), sizeof(fileNum)); - const auto name = fileIds().string(fileNum); - const int32_t length = name.size(); - state.write(asChar(&length), sizeof(length)); - state.write(name.data(), length); - } - } - - const auto mapMarker = kCheckpointMapMarker; - state.write(asChar(&mapMarker), sizeof(mapMarker)); - for (auto& pair : entries_) { - auto id = pair.first.fileNum.id(); - state.write(asChar(&id), sizeof(id)); - state.write(asChar(&pair.first.offset), sizeof(pair.first.offset)); - auto offsetAndSize = pair.second.bits(); - state.write(asChar(&offsetAndSize), sizeof(offsetAndSize)); - } - // We schedule the potentially long fsync of the cache file on another // thread of the cache write executor, if available. If there is none, we do // the sync on this thread at the end. @@ -772,6 +726,53 @@ void SsdFile::checkpoint(bool force) { executor_->add([fileSync]() { fileSync->prepare(); }); } + std::ofstream state; + const auto checkpointPath = fileName_ + kCheckpointExtension; + try { + state.exceptions(std::ofstream::failbit); + state.open(checkpointPath, std::ios_base::out | std::ios_base::trunc); + // The checkpoint state file contains: + // int32_t The 4 bytes of kCheckpointMagic, + // int32_t maxRegions, + // int32_t numRegions, + // regionScores from the 'tracker_', + // {fileId, fileName} pairs, + // kMapMarker, + // {fileId, offset, SSdRun} triples, + // kEndMarker. + state.write(kCheckpointMagic, sizeof(int32_t)); + state.write(asChar(&maxRegions_), sizeof(maxRegions_)); + state.write(asChar(&numRegions_), sizeof(numRegions_)); + + // Copy the region scores before writing out for tsan. + const auto scoresCopy = tracker_.copyScores(); + state.write(asChar(scoresCopy.data()), maxRegions_ * sizeof(uint64_t)); + std::unordered_set fileNums; + for (const auto& entry : entries_) { + const auto fileNum = entry.first.fileNum.id(); + if (fileNums.insert(fileNum).second) { + state.write(asChar(&fileNum), sizeof(fileNum)); + const auto name = fileIds().string(fileNum); + const int32_t length = name.size(); + state.write(asChar(&length), sizeof(length)); + state.write(name.data(), length); + } + } + + const auto mapMarker = kCheckpointMapMarker; + state.write(asChar(&mapMarker), sizeof(mapMarker)); + for (auto& pair : entries_) { + auto id = pair.first.fileNum.id(); + state.write(asChar(&id), sizeof(id)); + state.write(asChar(&pair.first.offset), sizeof(pair.first.offset)); + auto offsetAndSize = pair.second.bits(); + state.write(asChar(&offsetAndSize), sizeof(offsetAndSize)); + } + } catch (const std::exception& e) { + fileSync->close(); + std::rethrow_exception(std::current_exception()); + } + // NOTE: we need to ensure cache file data sync update completes before // updating checkpoint file. const auto fileSyncRc = fileSync->move(); @@ -820,6 +821,7 @@ void SsdFile::initializeCheckpoint() { if (checkpointIntervalBytes_ == 0) { return; } + bool hasCheckpoint = true; std::ifstream state(fileName_ + kCheckpointExtension); if (!state.is_open()) { @@ -889,7 +891,7 @@ T readNumber(std::ifstream& stream) { void SsdFile::readCheckpoint(std::ifstream& state) { char magic[4]; state.read(magic, sizeof(magic)); - VELOX_CHECK_EQ(strncmp(magic, kCheckpointMagic, 4), 0); + VELOX_CHECK_EQ(::strncmp(magic, kCheckpointMagic, 4), 0); const auto maxRegions = readNumber(state); VELOX_CHECK_EQ( maxRegions, @@ -900,7 +902,7 @@ void SsdFile::readCheckpoint(std::ifstream& state) { state.read(asChar(scores.data()), maxRegions_ * sizeof(uint64_t)); std::unordered_map idMap; for (;;) { - auto id = readNumber(state); + const auto id = readNumber(state); if (id == kCheckpointMapMarker) { break; } diff --git a/velox/common/caching/SsdFile.h b/velox/common/caching/SsdFile.h index 9b027cf9cb604..4f288fad249df 100644 --- a/velox/common/caching/SsdFile.h +++ b/velox/common/caching/SsdFile.h @@ -27,9 +27,8 @@ DECLARE_bool(ssd_verify_write); namespace facebook::velox::cache { -// A 64 bit word describing a SSD cache entry in an SsdFile. The low -// 23 bits are the size, for a maximum entry size of 8MB. The high -// bits are the offset. +/// A 64 bit word describing a SSD cache entry in an SsdFile. The low 23 bits +/// are the size, for a maximum entry size of 8MB. The high bits are the offset. class SsdRun { public: static constexpr int32_t kSizeBits = 23; @@ -39,7 +38,8 @@ class SsdRun { SsdRun(uint64_t offset, uint32_t size) : bits_((offset << kSizeBits) | ((size - 1))) { VELOX_CHECK_LT(offset, 1L << (64 - kSizeBits)); - VELOX_CHECK_LT(size - 1, 1 << kSizeBits); + VELOX_CHECK_NE(size, 0); + VELOX_CHECK_LE(size, 1 << kSizeBits); } SsdRun(uint64_t bits) : bits_(bits) {} @@ -71,16 +71,16 @@ class SsdRun { uint64_t bits_; }; -// Represents an SsdFile entry that is planned for load or being -// loaded. This is destroyed after load. Destruction decrements the -// pin count of the corresponding region of 'file_'. While there are -// pins, the region cannot be evicted. +/// Represents an SsdFile entry that is planned for load or being loaded. This +/// is destroyed after load. Destruction decrements the pin count of the +/// corresponding region of 'file_'. While there are pins, the region cannot be +/// evicted. class SsdPin { public: SsdPin() : file_(nullptr) {} - // Constructs a pin referencing 'run' in 'file'. The region must be - // pinned before constructing the pin. + /// Constructs a pin referencing 'run' in 'file'. The region must be pinned + /// before constructing the pin. SsdPin(SsdFile& file, SsdRun run); SsdPin(const SsdPin& other) = delete; @@ -177,20 +177,18 @@ struct SsdCacheStats { tsan_atomic readCheckpointErrors{0}; }; -// A shard of SsdCache. Corresponds to one file on SSD. The data -// backed by each SsdFile is selected on a hash of the storage file -// number of the cached data. Each file consists of an integer number -// of 64MB regions. Each region has a pin count and an read -// count. Cache replacement takes place region by region, preferring -// regions with a smaller read count. Entries do not span -// regions. Otherwise entries are consecutive byte ranges inside -// their region. +/// A shard of SsdCache. Corresponds to one file on SSD. The data backed by each +/// SsdFile is selected on a hash of the storage file number of the cached data. +/// Each file consists of an integer number of 64MB regions. Each region has a +/// pin count and an read count. Cache replacement takes place region by region, +/// preferring regions with a smaller read count. Entries do not span regions. +/// Otherwise entries are consecutive byte ranges inside their region. class SsdFile { public: static constexpr uint64_t kRegionSize = 1 << 26; // 64MB - // Constructs a cache backed by filename. Discards any previous - // contents of filename. + /// Constructs a cache backed by filename. Discards any previous contents of + /// filename. SsdFile( const std::string& filename, int32_t shardId, @@ -199,12 +197,12 @@ class SsdFile { bool disableFileCow = false, folly::Executor* executor = nullptr); - // Adds entries of 'pins' to this file. 'pins' must be in read mode and - // those pins that are successfully added to SSD are marked as being on SSD. - // The file of the entries must be a file that is backed by 'this'. + /// Adds entries of 'pins' to this file. 'pins' must be in read mode and + /// those pins that are successfully added to SSD are marked as being on SSD. + /// The file of the entries must be a file that is backed by 'this'. void write(std::vector& pins); - // Finds an entry for 'key'. If no entry is found, the returned pin is empty. + /// Finds an entry for 'key'. If no entry is found, the returned pin is empty. SsdPin find(RawFileCacheKey key); // Erases 'key' @@ -216,21 +214,21 @@ class SsdFile { const std::vector& ssdPins, const std::vector& pins); - // Increments the pin count of the region of 'offset'. + /// Increments the pin count of the region of 'offset'. void pinRegion(uint64_t offset); // Decrements the pin count of the region of 'offset'. If the pin count goes // to zero and evict is due, starts the eviction. void unpinRegion(uint64_t offset); - // Asserts that the region of 'offset' is pinned. This is called by - // the pin holder. The pin count can be read without mutex. + /// Asserts that the region of 'offset' is pinned. This is called by the pin + /// holder. The pin count can be read without mutex. void checkPinned(uint64_t offset) const { tsan_lock_guard l(mutex_); VELOX_CHECK_GT(regionPins_[regionIndex(offset)], 0); } - // Returns the region number corresponding to offset. + /// Returns the region number corresponding to offset. static int32_t regionIndex(uint64_t offset) { return offset / kRegionSize; } @@ -251,7 +249,7 @@ class SsdFile { // Adds 'stats_' to 'stats'. void updateStats(SsdCacheStats& stats) const; - // Resets this' to a post-construction empty state. See SsdCache::clear(). + /// Resets this' to a post-construction empty state. See SsdCache::clear(). void clear(); // Deletes the backing file. Used in testing. @@ -323,9 +321,9 @@ class SsdFile { // eviction log and leaves this open. void deleteCheckpoint(bool keepLog = false); - // Reads a checkpoint state file and sets 'this' accordingly if read - // is successful. Return true for successful read. A failed read - // deletes the checkpoint and leaves the log truncated open. + // Reads a checkpoint state file and sets 'this' accordingly if read is + // successful. Return true for successful read. A failed read deletes the + // checkpoint and leaves the log truncated open. void readCheckpoint(std::ifstream& state); // Logs an error message, deletes the checkpoint and stop making new @@ -344,8 +342,8 @@ class SsdFile { bool write(uint64_t offset, uint64_t length, const std::vector& iovecs); - // Synchronously logs that 'regions' are no longer valid in a possibly xisting - // checkpoint. + // Synchronously logs that 'regions' are no longer valid in a possibly + // existing checkpoint. void logEviction(const std::vector& regions); static constexpr const char* kLogExtension = ".log"; @@ -375,7 +373,7 @@ class SsdFile { bool suspended_{false}; // Number of used bytes in each region. A new entry must fit between the - // offset and the end of the region. This is subscripted with the region + // offset and the end of the region. This is sub-scripted with the region // index. The regionIndex times kRegionSize is an offset into the file. std::vector regionSizes_; @@ -405,9 +403,8 @@ class SsdFile { // Counters. SsdCacheStats stats_; - // Checkpoint after every 'checkpointIntervalBytes_' written into - // this file. 0 means no checkpointing. This is set to 0 if - // checkpointing fails. + // Checkpoint after every 'checkpointIntervalBytes_' written into this file. 0 + // means no checkpointing. This is set to 0 if checkpointing fails. int64_t checkpointIntervalBytes_{0}; // Executor for async fsync in checkpoint. diff --git a/velox/common/caching/SsdFileTracker.cpp b/velox/common/caching/SsdFileTracker.cpp index 32e3c307e352b..9250c72b550f7 100644 --- a/velox/common/caching/SsdFileTracker.cpp +++ b/velox/common/caching/SsdFileTracker.cpp @@ -39,9 +39,9 @@ std::vector SsdFileTracker::findEvictionCandidates( int32_t numCandidates, int32_t numRegions, const std::vector& regionPins) { - // Calculates average score of regions wiht no pins. Returns up to - // 'numCandidates' unpinned regions with score <= average, lowest - // scoring region first. + // Calculates average score of regions with no pins. Returns up to + // 'numCandidates' unpinned regions with score <= average, lowest scoring + // region first. int64_t scoreSum = 0; int32_t numUnpinned = 0; for (int i = 0; i < numRegions; ++i) { diff --git a/velox/common/caching/SsdFileTracker.h b/velox/common/caching/SsdFileTracker.h index e8dd2154fea78..331d2269222ad 100644 --- a/velox/common/caching/SsdFileTracker.h +++ b/velox/common/caching/SsdFileTracker.h @@ -24,9 +24,9 @@ namespace facebook::velox::cache { -// Tracks reads on an SsdFile. Reads are counted for fixed size regions and -// periodically decayed. Not thread safe, synchronization is the caller's -// responsibility. +/// Tracks reads on an SsdFile. Reads are counted for fixed size regions and +/// periodically decayed. Not thread safe, synchronization is the caller's +/// responsibility. class SsdFileTracker { public: void resize(int32_t numRegions) { @@ -42,9 +42,9 @@ class SsdFileTracker { } // Marks that a region has been filled and transits from writable to - // evictable. Set its score to be at least the best score + - // a small margin so that it gets time to live. Otherwise it has had - // the least time to get hits and would be the first evicted. + // evictable. Set its score to be at least the best score + a small margin so + // that it gets time to live. Otherwise, it has had the least time to get hits + // and would be the first evicted. void regionFilled(int32_t region); // Increments event count and periodically decays @@ -52,10 +52,10 @@ class SsdFileTracker { // tracked file. void fileTouched(int32_t totalEntries); - // Returns up to 'numCandidates' least used regions. 'numRegions' is - // the count of existing regions. This can be less than the size of - // the tracker if the file cannot grow to full size. Regions with a - // non-zero count in 'regionPins' are not considered. + /// Returns up to 'numCandidates' least used regions. 'numRegions' is the + /// count of existing regions. This can be less than the size of the tracker + /// if the file cannot grow to full size. Regions with a non-zero count in + /// 'regionPins' are not considered. std::vector findEvictionCandidates( int32_t numCandidates, int32_t numRegions, diff --git a/velox/common/caching/tests/AsyncDataCacheTest.cpp b/velox/common/caching/tests/AsyncDataCacheTest.cpp index 29071ab08a8ab..82263c188f073 100644 --- a/velox/common/caching/tests/AsyncDataCacheTest.cpp +++ b/velox/common/caching/tests/AsyncDataCacheTest.cpp @@ -896,7 +896,7 @@ TEST_F(AsyncDataCacheTest, cacheStats) { "[size 128: 0(0MB) allocated 0 mapped]\n" "[size 256: 0(0MB) allocated 0 mapped]\n" "]\n" - "SSD: Ssd cache IO: Write 0MB read 0MB Size 0GB Occupied 0GB0K entries.\n" + "SSD: Ssd cache IO: Write 0B read 0B Size 512.00MB Occupied 0B 0K entries.\n" "GroupStats: "; ASSERT_EQ(cache_->toString(), expectedDetailedCacheOutput); ASSERT_EQ(cache_->toString(true), expectedDetailedCacheOutput);