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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ CTestTestfile.cmake
/test/out.txt
/test/recordio_ref.io

# Local design notes and Graphify artifacts.
docs/cn/urma_proposal.md
graphify-out/

# Ignore protoc-gen-mcpack files
/protoc-gen-mcpack*/

Expand Down
13 changes: 10 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ DEFINES = [
}) + select({
"//bazel/config:brpc_with_rdma": ["BRPC_WITH_RDMA=1"],
"//conditions:default": [],
}) + select({
"//bazel/config:brpc_with_urma": ["BRPC_WITH_URMA=1"],
"//conditions:default": [],
}) + select({
"//bazel/config:brpc_with_debug_bthread_sche_safety": ["BRPC_DEBUG_BTHREAD_SCHE_SAFETY=1"],
"//conditions:default": ["BRPC_DEBUG_BTHREAD_SCHE_SAFETY=0"],
Expand Down Expand Up @@ -520,6 +523,7 @@ filegroup(
"src/brpc/*.proto",
"src/brpc/policy/*.proto",
"src/brpc/rdma/*.proto",
"src/brpc/urma/*.proto",
]),
visibility = ["//visibility:public"],
)
Expand Down Expand Up @@ -558,9 +562,7 @@ cc_library(
"src/brpc/event_dispatcher_kqueue.cpp",
]),
copts = COPTS,
includes = [
"src/",
],
includes = ["src/"],
linkopts = LINKOPTS,
visibility = ["//visibility:public"],
deps = [
Expand All @@ -572,6 +574,11 @@ cc_library(
":mcpack2pb",
"@com_github_google_leveldb//:leveldb",
] + select({
"//bazel/config:brpc_with_urma": [
"@umdk//:urma_headers",
],
"//conditions:default": [],
}) + select({
"//bazel/config:brpc_with_thrift": [
"@org_apache_thrift//:thrift",
],
Expand Down
84 changes: 83 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ option(WITH_THRIFT "With thrift framed protocol supported" OFF)
option(WITH_BTHREAD_TRACER "With bthread tracer supported" OFF)
option(WITH_SNAPPY "With snappy" OFF)
option(WITH_RDMA "With RDMA" OFF)
option(WITH_URMA "With URMA (openEuler Unified Remote Memory Access)" OFF)
option(DOWNLOAD_URMA_HEADERS
"Download UMDK headers when WITH_URMA is enabled and headers are absent"
ON)
option(WITH_UBRING "With UB" OFF)
option(WITH_DEBUG_BTHREAD_SCHE_SAFETY "With debugging bthread sche safety" OFF)
option(WITH_DEBUG_LOCK "With debugging lock" OFF)
Expand Down Expand Up @@ -121,6 +125,11 @@ if(WITH_RDMA)
set(WITH_RDMA_VAL "1")
endif()

set(WITH_URMA_VAL "0")
if(WITH_URMA)
set(WITH_URMA_VAL "1")
endif()

set(WITH_UBRING_VAL "0")
if(WITH_UBRING)
set(WITH_UBRING_VAL "1")
Expand Down Expand Up @@ -160,6 +169,7 @@ endif()
list(APPEND BRPC_COMMON_DEFINITIONS
BRPC_WITH_GLOG=${WITH_GLOG_VAL}
BRPC_WITH_RDMA=${WITH_RDMA_VAL}
BRPC_WITH_URMA=${WITH_URMA_VAL}
BRPC_WITH_UBRING=${WITH_UBRING_VAL}
BRPC_DEBUG_BTHREAD_SCHE_SAFETY=${WITH_DEBUG_BTHREAD_SCHE_SAFETY_VAL}
BRPC_DEBUG_LOCK=${WITH_DEBUG_LOCK_VAL}
Expand Down Expand Up @@ -318,6 +328,56 @@ if(WITH_RDMA)
list(APPEND BRPC_COMMON_INCLUDE_DIRS ${RDMA_INCLUDE_PATH})
endif()

if(WITH_URMA)
# UrmaTransport and its link-time mock both compile against the upstream
# UMDK API. Prefer installed headers; otherwise fetch a pinned upstream
# release, following Mooncake's URMA mock setup.
find_path(URMA_INCLUDE_PATH NAMES urma_api.h
HINTS ENV URMA_ROOT
PATHS /usr/include /usr/local/include
PATH_SUFFIXES ub/umdk/urma umdk/urma urma
src/urma/lib/urma/core/include)
find_path(URMA_BOND_INCLUDE_PATH NAMES urma_ubagg.h
HINTS ENV URMA_ROOT
PATHS /usr/include /usr/local/include
PATH_SUFFIXES ub/umdk/urma umdk/urma urma
src/urma/lib/urma/bond/include)
if(NOT URMA_INCLUDE_PATH AND DOWNLOAD_URMA_HEADERS)
include(FetchContent)
FetchContent_Declare(
urma_headers
GIT_REPOSITORY https://atomgit.com/openeuler/umdk.git
GIT_TAG v26.06.0_CAM
GIT_SHALLOW TRUE)
FetchContent_GetProperties(urma_headers)
if(NOT urma_headers_POPULATED)
FetchContent_Populate(urma_headers)
endif()
set(URMA_INCLUDE_PATH
"${urma_headers_SOURCE_DIR}/src/urma/lib/urma/core/include")
set(URMA_BOND_INCLUDE_PATH
"${urma_headers_SOURCE_DIR}/src/urma/lib/urma/bond/include")
message(STATUS "Using downloaded UMDK headers: ${URMA_INCLUDE_PATH}")
endif()
if(NOT URMA_INCLUDE_PATH)
message(FATAL_ERROR
"Fail to find urma_api.h. Install UMDK headers, set URMA_ROOT, "
"or enable DOWNLOAD_URMA_HEADERS.")
endif()

find_library(URMA_LIB NAMES urma
HINTS ENV URMA_ROOT
PATH_SUFFIXES lib lib64)
if(URMA_LIB)
message(STATUS "Found URMA library: ${URMA_LIB}")
set(URMA_USE_MOCK 0)
else()
message(STATUS
"liburma not found; building with the URMA link-time mock")
set(URMA_USE_MOCK 1)
endif()
endif()

find_library(PROTOC_LIB NAMES protoc)
if(NOT PROTOC_LIB)
message(FATAL_ERROR "Fail to find protoc lib")
Expand All @@ -342,6 +402,12 @@ list(APPEND BRPC_COMMON_INCLUDE_DIRS
${PROTOBUF_INCLUDE_DIRS}
${LEVELDB_INCLUDE_PATH}
)
if(WITH_URMA)
list(APPEND BRPC_COMMON_INCLUDE_DIRS ${URMA_INCLUDE_PATH})
if(URMA_BOND_INCLUDE_PATH)
list(APPEND BRPC_COMMON_INCLUDE_DIRS ${URMA_BOND_INCLUDE_PATH})
endif()
endif()

set(DYNAMIC_LIB
${GFLAGS_LIBRARY}
Expand Down Expand Up @@ -370,6 +436,13 @@ if(WITH_RDMA)
list(APPEND DYNAMIC_LIB ${RDMA_LIB})
endif()

if(WITH_URMA)
message(STATUS "brpc compile with URMA (mock=${URMA_USE_MOCK})")
if(NOT URMA_USE_MOCK)
list(APPEND DYNAMIC_LIB ${URMA_LIB})
endif()
endif()

if(WITH_UBRING)
message(STATUS "brpc compile with ubring")
list(APPEND DYNAMIC_LIB ${UB_LIB})
Expand Down Expand Up @@ -575,6 +648,14 @@ file(GLOB_RECURSE BRPC_SOURCES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/brpc
file(GLOB_RECURSE THRIFT_SOURCES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/brpc/thrift*.cpp")
file(GLOB_RECURSE EXCLUDE_SOURCES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/brpc/event_dispatcher_*.cpp")

# When building with the real liburma, exclude the link-time mock so its urma_*
# symbols do not clash with the library. When liburma is absent, keep it so CI
# can build and test UrmaTransport without URMA hardware.
if(WITH_URMA AND NOT URMA_USE_MOCK)
list(REMOVE_ITEM BRPC_SOURCES
"${PROJECT_SOURCE_DIR}/src/brpc/urma/mock_urma.cpp")
endif()

if(WITH_THRIFT)
message("brpc compile with thrift protocol")
else()
Expand Down Expand Up @@ -615,7 +696,8 @@ set(PROTO_FILES idl_options.proto
brpc/trackme.proto
brpc/streaming_rpc_meta.proto
brpc/proto_base.proto
brpc/rdma/rdma_handshake.proto)
brpc/rdma/rdma_handshake.proto
brpc/urma/urma_handshake.proto)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/output/include/brpc)
set(PROTOC_FLAGS ${PROTOC_FLAGS} -I${PROTOBUF_INCLUDE_DIR})
compile_proto(PROTO_HDRS PROTO_SRCS ${PROJECT_BINARY_DIR}
Expand Down
11 changes: 11 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,14 @@ git_override(
remote = 'https://github.com/hedronvision/bazel-compile-commands-extractor.git',
commit = '1e08f8e0507b6b6b1f4416a9a22cf5c28beaba93', # Jun 28, 2024
)

git_repository = use_repo_rule(
'@bazel_tools//tools/build_defs/repo:git.bzl',
'git_repository',
)
git_repository(
name = 'umdk',
build_file = '//bazel/third_party/umdk:umdk.BUILD',
remote = 'https://atomgit.com/openeuler/umdk.git',
tag = 'v26.06.0_CAM',
)
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,15 @@ JSON2PB_SOURCES = $(foreach d,$(JSON2PB_DIRS),$(wildcard $(addprefix $(d)/*,$(SR
JSON2PB_OBJS = $(addsuffix .o, $(basename $(JSON2PB_SOURCES)))

BRPC_DIRS = src/brpc src/brpc/details src/brpc/builtin src/brpc/policy src/brpc/policy/mysql src/brpc/rdma
ifeq ($(WITH_URMA),1)
BRPC_DIRS += src/brpc/urma
endif
THRIFT_SOURCES = $(foreach d,$(BRPC_DIRS),$(wildcard $(addprefix $(d)/thrift*,$(SRCEXTS))))
EXCLUDE_SOURCES = $(foreach d,$(BRPC_DIRS),$(wildcard $(addprefix $(d)/event_dispatcher_*,$(SRCEXTS))))
BRPC_SOURCES_ALL = $(foreach d,$(BRPC_DIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
ifeq ($(URMA_USE_MOCK),0)
BRPC_SOURCES_ALL := $(filter-out src/brpc/urma/mock_urma.cpp,$(BRPC_SOURCES_ALL))
endif
BRPC_SOURCES = $(filter-out $(THRIFT_SOURCES) $(EXCLUDE_SOURCES), $(BRPC_SOURCES_ALL))
BRPC_PROTOS = $(filter %.proto,$(BRPC_SOURCES))
BRPC_CFAMILIES = $(filter-out %.proto %.pb.cc,$(BRPC_SOURCES))
Expand Down
9 changes: 8 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ http_archive(
urls = ["https://archive.apache.org/dist/thrift/0.15.0/thrift-0.15.0.tar.gz"],
)

git_repository(
name = "umdk",
build_file = "//bazel/third_party/umdk:umdk.BUILD",
remote = "https://atomgit.com/openeuler/umdk.git",
tag = "v26.06.0_CAM",
)

# Header-only JSON library used by iobuf_unittest's IOBuf<->std::iostream
# adapter tests. Keep version in sync with MODULE.bazel.
http_archive(
Expand Down Expand Up @@ -317,4 +324,4 @@ http_archive(
sha256 = "3cd0e49f0f4a6d406c1d74b53b7616f5e24f5fd319eafc1bf8eee6e14124d115",
)
load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup")
hedron_compile_commands_setup()
hedron_compile_commands_setup()
8 changes: 7 additions & 1 deletion bazel/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ config_setting(
visibility = ["//visibility:public"],
)

config_setting(
name = "brpc_with_urma",
define_values = {"BRPC_WITH_URMA": "true"},
visibility = ["//visibility:public"],
)

config_setting(
name = "brpc_with_boringssl",
define_values = {"BRPC_WITH_BORINGSSL": "true"},
Expand Down Expand Up @@ -155,4 +161,4 @@ config_setting(
name = "with_babylon_counter",
define_values = {"with_babylon_counter": "true"},
visibility = ["//visibility:public"],
)
)
28 changes: 28 additions & 0 deletions bazel/third_party/umdk/umdk.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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.

package(default_visibility = ["//visibility:public"])

cc_library(
name = "urma_headers",
hdrs = glob([
"src/urma/lib/urma/bond/include/*.h",
"src/urma/lib/urma/core/include/*.h",
]),
includes = [
"src/urma/lib/urma/bond/include",
"src/urma/lib/urma/core/include",
],
)
25 changes: 24 additions & 1 deletion config_brpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ else
LDD=ldd
fi

TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,with-rdma,with-mesalink,with-bthread-tracer,with-debug-bthread-sche-safety,with-debug-lock,with-asan,with-riscv-zvbc,with-riscv-zbc,with-cpu-frequency,nodebugsymbols,werror -n 'config_brpc' -- "$@"`
TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,with-rdma,with-urma,with-mesalink,with-bthread-tracer,with-debug-bthread-sche-safety,with-debug-lock,with-asan,with-riscv-zvbc,with-riscv-zbc,with-cpu-frequency,nodebugsymbols,werror -n 'config_brpc' -- "$@"`
WITH_GLOG=0
WITH_THRIFT=0
WITH_RDMA=0
WITH_URMA=0
WITH_MESALINK=0
WITH_BTHREAD_TRACER=0
WITH_ASAN=0
Expand Down Expand Up @@ -90,6 +91,7 @@ while true; do
--with-glog ) WITH_GLOG=1; shift 1 ;;
--with-thrift) WITH_THRIFT=1; shift 1 ;;
--with-rdma) WITH_RDMA=1; shift 1 ;;
--with-urma) WITH_URMA=1; shift 1 ;;
--with-mesalink) WITH_MESALINK=1; shift 1 ;;
--with-bthread-tracer) WITH_BTHREAD_TRACER=1; shift 1 ;;
--with-debug-bthread-sche-safety ) BRPC_DEBUG_BTHREAD_SCHE_SAFETY=1; shift 1 ;;
Expand Down Expand Up @@ -538,6 +540,26 @@ if [ $WITH_RDMA != 0 ]; then
append_to_output "WITH_RDMA=1"
fi

if [ $WITH_URMA != 0 ]; then
URMA_LIB=$(find_dir_of_lib urma)
URMA_HDR=$(find_dir_of_header_or_die urma_api.h)
URMA_BOND_HDR=$(find_dir_of_header urma_ubagg.h)
CPPFLAGS="${CPPFLAGS} -DBRPC_WITH_URMA=1"
append_to_output "WITH_URMA=1"
append_to_output_headers "$URMA_HDR"
if [ -n "$URMA_BOND_HDR" ]; then
append_to_output_headers "$URMA_BOND_HDR"
fi
if [ -n "$URMA_LIB" ]; then
append_to_output_libs "$URMA_LIB"
append_to_output "DYNAMIC_LINKINGS+=-lurma"
append_to_output "URMA_USE_MOCK=0"
else
append_to_output "URMA_USE_MOCK=1"
print_info "liburma not found; using URMA link-time mock"
fi
fi

if [ $WITH_MESALINK != 0 ]; then
CPPFLAGS="${CPPFLAGS} -DUSE_MESALINK"
fi
Expand Down Expand Up @@ -674,6 +696,7 @@ print_info "System: $SYSTEM"
if [ $WITH_GLOG -ne 0 ]; then print_info "With glog: yes"; fi
if [ $WITH_THRIFT -ne 0 ]; then print_info "With thrift: yes"; fi
if [ $WITH_RDMA -ne 0 ]; then print_info "With RDMA: yes"; fi
if [ $WITH_URMA -ne 0 ]; then print_info "With URMA: yes"; fi
if [ $WITH_MESALINK -ne 0 ]; then print_info "With MesaLink: yes"; fi
if [ $WITH_BTHREAD_TRACER -ne 0 ]; then print_info "With bthread tracer: yes"; fi
if [ $WITH_ASAN -ne 0 ]; then print_info "With ASAN: yes"; fi
Expand Down
Loading
Loading