Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ bazel-bin
bazel-distbench
bazel-out
bazel-testlogs
gen-cpp/
65 changes: 62 additions & 3 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ config_setting(
flag_values = {":with-mercury": 'True'}
)

bool_flag(
name = "with-thrift",
build_setting_default = False
)

config_setting(
name = "with_thrift",
flag_values = {":with-thrift": 'True'}
)

cc_library(
name = "distbench_netutils",
srcs = [
Expand Down Expand Up @@ -115,9 +125,18 @@ cc_library(
+ select({
"with_mercury": [":protocol_driver_mercury", ],
"//conditions:default": []
}),
})
+ select({
"with_thrift": [":protocol_driver_thrift"],
"//conditions:default": []
}
),
copts = select({
":with_mercury":["-DWITH_MERCURY"],
":with_thrift": ["-DWITH_THRIFT"],
"//conditions:default": []
})
+ select({
":with_mercury": ["-DWITH_MERCURY"],
"//conditions:default": []
})
)
Expand Down Expand Up @@ -188,6 +207,10 @@ cc_test(
":with_mercury":["-DWITH_MERCURY"],
"//conditions:default": []
})
+ select({
":with_thrift":["-DWITH_THRIFT"],
"//conditions:default": []
})
)

cc_binary(
Expand Down Expand Up @@ -263,6 +286,10 @@ cc_test(
copts = select({
":with_mercury":["-DWITH_MERCURY"],
"//conditions:default": []
})
+ select({
":with_thrift":["-DWITH_THRIFT"],
"//conditions:default": []
}),
)

Expand Down Expand Up @@ -320,6 +347,21 @@ cc_test(
],
)

cc_library(
name = "distbench_thrift_lib",
srcs = ["gen-cpp/Distbench.cpp",
# "gen-cpp/distbench_types.cpp"
],
hdrs = ["gen-cpp/Distbench.h", "gen-cpp/distbench_types.h"],
strip_include_prefix = "gen-cpp/",
deps = [
"@apache_thrift//:thrift",
],
tags = [
"manual"
],
)

cc_test(
name = "distbench_engine_test",
size = "medium",
Expand Down Expand Up @@ -400,4 +442,21 @@ cc_test(
],
)


cc_library(
name = "protocol_driver_thrift",
srcs = [
"protocol_driver_thrift.cc",
],
hdrs = [
"protocol_driver_thrift.h",
],
deps = [
":distbench_utils",
":protocol_driver_api",
":distbench_thrift_lib",
"@apache_thrift//:thrift",
],
tags = [
"manual"
],
)
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
default: all

thrift_proto: distbench.thrift
../../opt/thrift/bin/thrift --gen cpp distbench.thrift

testlog:
bazel test --test_output=all :all

Expand Down Expand Up @@ -28,7 +31,13 @@ clang-format:
done

all:
bazel build :all
bazel build :distbench

test_with_thrift: thrift_proto
bazel test :all --//:with-thrift

all_with_thrift: thrift_proto
bazel build :distbench --//:with-thrift

clean:
bazel clean
6 changes: 6 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,9 @@ new_local_repository(
build_file = "libfabric.BUILD",
)

new_local_repository(
name = "apache_thrift",
path = "../opt/thrift",
build_file = "thrift.BUILD",
)

5 changes: 5 additions & 0 deletions distbench.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace cpp thrift

service Distbench {
string GenericRPC(1: string payload);
}
14 changes: 14 additions & 0 deletions distbench_test_sequencer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,20 @@ TEST(DistBenchTestSequencer,
RunIntenseTrafficMaxDurationMaxIteration("grpc_async_callback");
}

#ifdef WITH_THRIFT
TEST(DistBenchTestSequencer, RunIntenseTrafficMaxDurationThrift) {
RunIntenseTrafficMaxDuration("thrift");
}

TEST(DistBenchTestSequencer, RunIntenseTrafficMaxIterationThrift) {
RunIntenseTrafficMaxIteration("thrift");
}

TEST(DistBenchTestSequencer, RunIntenseTrafficMaxDurationMaxIterationThrift) {
RunIntenseTrafficMaxDurationMaxIteration("thrift");
}
#endif

#ifdef WITH_MERCURY
TEST(DistBenchTestSequencer, RunIntenseTrafficMaxDurationMercury) {
RunIntenseTrafficMaxDuration("mercury");
Expand Down
47 changes: 47 additions & 0 deletions docs/thrift_how_to.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Running Distbench with Thrift

## Introduction

[Apache Thrift](https://thrift.apache.org/) can be used as transport for the
RPCs using the thrift protocol driver.

Note: Thrift is only used as a transport for the RPC the
serialization/deserialization is still performed using Protobuf.

## Building the Thrift library

Build the Apache Thrift library in the parent folder `opt/thrift`.

```bash
cd ..
git clone https://github.com/apache/thrift.git thrift_src
cd thrift_src
./bootstrap.sh
./configure --without-java --without-go --without-python --without-py3 --prefix=`pwd`/../opt/thrift
make
make check
make install
```

Run the Distbench tests:
```bash
cd ../distbench
make test_with_thrift
```

## Running with the Thrift protocol driver

Use the `thrift` protocol driver:
```
tests {
default_protocol: "thrift"
```

Run the test:
```bash
export DISTBENCH_EXTRA_BAZEL_OPTIONS="--//:with-thrift"
./start_distbench_localhost.sh -n 1
./simple_test.sh
```


7 changes: 7 additions & 0 deletions protocol_driver_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#ifdef WITH_MERCURY
#include "protocol_driver_mercury.h"
#endif
#ifdef WITH_THRIFT
#include "protocol_driver_thrift.h"
#endif

namespace distbench {

Expand Down Expand Up @@ -53,6 +56,10 @@ absl::StatusOr<std::unique_ptr<ProtocolDriver>> AllocateProtocolDriver(
#ifdef WITH_MERCURY
} else if (opts.protocol_name() == "mercury") {
pd = std::make_unique<ProtocolDriverMercury>();
#endif
#ifdef WITH_THRIFT
} else if (opts.protocol_name() == "thrift") {
pd = std::make_unique<ProtocolDriverThrift>();
#endif
} else {
if (alias_resolver_ == nullptr) {
Expand Down
9 changes: 9 additions & 0 deletions protocol_driver_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ ProtocolDriverOptions MercuryOptions() {
return ret;
}

ProtocolDriverOptions ThriftOptions() {
ProtocolDriverOptions ret;
ret.set_protocol_name("thrift");
return ret;
}

void BM_GrpcEcho(benchmark::State& state) { Echo(state, GrpcOptions()); }

void BM_GrpcCallbackEcho(benchmark::State& state) {
Expand All @@ -302,6 +308,9 @@ INSTANTIATE_TEST_SUITE_P(ProtocolDriverTests, ProtocolDriverTest,
GrpcPollingClientHandoffServer(),
GrpcPollingClientPollingServer(),
GrpcCallbackClientInlineServer(),
#ifdef WITH_THRIFT
ThriftOptions(),
#endif
#ifdef WITH_MERCURY
MercuryOptions(),
#endif
Expand Down
Loading