diff options
author | Fabricio Voznika <fvoznika@google.com> | 2021-04-20 11:47:28 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-04-20 11:48:48 -0700 |
commit | bf1e14cf8a24100fd12292a87e4fc3a439399669 (patch) | |
tree | 27fb92b2f070da4efd4ae0b455cf2091ccee8b07 /test/perf/linux | |
parent | 3fff4c4a0fbb1b132348d4b82f61cc38a4cc6cb2 (diff) |
Speed up O_APPEND with remote revalidating
Remote revalidating requires to update file size on every write
on a file opened with O_APPEND. If host FD exists, it can be
used to update the size and skip round trip to the gofer. With
this change, O_APPEND writes with remote revalidating is almost
as fast as exclusive mode:
BM_Append
VFS1 60.7us
VFS2 56.8us
VFS2 exclusive 14.2us
This change 15.8us
Updates #1792
PiperOrigin-RevId: 369486801
Diffstat (limited to 'test/perf/linux')
-rw-r--r-- | test/perf/linux/write_benchmark.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/perf/linux/write_benchmark.cc b/test/perf/linux/write_benchmark.cc index 7b060c70e..d495f3ddc 100644 --- a/test/perf/linux/write_benchmark.cc +++ b/test/perf/linux/write_benchmark.cc @@ -46,6 +46,18 @@ void BM_Write(benchmark::State& state) { BENCHMARK(BM_Write)->Range(1, 1 << 26)->UseRealTime(); +void BM_Append(benchmark::State& state) { + auto file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile()); + auto fd = ASSERT_NO_ERRNO_AND_VALUE(Open(file.path(), O_WRONLY | O_APPEND)); + + const char data = 'a'; + for (auto _ : state) { + TEST_CHECK(WriteFd(fd.get(), &data, 1) == 1); + } +} + +BENCHMARK(BM_Append); + } // namespace } // namespace testing |