| Line |
Branch |
Exec |
Source |
| 1 |
|
|
#include <gflags/gflags.h> |
| 2 |
|
|
|
| 3 |
|
|
#include <algorithm> |
| 4 |
|
|
#include <chrono> |
| 5 |
|
|
#include <cstdio> |
| 6 |
|
|
#include <vector> |
| 7 |
|
|
|
| 8 |
|
|
#include "grpc_ps_client.h" |
| 9 |
|
|
|
| 10 |
|
|
DEFINE_string(host, "127.0.0.1", "PS server host"); |
| 11 |
|
|
DEFINE_int32(port, 15000, "PS server port"); |
| 12 |
|
|
DEFINE_int32(warmup, 10, "Warmup iterations"); |
| 13 |
|
|
DEFINE_int32(iters, 100, "Measured iterations per payload size"); |
| 14 |
|
|
|
| 15 |
|
|
static const int64_t kSizes[] = { |
| 16 |
|
|
4 * 1024, // 4 KB |
| 17 |
|
|
64 * 1024, // 64 KB |
| 18 |
|
|
512 * 1024, // 512 KB |
| 19 |
|
|
4 * 1024 * 1024, // 4 MB |
| 20 |
|
|
}; |
| 21 |
|
|
|
| 22 |
|
✗ |
static double now_us() { |
| 23 |
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
return std::chrono::duration_cast<std::chrono::nanoseconds>( |
| 24 |
|
✗ |
std::chrono::steady_clock::now().time_since_epoch()) |
| 25 |
|
✗ |
.count() / |
| 26 |
|
✗ |
1e3; |
| 27 |
|
|
} |
| 28 |
|
|
|
| 29 |
|
|
template <typename Fn> |
| 30 |
|
|
static void |
| 31 |
|
✗ |
RunBench(const char* label, int64_t size_bytes, int warmup, int iters, Fn fn) { |
| 32 |
0/4
void RunBench<main::{lambda(long)#1}>(char const*, long, int, int, main::{lambda(long)#1}):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
void RunBench<main::{lambda(long)#2}>(char const*, long, int, int, main::{lambda(long)#2}):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
for (int i = 0; i < warmup; i++) |
| 33 |
0/4
void RunBench<main::{lambda(long)#1}>(char const*, long, int, int, main::{lambda(long)#1}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
void RunBench<main::{lambda(long)#2}>(char const*, long, int, int, main::{lambda(long)#2}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
fn(size_bytes); |
| 34 |
|
|
|
| 35 |
0/4
void RunBench<main::{lambda(long)#1}>(char const*, long, int, int, main::{lambda(long)#1}):
✗ Branch 2 not taken.
✗ Branch 3 not taken.
void RunBench<main::{lambda(long)#2}>(char const*, long, int, int, main::{lambda(long)#2}):
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
✗ |
std::vector<double> latencies(iters); |
| 36 |
0/4
void RunBench<main::{lambda(long)#1}>(char const*, long, int, int, main::{lambda(long)#1}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
void RunBench<main::{lambda(long)#2}>(char const*, long, int, int, main::{lambda(long)#2}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
double t_start = now_us(); |
| 37 |
0/4
void RunBench<main::{lambda(long)#1}>(char const*, long, int, int, main::{lambda(long)#1}):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
void RunBench<main::{lambda(long)#2}>(char const*, long, int, int, main::{lambda(long)#2}):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
for (int i = 0; i < iters; i++) { |
| 38 |
0/4
void RunBench<main::{lambda(long)#1}>(char const*, long, int, int, main::{lambda(long)#1}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
void RunBench<main::{lambda(long)#2}>(char const*, long, int, int, main::{lambda(long)#2}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
double t0 = now_us(); |
| 39 |
0/4
void RunBench<main::{lambda(long)#1}>(char const*, long, int, int, main::{lambda(long)#1}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
void RunBench<main::{lambda(long)#2}>(char const*, long, int, int, main::{lambda(long)#2}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
fn(size_bytes); |
| 40 |
0/4
void RunBench<main::{lambda(long)#1}>(char const*, long, int, int, main::{lambda(long)#1}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
void RunBench<main::{lambda(long)#2}>(char const*, long, int, int, main::{lambda(long)#2}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
latencies[i] = now_us() - t0; |
| 41 |
|
|
} |
| 42 |
0/4
void RunBench<main::{lambda(long)#1}>(char const*, long, int, int, main::{lambda(long)#1}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
void RunBench<main::{lambda(long)#2}>(char const*, long, int, int, main::{lambda(long)#2}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
double elapsed_us = now_us() - t_start; |
| 43 |
|
|
|
| 44 |
0/4
void RunBench<main::{lambda(long)#1}>(char const*, long, int, int, main::{lambda(long)#1}):
✗ Branch 3 not taken.
✗ Branch 4 not taken.
void RunBench<main::{lambda(long)#2}>(char const*, long, int, int, main::{lambda(long)#2}):
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
✗ |
std::sort(latencies.begin(), latencies.end()); |
| 45 |
|
✗ |
double avg_us = elapsed_us / iters; |
| 46 |
|
✗ |
double p50_us = latencies[iters * 50 / 100]; |
| 47 |
|
✗ |
double p99_us = latencies[iters * 99 / 100]; |
| 48 |
|
✗ |
double tput_mb = |
| 49 |
|
✗ |
(static_cast<double>(size_bytes) * iters / (1024.0 * 1024.0)) / |
| 50 |
|
✗ |
(elapsed_us / 1e6); |
| 51 |
|
|
|
| 52 |
0/4
void RunBench<main::{lambda(long)#1}>(char const*, long, int, int, main::{lambda(long)#1}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
void RunBench<main::{lambda(long)#2}>(char const*, long, int, int, main::{lambda(long)#2}):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
printf(" [%-4s] %6.0f KB avg=%8.1f us p50=%8.1f us p99=%8.1f us " |
| 53 |
|
|
"tput=%8.1f MB/s\n", |
| 54 |
|
|
label, |
| 55 |
|
|
size_bytes / 1024.0, |
| 56 |
|
|
avg_us, |
| 57 |
|
|
p50_us, |
| 58 |
|
|
p99_us, |
| 59 |
|
|
tput_mb); |
| 60 |
|
✗ |
} |
| 61 |
|
|
|
| 62 |
|
✗ |
int main(int argc, char** argv) { |
| 63 |
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
gflags::ParseCommandLineFlags(&argc, &argv, true); |
| 64 |
|
|
|
| 65 |
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
GRPCParameterClient client(FLAGS_host, FLAGS_port, /*shard=*/0); |
| 66 |
|
|
|
| 67 |
0/2
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
✗ |
printf("PS Network Benchmark server=%s:%d warmup=%d iters=%d\n\n", |
| 68 |
|
|
FLAGS_host.c_str(), |
| 69 |
|
|
FLAGS_port, |
| 70 |
|
|
FLAGS_warmup, |
| 71 |
|
|
FLAGS_iters); |
| 72 |
|
|
|
| 73 |
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
printf("LoadFakeData (download: server -> client)\n"); |
| 74 |
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
for (int64_t sz : kSizes) |
| 75 |
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
RunBench("load", sz, FLAGS_warmup, FLAGS_iters, [&](int64_t n) { |
| 76 |
|
✗ |
client.LoadFakeData(n); |
| 77 |
|
✗ |
}); |
| 78 |
|
|
|
| 79 |
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
printf("\nDumpFakeData (upload: client -> server)\n"); |
| 80 |
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
✗ |
for (int64_t sz : kSizes) |
| 81 |
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
✗ |
RunBench("dump", sz, FLAGS_warmup, FLAGS_iters, [&](int64_t n) { |
| 82 |
|
✗ |
client.DumpFakeData(n); |
| 83 |
|
✗ |
}); |
| 84 |
|
|
|
| 85 |
|
✗ |
return 0; |
| 86 |
|
✗ |
} |
| 87 |
|
|
|