Merge "Minor benchmark fixes." into main am: 41cc7be55a

Original change: https://android-review.googlesource.com/c/platform/bionic/+/3003517

Change-Id: I6b88fafe267becff4c2b3486f9ce58511d5f0268
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Christopher Ferris 2024-03-14 03:59:28 +00:00 committed by Automerger Merge Worker
commit cf54c528f3
3 changed files with 81 additions and 81 deletions

View file

@ -523,39 +523,39 @@ std::map<std::string, args_vector_t> GetShorthand() {
int page_sz = getpagesize();
std::vector<int> sub_page_sizes = {page_sz / 2, page_sz / 4, page_sz / 8};
std::vector<int> multi_page_sizes = {page_sz, page_sz * 2, page_sz * 3, page_sz * 10,
page_sz * 100};
std::vector<int> multi_page_sizes = {page_sz, page_sz * 2, page_sz * 3, page_sz * 10,
page_sz * 25, page_sz * 50, page_sz * 75, page_sz * 100};
std::vector<int> all_page_sizes(sub_page_sizes);
all_page_sizes.insert(all_page_sizes.end(), multi_page_sizes.begin(), multi_page_sizes.end());
std::map<std::string, args_vector_t> args_shorthand {
{"AT_COMMON_SIZES", GetArgs(kCommonSizes)},
{"AT_SMALL_SIZES", GetArgs(kSmallSizes)},
{"AT_MEDIUM_SIZES", GetArgs(kMediumSizes)},
{"AT_LARGE_SIZES", GetArgs(kLargeSizes)},
{"AT_ALL_SIZES", GetArgs(all_sizes)},
{"AT_SUB_PAGE_SIZES", GetArgs(sub_page_sizes)},
{"AT_MULTI_PAGE_SIZES", GetArgs(multi_page_sizes)},
{"AT_All_PAGE_SIZES", GetArgs(all_page_sizes)},
std::map<std::string, args_vector_t> args_shorthand{
{"AT_COMMON_SIZES", GetArgs(kCommonSizes)},
{"AT_SMALL_SIZES", GetArgs(kSmallSizes)},
{"AT_MEDIUM_SIZES", GetArgs(kMediumSizes)},
{"AT_LARGE_SIZES", GetArgs(kLargeSizes)},
{"AT_ALL_SIZES", GetArgs(all_sizes)},
{"AT_SUB_PAGE_SIZES", GetArgs(sub_page_sizes)},
{"AT_MULTI_PAGE_SIZES", GetArgs(multi_page_sizes)},
{"AT_ALL_PAGE_SIZES", GetArgs(all_page_sizes)},
{"AT_ALIGNED_ONEBUF", GetArgs(kCommonSizes, 0)},
{"AT_ALIGNED_ONEBUF_SMALL", GetArgs(kSmallSizes, 0)},
{"AT_ALIGNED_ONEBUF_MEDIUM", GetArgs(kMediumSizes, 0)},
{"AT_ALIGNED_ONEBUF_LARGE", GetArgs(kLargeSizes, 0)},
{"AT_ALIGNED_ONEBUF_ALL", GetArgs(all_sizes, 0)},
{"AT_ALIGNED_ONEBUF", GetArgs(kCommonSizes, 0)},
{"AT_ALIGNED_ONEBUF_SMALL", GetArgs(kSmallSizes, 0)},
{"AT_ALIGNED_ONEBUF_MEDIUM", GetArgs(kMediumSizes, 0)},
{"AT_ALIGNED_ONEBUF_LARGE", GetArgs(kLargeSizes, 0)},
{"AT_ALIGNED_ONEBUF_ALL", GetArgs(all_sizes, 0)},
{"AT_ALIGNED_TWOBUF", GetArgs(kCommonSizes, 0, 0)},
{"AT_ALIGNED_TWOBUF_SMALL", GetArgs(kSmallSizes, 0, 0)},
{"AT_ALIGNED_TWOBUF_MEDIUM", GetArgs(kMediumSizes, 0, 0)},
{"AT_ALIGNED_TWOBUF_LARGE", GetArgs(kLargeSizes, 0, 0)},
{"AT_ALIGNED_TWOBUF_ALL", GetArgs(all_sizes, 0, 0)},
{"AT_ALIGNED_TWOBUF", GetArgs(kCommonSizes, 0, 0)},
{"AT_ALIGNED_TWOBUF_SMALL", GetArgs(kSmallSizes, 0, 0)},
{"AT_ALIGNED_TWOBUF_MEDIUM", GetArgs(kMediumSizes, 0, 0)},
{"AT_ALIGNED_TWOBUF_LARGE", GetArgs(kLargeSizes, 0, 0)},
{"AT_ALIGNED_TWOBUF_ALL", GetArgs(all_sizes, 0, 0)},
// Do not exceed 512. that is about the largest number of properties
// that can be created with the current property area size.
{"NUM_PROPS", args_vector_t{ {1}, {4}, {16}, {64}, {128}, {256}, {512} }},
// Do not exceed 512. that is about the largest number of properties
// that can be created with the current property area size.
{"NUM_PROPS", args_vector_t{{1}, {4}, {16}, {64}, {128}, {256}, {512}}},
{"MATH_COMMON", args_vector_t{ {0}, {1}, {2}, {3} }},
{"MATH_SINCOS_COMMON", args_vector_t{ {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7} }},
{"MATH_COMMON", args_vector_t{{0}, {1}, {2}, {3}}},
{"MATH_SINCOS_COMMON", args_vector_t{{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}}},
};
args_vector_t args_onebuf;

View file

@ -2,42 +2,42 @@
<fn>
<name>BM_syscall_mmap_anon_rw</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_anon_noreserve</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_anon_none</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_anon_rw_fixed</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_anon_none_fixed</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_file_rd_priv</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_file_rw_shared</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_file_rw_priv_fixed_start</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_file_rw_priv_fixed_mid</name>
@ -81,40 +81,40 @@
<fn>
<name>BM_syscall_mmap_anon_mprotect_rw_to_rd</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_anon_mprotect_rw_to_none</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_anon_mprotect_rd_to_none</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_file_mprotect_rw_to_rd</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_file_mprotect_rw_to_none</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_file_mprotect_none_to_rw</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_file_mprotect_none_to_rd</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>
<fn>
<name>BM_syscall_mmap_file_mprotect_rd_to_none</name>
<iterations>10</iterations>
<args>AT_All_PAGE_SIZES</args>
<args>AT_ALL_PAGE_SIZES</args>
</fn>

View file

@ -39,8 +39,8 @@ struct MmapParams {
};
struct MprotectParams {
int from_prot;
int to_prot;
int initial_prot;
int mprotect_prot;
int64_t size;
};
@ -134,7 +134,7 @@ static void BM_syscall_mmap_anon_rw(benchmark::State& state) {
MmapBenchmark(state, params, 0);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_rw, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_rw, "AT_ALL_PAGE_SIZES");
static void BM_syscall_mmap_anon_noreserve(benchmark::State& state) {
struct MmapParams params = {
@ -145,7 +145,7 @@ static void BM_syscall_mmap_anon_noreserve(benchmark::State& state) {
MmapBenchmark(state, params, 0);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_noreserve, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_noreserve, "AT_ALL_PAGE_SIZES");
static void BM_syscall_mmap_anon_none(benchmark::State& state) {
struct MmapParams params = {
@ -156,7 +156,7 @@ static void BM_syscall_mmap_anon_none(benchmark::State& state) {
MmapBenchmark(state, params, 0);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_none, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_none, "AT_ALL_PAGE_SIZES");
// anon fixed mmap
static void BM_syscall_mmap_anon_rw_fixed(benchmark::State& state) {
@ -168,7 +168,7 @@ static void BM_syscall_mmap_anon_rw_fixed(benchmark::State& state) {
MmapFixedBenchmark(state, params, -1, params.size, 0);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_rw_fixed, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_rw_fixed, "AT_ALL_PAGE_SIZES");
static void BM_syscall_mmap_anon_none_fixed(benchmark::State& state) {
struct MmapParams params = {
@ -179,7 +179,7 @@ static void BM_syscall_mmap_anon_none_fixed(benchmark::State& state) {
MmapFixedBenchmark(state, params, -1, params.size, 0);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_none_fixed, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_none_fixed, "AT_ALL_PAGE_SIZES");
// file mmap
static void BM_syscall_mmap_file_rd_priv(benchmark::State& state) {
@ -191,7 +191,7 @@ static void BM_syscall_mmap_file_rd_priv(benchmark::State& state) {
MmapFileBenchmark(state, params, params.size, 0);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_rd_priv, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_rd_priv, "AT_ALL_PAGE_SIZES");
static void BM_syscall_mmap_file_rw_shared(benchmark::State& state) {
struct MmapParams params = {
@ -202,7 +202,7 @@ static void BM_syscall_mmap_file_rw_shared(benchmark::State& state) {
MmapFileBenchmark(state, params, params.size, 0);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_rw_shared, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_rw_shared, "AT_ALL_PAGE_SIZES");
// file fixed mmap
static void BM_syscall_mmap_file_rw_priv_fixed_start(benchmark::State& state) {
@ -215,7 +215,7 @@ static void BM_syscall_mmap_file_rw_priv_fixed_start(benchmark::State& state) {
// allocate 3x area and map at the start
MmapFileBenchmark(state, params, params.size * 3, 0);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_rw_priv_fixed_start, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_rw_priv_fixed_start, "AT_ALL_PAGE_SIZES");
static void BM_syscall_mmap_file_rw_priv_fixed_mid(benchmark::State& state) {
struct MmapParams params = {
@ -321,19 +321,19 @@ void MprotectBenchmark(benchmark::State& state, const struct MprotectParams& par
* Guarantee that physical memory pages are allocated for this region to prevent
* segmentation fault when using mprotect to change permissions.
*/
if (params.from_prot & PROT_WRITE) {
if (params.initial_prot & PROT_WRITE) {
MakeAllocationResident(addr, params.size, page_sz);
}
state.ResumeTiming();
if (mprotect(addr, params.size, params.to_prot) != 0) {
if (mprotect(addr, params.size, params.mprotect_prot) != 0) {
state.SkipWithError(android::base::StringPrintf("mprotect failed: %m"));
break;
}
state.PauseTiming();
// Revert back to the original protection
int res = mprotect(addr, params.size, params.from_prot);
int res = mprotect(addr, params.size, params.initial_prot);
state.ResumeTiming();
if (res != 0) {
state.SkipWithError(
@ -345,7 +345,7 @@ void MprotectBenchmark(benchmark::State& state, const struct MprotectParams& par
static void MprotectBenchmarkWithMmapAnon(benchmark::State& state,
const struct MprotectParams& params) {
void* addr = mmap(nullptr, params.size, params.from_prot, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
void* addr = mmap(nullptr, params.size, params.initial_prot, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
if (addr == MAP_FAILED) {
state.SkipWithError(android::base::StringPrintf("mmap failed: %m"));
return;
@ -359,33 +359,33 @@ static void MprotectBenchmarkWithMmapAnon(benchmark::State& state,
static void BM_syscall_mmap_anon_mprotect_rw_to_rd(benchmark::State& state) {
struct MprotectParams params = {
.from_prot = PROT_READ | PROT_WRITE,
.to_prot = PROT_READ,
.initial_prot = PROT_READ | PROT_WRITE,
.mprotect_prot = PROT_READ,
.size = state.range(0),
};
MprotectBenchmarkWithMmapAnon(state, params);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_mprotect_rw_to_rd, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_mprotect_rw_to_rd, "AT_ALL_PAGE_SIZES");
static void BM_syscall_mmap_anon_mprotect_rw_to_none(benchmark::State& state) {
struct MprotectParams params = {
.from_prot = PROT_READ | PROT_WRITE,
.to_prot = PROT_NONE,
.initial_prot = PROT_READ | PROT_WRITE,
.mprotect_prot = PROT_NONE,
.size = state.range(0),
};
MprotectBenchmarkWithMmapAnon(state, params);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_mprotect_rw_to_none, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_mprotect_rw_to_none, "AT_ALL_PAGE_SIZES");
static void BM_syscall_mmap_anon_mprotect_rd_to_none(benchmark::State& state) {
struct MprotectParams params = {
.from_prot = PROT_READ,
.to_prot = PROT_NONE,
.initial_prot = PROT_READ,
.mprotect_prot = PROT_NONE,
.size = state.range(0),
};
MprotectBenchmarkWithMmapAnon(state, params);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_mprotect_rd_to_none, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_anon_mprotect_rd_to_none, "AT_ALL_PAGE_SIZES");
static void MprotectBenchmarkWithMmapFile(benchmark::State& state,
const struct MprotectParams& params) {
@ -401,7 +401,7 @@ static void MprotectBenchmarkWithMmapFile(benchmark::State& state,
return;
}
void* addr = mmap(nullptr, params.size, params.from_prot, MAP_PRIVATE, tf.fd, 0);
void* addr = mmap(nullptr, params.size, params.initial_prot, MAP_PRIVATE, tf.fd, 0);
if (addr == MAP_FAILED) {
state.SkipWithError(android::base::StringPrintf("mmap failed: %m"));
return;
@ -415,50 +415,50 @@ static void MprotectBenchmarkWithMmapFile(benchmark::State& state,
static void BM_syscall_mmap_file_mprotect_rw_to_rd(benchmark::State& state) {
struct MprotectParams params = {
.from_prot = PROT_READ | PROT_WRITE,
.to_prot = PROT_READ,
.initial_prot = PROT_READ | PROT_WRITE,
.mprotect_prot = PROT_READ,
.size = state.range(0),
};
MprotectBenchmarkWithMmapFile(state, params);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_mprotect_rw_to_rd, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_mprotect_rw_to_rd, "AT_ALL_PAGE_SIZES");
static void BM_syscall_mmap_file_mprotect_rw_to_none(benchmark::State& state) {
struct MprotectParams params = {
.from_prot = PROT_READ | PROT_WRITE,
.to_prot = PROT_NONE,
.initial_prot = PROT_READ | PROT_WRITE,
.mprotect_prot = PROT_NONE,
.size = state.range(0),
};
MprotectBenchmarkWithMmapFile(state, params);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_mprotect_rw_to_none, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_mprotect_rw_to_none, "AT_ALL_PAGE_SIZES");
static void BM_syscall_mmap_file_mprotect_none_to_rw(benchmark::State& state) {
struct MprotectParams params = {
.from_prot = PROT_NONE,
.to_prot = PROT_READ | PROT_WRITE,
.initial_prot = PROT_NONE,
.mprotect_prot = PROT_READ | PROT_WRITE,
.size = state.range(0),
};
MprotectBenchmarkWithMmapFile(state, params);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_mprotect_none_to_rw, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_mprotect_none_to_rw, "AT_ALL_PAGE_SIZES");
static void BM_syscall_mmap_file_mprotect_none_to_rd(benchmark::State& state) {
struct MprotectParams params = {
.from_prot = PROT_NONE,
.to_prot = PROT_READ,
.initial_prot = PROT_NONE,
.mprotect_prot = PROT_READ,
.size = state.range(0),
};
MprotectBenchmarkWithMmapFile(state, params);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_mprotect_none_to_rd, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_mprotect_none_to_rd, "AT_ALL_PAGE_SIZES");
static void BM_syscall_mmap_file_mprotect_rd_to_none(benchmark::State& state) {
struct MprotectParams params = {
.from_prot = PROT_READ,
.to_prot = PROT_NONE,
.initial_prot = PROT_READ,
.mprotect_prot = PROT_NONE,
.size = state.range(0),
};
MprotectBenchmarkWithMmapFile(state, params);
}
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_mprotect_rd_to_none, "AT_All_PAGE_SIZES");
BIONIC_BENCHMARK_WITH_ARG(BM_syscall_mmap_file_mprotect_rd_to_none, "AT_ALL_PAGE_SIZES");