[memory-usage] Track memory usage for chaotic-good (#36863)

Built on #36862 which should be merged first.

Closes #36863

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36863 from ctiller:cgmem 9d45ced0b6
PiperOrigin-RevId: 644219306
pull/36960/head
Craig Tiller 5 months ago committed by Copybara-Service
parent af580b4422
commit 3b21f2cac5
  1. 4
      test/core/memory_usage/BUILD
  2. 6
      test/core/memory_usage/callback_client.cc
  3. 6
      test/core/memory_usage/callback_server.cc
  4. 15
      test/core/memory_usage/client.cc
  5. 10
      test/core/memory_usage/memory_usage_test.cc
  6. 6
      test/core/memory_usage/server.cc
  7. 1
      tools/profiling/memory/memory_diff.py

@ -58,6 +58,7 @@ grpc_cc_binary(
"//:gpr",
"//:grpc",
"//src/core:channel_args",
"//src/core:chaotic_good_connector",
"//test/core/test_util:grpc_test_util",
"//test/core/test_util:grpc_test_util_base",
],
@ -82,6 +83,7 @@ grpc_cc_binary(
"//:gpr",
"//:grpc",
"//src/core:channel_args",
"//src/core:chaotic_good_server",
"//src/core:xds_enabled_server",
"//test/core/end2end:ssl_test_data",
"//test/core/test_util:grpc_test_util",
@ -109,6 +111,7 @@ grpc_cc_binary(
"//:gpr",
"//:grpc",
"//:grpc++",
"//:grpcpp_chaotic_good",
"//src/proto/grpc/testing:benchmark_service_proto",
"//test/core/end2end:ssl_test_data",
"//test/core/test_util:grpc_test_util",
@ -135,6 +138,7 @@ grpc_cc_binary(
"//:gpr",
"//:grpc",
"//:grpc++",
"//:grpcpp_chaotic_good",
"//src/proto/grpc/testing:benchmark_service_proto",
"//test/core/end2end:ssl_test_data",
"//test/core/test_util:grpc_test_util",

@ -39,6 +39,7 @@
#include <grpcpp/support/status.h>
#include "src/core/lib/gprpp/notification.h"
#include "src/cpp/ext/chaotic_good.h"
#include "src/proto/grpc/testing/benchmark_service.grpc.pb.h"
#include "src/proto/grpc/testing/messages.pb.h"
#include "test/core/memory_usage/memstats.h"
@ -48,12 +49,15 @@ ABSL_FLAG(std::string, target, "", "Target host:port");
ABSL_FLAG(bool, secure, false, "Use SSL Credentials");
ABSL_FLAG(int, server_pid, 0, "Server's pid");
ABSL_FLAG(int, size, 50, "Number of channels");
ABSL_FLAG(bool, chaotic_good, false, "Use chaotic good");
std::shared_ptr<grpc::Channel> CreateChannelForTest(int index) {
// Set the authentication mechanism.
std::shared_ptr<grpc::ChannelCredentials> creds =
grpc::InsecureChannelCredentials();
if (absl::GetFlag(FLAGS_secure)) {
if (absl::GetFlag(FLAGS_chaotic_good)) {
creds = grpc::ChaoticGoodInsecureChannelCredentials();
} else if (absl::GetFlag(FLAGS_secure)) {
// TODO (chennancy) Add in secure credentials
LOG(INFO) << "Supposed to be secure, is not yet";
}

@ -33,6 +33,7 @@
#include <grpcpp/support/status.h>
#include <grpcpp/xds_server_builder.h>
#include "src/cpp/ext/chaotic_good.h"
#include "src/proto/grpc/testing/benchmark_service.grpc.pb.h"
#include "src/proto/grpc/testing/messages.pb.h"
#include "test/core/memory_usage/memstats.h"
@ -41,6 +42,7 @@
ABSL_FLAG(std::string, bind, "", "Bind host:port");
ABSL_FLAG(bool, secure, false, "Use SSL Credentials");
ABSL_FLAG(bool, use_xds, false, "Use xDS");
ABSL_FLAG(bool, chaotic_good, false, "Use chaotic good");
class ServerCallbackImpl final
: public grpc::testing::BenchmarkService::CallbackService {
@ -102,7 +104,9 @@ int main(int argc, char** argv) {
// Set the authentication mechanism.
std::shared_ptr<grpc::ServerCredentials> creds =
grpc::InsecureServerCredentials();
if (absl::GetFlag(FLAGS_secure)) {
if (absl::GetFlag(FLAGS_chaotic_good)) {
creds = grpc::ChaoticGoodInsecureServerCredentials();
} else if (absl::GetFlag(FLAGS_secure)) {
LOG(INFO) << "Supposed to be secure, is not yet";
// TODO (chennancy) Add in secure credentials
}

@ -42,6 +42,7 @@
#include <grpc/status.h>
#include <grpc/support/time.h>
#include "src/core/ext/transport/chaotic_good/client/chaotic_good_connector.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/util/useful.h"
@ -231,6 +232,7 @@ ABSL_FLAG(std::string, target, "localhost:443", "Target host:port");
ABSL_FLAG(int, warmup, 100, "Warmup iterations");
ABSL_FLAG(int, benchmark, 1000, "Benchmark iterations");
ABSL_FLAG(bool, minstack, false, "Use minimal stack");
ABSL_FLAG(bool, chaotic_good, false, "Use chaotic good");
int main(int argc, char** argv) {
absl::ParseCommandLine(argc, argv);
@ -255,10 +257,19 @@ int main(int argc, char** argv) {
args_vec.push_back(grpc_channel_arg_integer_create(
const_cast<char*>(GRPC_ARG_MINIMAL_STACK), 1));
}
if (absl::GetFlag(FLAGS_chaotic_good)) {
args_vec.push_back(grpc_channel_arg_integer_create(
const_cast<char*>(GRPC_ARG_ENABLE_RETRIES), 0));
}
grpc_channel_args args = {args_vec.size(), args_vec.data()};
channel = grpc_channel_create(absl::GetFlag(FLAGS_target).c_str(),
grpc_insecure_credentials_create(), &args);
if (absl::GetFlag(FLAGS_chaotic_good)) {
channel = grpc_chaotic_good_channel_create(
absl::GetFlag(FLAGS_target).c_str(), &args);
} else {
channel = grpc_channel_create(absl::GetFlag(FLAGS_target).c_str(),
grpc_insecure_credentials_create(), &args);
}
int call_idx = 0;
const int warmup_iterations = absl::GetFlag(FLAGS_warmup);

@ -65,9 +65,10 @@ ABSL_FLAG(std::string, benchmark_names, "",
"if --use_xds is true.");
ABSL_FLAG(int, size, 1000, "Number of channels/calls");
ABSL_FLAG(std::string, scenario_config, "insecure",
"Possible Values: minstack (Use minimal stack), resource_quota, "
"secure (Use SSL credentials on server)");
ABSL_FLAG(
std::string, scenario_config, "insecure",
"Possible Values: minstack (Use minimal stack), resource_quota, insecure, "
"secure (Use SSL credentials on server), chaotic_good");
ABSL_FLAG(bool, memory_profiling, false,
"Run memory profiling"); // TODO (chennancy) Connect this flag
ABSL_FLAG(bool, use_xds, false, "Use xDS");
@ -82,6 +83,7 @@ class Subprocess {
for (const auto& arg : args) {
args_c.push_back(arg.c_str());
}
LOG(INFO) << "START: " << absl::StrJoin(args, " ");
process_ = gpr_subprocess_create(args_c.size(), args_c.data());
}
@ -308,7 +310,7 @@ int main(int argc, char** argv) {
{"resource_quota", {/*client=*/{}, /*server=*/{"--secure"}}},
{"minstack", {/*client=*/{"--minstack"}, /*server=*/{"--minstack"}}},
{"insecure", {{}, {}}},
};
{"chaotic_good", {{"--chaotic_good"}, {"--chaotic_good"}}}};
auto it_scenario = scenarios.find(absl::GetFlag(FLAGS_scenario_config));
if (it_scenario == scenarios.end()) {
printf("No scenario matching the name could be found\n");

@ -47,6 +47,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/time.h>
#include "src/core/ext/transport/chaotic_good/server/chaotic_good_server.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/xds/grpc/xds_enabled_server.h"
@ -59,6 +60,7 @@ ABSL_FLAG(std::string, bind, "", "Bind host:port");
ABSL_FLAG(bool, secure, false, "Use security");
ABSL_FLAG(bool, minstack, false, "Use minimal stack");
ABSL_FLAG(bool, use_xds, false, "Use xDS");
ABSL_FLAG(bool, chaotic_good, false, "Use chaotic good");
static grpc_completion_queue* cq;
static grpc_server* server;
@ -220,7 +222,9 @@ int main(int argc, char** argv) {
}
MemStats before_server_create = MemStats::Snapshot();
if (absl::GetFlag(FLAGS_secure)) {
if (absl::GetFlag(FLAGS_chaotic_good)) {
grpc_server_add_chaotic_good_port(server, addr.c_str());
} else if (absl::GetFlag(FLAGS_secure)) {
grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key,
test_server1_cert};
grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(

@ -88,6 +88,7 @@ _INTERESTING = {
_SCENARIOS = {
"default": [],
"minstack": ["--scenario_config=minstack"],
"chaotic_good": ["--scenario_config=chaotic_good"],
}
_BENCHMARKS = {

Loading…
Cancel
Save