1# Copyright 2017 gRPC authors. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_package") 16load("//test/cpp/microbenchmarks:grpc_benchmark_config.bzl", "grpc_benchmark_args") 17 18licenses(["notice"]) 19 20grpc_package(name = "test/cpp/microbenchmarks") 21 22grpc_cc_test( 23 name = "noop-benchmark", 24 srcs = ["noop-benchmark.cc"], 25 external_deps = [ 26 "benchmark", 27 ], 28 deps = ["//test/core/util:grpc_test_util"], 29) 30 31grpc_cc_test( 32 name = "bm_channel_args", 33 srcs = ["bm_channel_args.cc"], 34 external_deps = [ 35 "benchmark", 36 "absl/container:btree", 37 ], 38 deps = [ 39 "//:grpc++", 40 "//src/core:channel_args", 41 "//test/core/util:grpc_test_util", 42 ], 43) 44 45grpc_cc_test( 46 name = "bm_rng", 47 srcs = ["bm_rng.cc"], 48 external_deps = [ 49 "benchmark", 50 "absl/container:btree", 51 ], 52 deps = [ 53 "//:grpc++", 54 "//src/core:channel_args", 55 "//test/core/util:grpc_test_util", 56 ], 57) 58 59grpc_cc_test( 60 name = "bm_exec_ctx", 61 srcs = ["bm_exec_ctx.cc"], 62 args = grpc_benchmark_args(), 63 external_deps = [ 64 "benchmark", 65 ], 66 uses_event_engine = False, 67 uses_polling = False, 68 deps = [":helpers"], 69) 70 71grpc_cc_test( 72 name = "bm_event_engine_run", 73 size = "small", 74 srcs = ["bm_event_engine_run.cc"], 75 args = grpc_benchmark_args(), 76 external_deps = [ 77 "absl/debugging:leak_check", 78 "benchmark", 79 ], 80 uses_polling = False, 81 deps = [ 82 ":helpers", 83 "//src/core:common_event_engine_closures", 84 ], 85) 86 87grpc_cc_test( 88 name = "bm_thread_pool", 89 size = "small", 90 srcs = ["bm_thread_pool.cc"], 91 args = grpc_benchmark_args(), 92 external_deps = [ 93 "benchmark", 94 ], 95 uses_event_engine = False, 96 uses_polling = False, 97 deps = [ 98 ":helpers", 99 "//src/core:common_event_engine_closures", 100 ], 101) 102 103grpc_cc_library( 104 name = "helpers", 105 testonly = 1, 106 srcs = ["helpers.cc"], 107 hdrs = [ 108 "fullstack_context_mutators.h", 109 "fullstack_fixtures.h", 110 "helpers.h", 111 ], 112 external_deps = [ 113 "benchmark", 114 ], 115 deps = [ 116 "//:grpc++_unsecure", 117 "//src/proto/grpc/testing:echo_proto", 118 "//test/core/util:grpc_test_util_base", 119 "//test/core/util:grpc_test_util_unsecure", 120 "//test/cpp/util:test_config", 121 ], 122) 123 124# Need a secure version of helpers to benchmark opencensus 125grpc_cc_library( 126 name = "helpers_secure", 127 testonly = 1, 128 srcs = ["helpers.cc"], 129 hdrs = [ 130 "fullstack_context_mutators.h", 131 "fullstack_fixtures.h", 132 "helpers.h", 133 ], 134 external_deps = [ 135 "benchmark", 136 ], 137 deps = [ 138 "//:grpc++", 139 "//src/proto/grpc/testing:echo_proto", 140 "//test/core/util:grpc_test_util", 141 "//test/core/util:grpc_test_util_base", 142 "//test/cpp/util:test_config", 143 ], 144) 145 146grpc_cc_test( 147 name = "bm_closure", 148 srcs = ["bm_closure.cc"], 149 args = grpc_benchmark_args(), 150 tags = [ 151 "no_mac", 152 "no_windows", 153 ], 154 deps = [ 155 ":helpers", 156 "//src/core:closure", 157 ], 158) 159 160grpc_cc_test( 161 name = "bm_huffman_decode", 162 srcs = ["bm_huffman_decode.cc"], 163 args = grpc_benchmark_args(), 164 tags = [ 165 "no_mac", 166 "no_windows", 167 "nomsan", 168 "notsan", 169 "noubsan", 170 ], 171 deps = [ 172 ":helpers", 173 "//test/cpp/microbenchmarks/huffman_geometries", 174 ], 175) 176 177grpc_cc_test( 178 name = "bm_alarm", 179 srcs = ["bm_alarm.cc"], 180 args = grpc_benchmark_args(), 181 tags = [ 182 "no_mac", 183 "no_windows", 184 ], 185 deps = [":helpers"], 186) 187 188grpc_cc_test( 189 name = "bm_arena", 190 size = "large", 191 srcs = ["bm_arena.cc"], 192 args = grpc_benchmark_args(), 193 tags = [ 194 "no_mac", 195 "no_windows", 196 "notsan", 197 ], 198 uses_event_engine = False, 199 uses_polling = False, 200 deps = [":helpers"], 201) 202 203grpc_cc_test( 204 name = "bm_byte_buffer", 205 srcs = ["bm_byte_buffer.cc"], 206 args = grpc_benchmark_args(), 207 tags = [ 208 "no_mac", 209 "no_windows", 210 ], 211 uses_event_engine = False, 212 uses_polling = False, 213 deps = [":helpers"], 214) 215 216grpc_cc_test( 217 name = "bm_channel", 218 srcs = ["bm_channel.cc"], 219 args = grpc_benchmark_args(), 220 tags = [ 221 "no_mac", 222 "no_windows", 223 ], 224 uses_event_engine = False, 225 uses_polling = False, 226 deps = [":helpers"], 227) 228 229grpc_cc_test( 230 name = "bm_cq", 231 srcs = ["bm_cq.cc"], 232 args = grpc_benchmark_args(), 233 tags = [ 234 "no_mac", 235 "no_windows", 236 ], 237 deps = [":helpers"], 238) 239 240grpc_cc_test( 241 name = "bm_cq_multiple_threads", 242 srcs = ["bm_cq_multiple_threads.cc"], 243 args = grpc_benchmark_args(), 244 tags = [ 245 "no_mac", 246 "no_windows", 247 ], 248 uses_event_engine = False, 249 uses_polling = False, 250 deps = [":helpers"], 251) 252 253grpc_cc_library( 254 name = "fullstack_streaming_ping_pong_h", 255 testonly = 1, 256 hdrs = [ 257 "fullstack_streaming_ping_pong.h", 258 ], 259 tags = [ 260 "no_mac", 261 "no_windows", 262 ], 263 deps = [":helpers"], 264) 265 266grpc_cc_test( 267 name = "bm_fullstack_streaming_ping_pong", 268 size = "large", 269 srcs = [ 270 "bm_fullstack_streaming_ping_pong.cc", 271 ], 272 args = grpc_benchmark_args(), 273 flaky = True, 274 tags = [ 275 "no_mac", # to emulate "excluded_poll_engines: poll" 276 "no_windows", 277 ], 278 deps = [":fullstack_streaming_ping_pong_h"], 279) 280 281grpc_cc_library( 282 name = "fullstack_streaming_pump_h", 283 testonly = 1, 284 hdrs = [ 285 "fullstack_streaming_pump.h", 286 ], 287 deps = [":helpers"], 288) 289 290grpc_cc_test( 291 name = "bm_fullstack_streaming_pump", 292 srcs = [ 293 "bm_fullstack_streaming_pump.cc", 294 ], 295 args = grpc_benchmark_args(), 296 tags = [ 297 "no_mac", # to emulate "excluded_poll_engines: poll" 298 "no_windows", 299 ], 300 deps = [":fullstack_streaming_pump_h"], 301) 302 303grpc_cc_library( 304 name = "fullstack_unary_ping_pong_h", 305 testonly = 1, 306 hdrs = [ 307 "fullstack_unary_ping_pong.h", 308 ], 309 deps = [":helpers_secure"], 310) 311 312grpc_cc_test( 313 name = "bm_fullstack_unary_ping_pong", 314 size = "large", 315 srcs = [ 316 "bm_fullstack_unary_ping_pong.cc", 317 ], 318 args = grpc_benchmark_args(), 319 tags = [ 320 "no_mac", # to emulate "excluded_poll_engines: poll" 321 "no_windows", 322 ], 323 deps = [":fullstack_unary_ping_pong_h"], 324) 325 326grpc_cc_test( 327 name = "bm_fullstack_unary_ping_pong_chaotic_good", 328 size = "large", 329 srcs = [ 330 "bm_fullstack_unary_ping_pong_chaotic_good.cc", 331 ], 332 args = grpc_benchmark_args(), 333 tags = [ 334 "no_mac", # to emulate "excluded_poll_engines: poll" 335 "no_windows", 336 ], 337 deps = [ 338 ":fullstack_unary_ping_pong_h", 339 "//:grpcpp_chaotic_good", 340 ], 341) 342 343grpc_cc_test( 344 name = "bm_chttp2_hpack", 345 srcs = ["bm_chttp2_hpack.cc"], 346 args = grpc_benchmark_args(), 347 tags = [ 348 "no_mac", 349 "no_windows", 350 ], 351 uses_event_engine = False, 352 uses_polling = False, 353 deps = [ 354 ":helpers", 355 "//src/core:slice", 356 ], 357) 358 359grpc_cc_test( 360 name = "bm_chttp2_transport", 361 srcs = ["bm_chttp2_transport.cc"], 362 args = grpc_benchmark_args(), 363 tags = [ 364 "no_mac", 365 "no_windows", 366 "nomsan", 367 ], 368 deps = [ 369 ":helpers", 370 "//src/core:closure", 371 "//src/core:slice", 372 ], 373) 374 375grpc_cc_test( 376 name = "bm_opencensus_plugin", 377 srcs = ["bm_opencensus_plugin.cc"], 378 args = grpc_benchmark_args(), 379 language = "C++", 380 deps = [ 381 ":helpers_secure", 382 "//:grpc_opencensus_plugin", 383 "//src/proto/grpc/testing:echo_proto", 384 ], 385) 386 387grpc_cc_library( 388 name = "bm_callback_test_service_impl", 389 testonly = 1, 390 srcs = ["callback_test_service.cc"], 391 hdrs = ["callback_test_service.h"], 392 external_deps = [ 393 "benchmark", 394 ], 395 deps = [ 396 ":helpers", 397 "//src/proto/grpc/testing:echo_proto", 398 "//test/cpp/util:test_util", 399 ], 400) 401 402grpc_cc_library( 403 name = "callback_unary_ping_pong_h", 404 testonly = 1, 405 hdrs = [ 406 "callback_unary_ping_pong.h", 407 ], 408 deps = [ 409 ":bm_callback_test_service_impl", 410 ":helpers", 411 ], 412) 413 414grpc_cc_test( 415 name = "bm_callback_unary_ping_pong", 416 size = "large", 417 srcs = [ 418 "bm_callback_unary_ping_pong.cc", 419 ], 420 args = grpc_benchmark_args(), 421 tags = [ 422 "manual", 423 "no_mac", 424 "no_windows", 425 "notap", 426 ], 427 deps = [":callback_unary_ping_pong_h"], 428) 429 430grpc_cc_library( 431 name = "callback_streaming_ping_pong_h", 432 testonly = 1, 433 hdrs = [ 434 "callback_streaming_ping_pong.h", 435 ], 436 deps = [ 437 ":bm_callback_test_service_impl", 438 ":helpers", 439 ], 440) 441 442grpc_cc_test( 443 name = "bm_callback_streaming_ping_pong", 444 size = "large", 445 srcs = [ 446 "bm_callback_streaming_ping_pong.cc", 447 ], 448 args = grpc_benchmark_args(), 449 tags = [ 450 "manual", 451 "no_mac", 452 "no_windows", 453 "notap", 454 ], 455 deps = [":callback_streaming_ping_pong_h"], 456) 457 458# TODO(hork): Generalize this for other work queue implementations 459grpc_cc_test( 460 name = "bm_basic_work_queue", 461 srcs = ["bm_basic_work_queue.cc"], 462 args = grpc_benchmark_args(), 463 external_deps = ["benchmark"], 464 tags = [ 465 "manual", 466 "no_windows", 467 "notap", 468 ], 469 uses_event_engine = False, 470 uses_polling = False, 471 deps = [ 472 "//:gpr", 473 "//src/core:common_event_engine_closures", 474 "//src/core:event_engine_basic_work_queue", 475 "//test/core/util:grpc_test_util", 476 ], 477) 478