sapling/eden/fs/benchmarks/stat.cpp
Chad Austin d0fb86a240 add 4k random writes benchmark
Summary:
To help investigate a Linux kernel performance dropoff where the
kernel falsely thinks the EdenFS FUSE mount can't handle dirty page
writes at a high rate, add a 4k random writes benchmark.

Reviewed By: simpkins

Differential Revision: D21328771

fbshipit-source-id: c9977bd2e291d01e92631094aba3d8d807ec62da
2020-07-14 16:13:37 -07:00

35 lines
771 B
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#include <folly/Exception.h>
#include <folly/File.h>
#include <gflags/gflags.h>
#include "eden/fs/benchharness/Bench.h"
namespace {
DEFINE_string(
filename,
"stat.tmp",
"Path which should be opened and repeatedly stat'd");
void call_fstat(benchmark::State& state) {
folly::File file{FLAGS_filename, O_CREAT | O_RDONLY | O_CLOEXEC};
struct stat buf;
for (auto _ : state) {
folly::checkUnixError(::fstat(file.fd(), &buf), "fstat failed");
}
folly::checkUnixError(::unlink(FLAGS_filename.c_str()));
}
BENCHMARK(call_fstat);
} // namespace
EDEN_BENCHMARK_MAIN();