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

Method TAlignmentCalcer

util/system/direct_io.cpp:16–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14namespace {
15 struct TAlignmentCalcer {
16 inline TAlignmentCalcer()
17 : Alignment(0)
18 {
19#ifdef _linux_
20 utsname sysInfo;
21
22 Y_ABORT_UNLESS(!uname(&sysInfo), "Error while call uname: %s", LastSystemErrorText());
23
24 TStringBuf release(sysInfo.release);
25 release = release.substr(0, release.find_first_not_of(".0123456789"));
26
27 int v1 = FromString<int>(release.NextTok('.'));
28 int v2 = FromString<int>(release.NextTok('.'));
29 int v3 = FromString<int>(release.NextTok('.'));
30 int linuxVersionCode = KERNEL_VERSION(v1, v2, v3);
31
32 if (linuxVersionCode < KERNEL_VERSION(2, 4, 10)) {
33 Alignment = 0;
34 } else if (linuxVersionCode < KERNEL_VERSION(2, 6, 0)) {
35 Alignment = NSystemInfo::GetPageSize();
36 } else {
37 // Default alignment used to be 512, but most modern devices rely on 4k physical blocks.
38 // 4k alignment works well for both 512 and 4k blocks and doesn't require 512e support in the kernel.
39 // See IGNIETFERRO-946.
40 Alignment = 4096;
41 }
42#endif
43 }
44
45 size_t Alignment;
46 };

Callers

nothing calls this directly

Calls 5

LastSystemErrorTextFunction · 0.70
GetPageSizeFunction · 0.50
substrMethod · 0.45
find_first_not_ofMethod · 0.45
NextTokMethod · 0.45

Tested by

no test coverage detected