proxygen
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
HugePageUtil.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2012-present Facebook, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#include <iostream>
18
#include <stdexcept>
19
20
#include <
folly/Format.h
>
21
#include <
folly/Range.h
>
22
#include <
folly/experimental/io/HugePages.h
>
23
#include <
folly/portability/GFlags.h
>
24
#include <
folly/system/MemoryMapping.h
>
25
26
DEFINE_bool
(cp,
false
,
"Copy file"
);
27
28
using namespace
folly
;
29
30
namespace
{
31
32
[[noreturn]]
void
usage(
const
char
*
name
) {
33
std::cerr <<
folly::format
(
34
"Usage: {0}\n"
35
" list all huge page sizes and their mount points\n"
36
" {0} -cp <src_file> <dest_nameprefix>\n"
37
" copy src_file to a huge page file\n"
,
38
name);
39
exit(1);
40
}
41
42
void
copy
(
const
char
* srcFile,
const
char
*
dest
) {
43
fs::path destPath(dest);
44
if
(!destPath.is_absolute()) {
45
auto
hp =
getHugePageSize
();
46
CHECK(hp) <<
"no huge pages available"
;
47
destPath =
fs::canonical_parent
(destPath, hp->mountPoint);
48
}
49
50
mmapFileCopy
(srcFile, destPath.c_str());
51
}
52
53
void
list
() {
54
for
(
const
auto
& p :
getHugePageSizes
()) {
55
std::cout << p.size <<
" "
<< p.mountPoint <<
"\n"
;
56
}
57
}
58
59
}
// namespace
60
61
int
main
(
int
argc,
char
*
argv
[]) {
62
gflags::ParseCommandLineFlags(&argc, &argv,
true
);
63
if
(FLAGS_cp) {
64
if
(argc != 3) {
65
usage(argv[0]);
66
}
67
copy
(argv[1], argv[2]);
68
}
else
{
69
if
(argc != 1) {
70
usage(argv[0]);
71
}
72
list
();
73
}
74
return
0;
75
}
folly::getHugePageSizes
const HugePageSizeVec & getHugePageSizes()
Definition:
HugePages.cpp:201
MemoryMapping.h
upload.dest
dest
Definition:
upload.py:394
folly
—— Concurrent Priority Queue Implementation ——
Definition:
AtomicBitSet.h:29
folly::getHugePageSize
const HugePageSize * getHugePageSize(size_t size)
Definition:
HugePages.cpp:206
Range.h
name
const char * name
Definition:
http_parser.c:437
folly::copy
constexpr std::decay< T >::type copy(T &&value) noexcept(noexcept(typename std::decay< T >::type(std::forward< T >(value))))
Definition:
Utility.h:72
argv
char ** argv
Definition:
SmallLocksBenchmark.cpp:430
bm::list
Encoder::MutableCompressedList list
Definition:
BitVectorCodingTest.cpp:78
main
int main(int argc, char *argv[])
Definition:
HugePageUtil.cpp:61
Format.h
HugePages.h
DEFINE_bool
DEFINE_bool(cp, false,"Copy file")
folly::format
Formatter< false, Args... > format(StringPiece fmt, Args &&...args)
Definition:
Format.h:271
GFlags.h
folly::mmapFileCopy
void mmapFileCopy(const char *src, const char *dest, mode_t mode)
Definition:
MemoryMapping.cpp:411
folly::fs::canonical_parent
path canonical_parent(const path &pth, const path &base)
Definition:
FsUtil.cpp:68
proxygen
folly
folly
experimental
io
HugePageUtil.cpp
Generated by
1.8.11