MCPcopy Create free account
hub / github.com/catboost/catboost / PrefetchCache

Method PrefetchCache

util/system/file.cpp:782–804  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

780}
781
782void TFileHandle::PrefetchCache(i64 offset, i64 length, bool wait) const noexcept {
783#ifdef _linux_
784 #if HAVE_POSIX_FADVISE
785 // POSIX_FADV_WILLNEED starts reading upto read_ahead_kb in background
786 ::posix_fadvise(Fd_, offset, length, POSIX_FADV_WILLNEED);
787 #endif
788
789 if (wait) {
790 TFileHandle devnull("/dev/null", OpenExisting | WrOnly | CloseOnExec);
791 off_t end = length ? (offset + length) : GetLength();
792 off_t pos = offset;
793 ssize_t ret;
794
795 do {
796 ret = ::sendfile((FHANDLE)devnull, Fd_, &pos, end - pos);
797 } while (pos < end && (ret > 0 || errno == EINTR));
798 }
799#else
800 Y_UNUSED(offset);
801 Y_UNUSED(length);
802 Y_UNUSED(wait);
803#endif
804}
805
806void TFileHandle::EvictCache(i64 offset, i64 length) const noexcept {
807#if HAVE_POSIX_FADVISE

Callers 2

PrefetchCacheMethod · 0.45
TestCacheMethod · 0.45

Calls 2

Y_UNUSEDFunction · 0.85
GetLengthFunction · 0.50

Tested by 1

TestCacheMethod · 0.36