chenBright commented on code in PR #3328: URL: https://github.com/apache/brpc/pull/3328#discussion_r3369154737
########## bazel/third_party/liburing/liburing.BUILD: ########## @@ -0,0 +1,39 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# BUILD file for liburing (io_uring userspace library). +# Uses rules_foreign_cc to run liburing's ./configure + make, which is required +# because compat.h (providing __kernel_timespec on older kernels) is generated +# by the configure script and is not present in the source tarball. + +load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make") + +licenses(["notice"]) # MIT / GPL-2.0-only (dual-licensed) + +filegroup( + name = "all_srcs", + srcs = glob(["**"]), +) + +configure_make( Review Comment: The liburing BUILD.bazel implementation in the bazel central registry is better. https://github.com/bazelbuild/bazel-central-registry/blob/main/modules/liburing/2.14/overlay/BUILD.bazel ########## MODULE.bazel: ########## @@ -15,6 +15,7 @@ bazel_dep(name = 'platforms', version = '0.0.4') bazel_dep(name = "apple_support", version = "1.17.1") bazel_dep(name = 'rules_cc', version = '0.0.1') bazel_dep(name = 'rules_proto', version = '4.0.0') +bazel_dep(name = 'rules_foreign_cc', version = '0.12.0') Review Comment: 1. Which module depends on rules_foreign_cc? 2. According to https://registry.bazel.build/modules/liburing/2.14, you need to add the liburing dependency, as follows: ``` bazel_dep(name = "liburing", version = "2.14", repo_name = "com_github_axboe_liburing") ``` ########## BUILD.bazel: ########## @@ -531,18 +538,33 @@ cc_library( "src/brpc/policy/thrift_protocol.cpp", "src/brpc/event_dispatcher_epoll.cpp", "src/brpc/event_dispatcher_kqueue.cpp", + "src/brpc/iouring/*.cpp", + # Exclude pre-generated .pb.cc files; Bazel regenerates them via + # brpc_internal_cc_proto / brpc_idl_options_cc_proto using protoc 27.x. + "src/brpc/*.pb.cc", + "src/brpc/**/*.pb.cc", Review Comment: This might be a false question. brpc has been using protobuf 27.3 in MOUDLE.bazel for a long time and it compiles successfully in CI. These pb.cc files are probably not generated by bazel; they might be generated by compiling with make. https://github.com/apache/brpc/blob/72adb6ec24a98247b0f6d8c2ce40a6fc3ae0c41b/MODULE.bazel#L11 ########## BUILD.bazel: ########## @@ -94,6 +97,11 @@ LINKOPTS = [ "-libverbs", ], "//conditions:default": [], +}) + select({ + "//bazel/config:brpc_with_iouring": [ + "-luring", + ], + "//conditions:default": [], Review Comment: It's more appropriate to handle linking issues in liburing BUILD.bazel. In brpc BUILD.bazel, you only need to depend on liburing in deps. ########## src/bthread/types.h: ########## @@ -152,7 +152,14 @@ static const size_t BTHREAD_EPOLL_THREAD_NUM = 1; static const bthread_t BTHREAD_ATOMIC_INIT = 0; // Min/Max number of work pthreads. +// When RDMA or io_uring is compiled in, their dedicated Poller threads handle +// I/O directly, so the bare minimum drops to 1 worker + epoll thread. +// Otherwise keep the traditional floor of 3 + epoll (1 epoll + 2 workers). +#if defined(BRPC_WITH_RDMA) || defined(BRPC_WITH_IOURING) +static const int BTHREAD_MIN_CONCURRENCY = 1 + BTHREAD_EPOLL_THREAD_NUM; +#else static const int BTHREAD_MIN_CONCURRENCY = 3 + BTHREAD_EPOLL_THREAD_NUM; +#endif Review Comment: @yanglimingcn This issue deserves attention. ########## BUILD.bazel: ########## @@ -531,18 +538,33 @@ cc_library( "src/brpc/policy/thrift_protocol.cpp", "src/brpc/event_dispatcher_epoll.cpp", "src/brpc/event_dispatcher_kqueue.cpp", + "src/brpc/iouring/*.cpp", + # Exclude pre-generated .pb.cc files; Bazel regenerates them via + # brpc_internal_cc_proto / brpc_idl_options_cc_proto using protoc 27.x. + "src/brpc/*.pb.cc", + "src/brpc/**/*.pb.cc", ]) + select({ "//bazel/config:brpc_with_thrift": glob([ "src/brpc/thrift*.cpp", "src/brpc/**/thrift*.cpp", ]), "//conditions:default": [], + }) + select({ + "//bazel/config:brpc_with_iouring": glob([ + "src/brpc/iouring/*.cpp", + ]), + "//conditions:default": [], }), hdrs = glob([ "src/brpc/*.h", "src/brpc/**/*.h", "src/brpc/event_dispatcher_epoll.cpp", "src/brpc/event_dispatcher_kqueue.cpp", + ], exclude = [ + # Exclude pre-generated .pb.h files; Bazel uses the ones regenerated by + # brpc_internal_cc_proto / brpc_idl_options_cc_proto (protoc 27.x). + "src/brpc/*.pb.h", + "src/brpc/**/*.pb.h", Review Comment: This might be a false question. brpc has been using protobuf 27.3 in MOUDLE.bazel for a long time and it compiles successfully in CI. These pb.h files are probably not generated by bazel; they might be generated by compiling with make. https://github.com/apache/brpc/blob/72adb6ec24a98247b0f6d8c2ce40a6fc3ae0c41b/MODULE.bazel#L11 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
