MCPcopy Create free account
hub / github.com/bytedance/bolt / checkEvictionBlocked

Method checkEvictionBlocked

bolt/common/caching/tests/SsdFileTest.cpp:198–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196 }
197
198 void checkEvictionBlocked(
199 std::vector<TestEntry>& allEntries,
200 uint64_t ssdSize) {
201 auto ssdPins = pinAllRegions(allEntries);
202 auto pins = makePins(fileName_.id(), ssdSize, 4096, 2048 * 1025, 62 * kMB);
203 ssdFile_->write(pins);
204 // Only Some pins get written because space cannot be cleared
205 // because all regions are pinned. The file will not give out new
206 // pins so that this situation is not continued
207 EXPECT_TRUE(
208 ssdFile_->find(RawFileCacheKey{fileName_.id(), ssdSize}).empty());
209 int32_t numWritten = 0;
210 for (auto& pin : pins) {
211 if (pin.entry()->ssdFile()) {
212 ++numWritten;
213 allEntries.emplace_back(
214 pin.entry()->key(), pin.entry()->ssdOffset(), pin.entry()->size());
215 }
216 }
217 EXPECT_LT(numWritten, pins.size());
218 // vector::clear() does not guarantee the release order; we need to clear
219 // the pins in the correct order explicitly.
220 for (auto& pin : ssdPins) {
221 pin.clear();
222 }
223 ssdPins.clear();
224
225 // The pins were cleared and the file is no longer suspended. Check that the
226 // entry that was not found is found now.
227 EXPECT_FALSE(
228 ssdFile_->find(RawFileCacheKey{fileName_.id(), ssdSize}).empty());
229
230 pins.erase(pins.begin(), pins.begin() + numWritten);
231 ssdFile_->write(pins);
232 for (auto& pin : pins) {
233 if (pin.entry()->ssdFile()) {
234 allEntries.emplace_back(
235 pin.entry()->key(), pin.entry()->ssdOffset(), pin.entry()->size());
236 }
237 }
238 // Clear the pins and read back. Clear must complete before
239 // makePins so that there are no pre-existing exclusive pins for the same
240 // key.
241 pins.clear();
242 pins = makePins(fileName_.id(), ssdSize, 4096, 2048 * 1025, 62 * kMB);
243 readAndCheckPins(pins);
244 }
245
246 std::shared_ptr<exec::test::TempDirectoryPath> tempDirectory_;
247

Callers

nothing calls this directly

Calls 12

ssdFileMethod · 0.80
entryMethod · 0.80
keyMethod · 0.80
ssdOffsetMethod · 0.80
idMethod · 0.45
writeMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected