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

Function Madvise

util/system/madvise.cpp:24–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23namespace {
24 void Madvise(int flag, const void* cbegin, size_t size) {
25 static const size_t pageSize = NSystemInfo::GetPageSize();
26 void* begin = AlignDown(const_cast<void*>(cbegin), pageSize);
27 size = AlignUp(size, pageSize);
28
29#if defined(_win_)
30 if (!VirtualFree((LPVOID)begin, size, flag)) {
31 TString err(LastSystemErrorText());
32 ythrow yexception() << "VirtualFree(" << begin << ", " << size << ", " << flag << ")"
33 << " returned error: " << err;
34 }
35#else
36 if (-1 == madvise(begin, size, flag)) {
37 TString err(LastSystemErrorText());
38 ythrow yexception() << "madvise(" << begin << ", " << size << ", " << flag << ")"
39 << " returned error: " << err;
40 }
41#endif
42 }
43} // namespace
44
45void MadviseSequentialAccess(const void* begin, size_t size) {

Callers 5

MadviseSequentialAccessFunction · 0.85
MadviseRandomAccessFunction · 0.85
MadviseEvictFunction · 0.85

Calls 4

AlignDownFunction · 0.70
AlignUpFunction · 0.70
LastSystemErrorTextFunction · 0.70
GetPageSizeFunction · 0.50

Tested by

no test coverage detected