Skip to content
Closed
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
49 changes: 47 additions & 2 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Build and Test on Linux

on:
push:
branches: [ master ]
branches: [ master, urma_transport_review_fixes ]
paths-ignore:
- '**.md'
pull_request:
branches: [ master ]
branches: [ master, urma_transport ]
paths-ignore:
- '**.md'

Expand Down Expand Up @@ -85,6 +85,51 @@ jobs:
-DWITH_ASAN=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ..
make -j ${{env.proc_num}} && make clean

compile-and-test-with-urma:
# WITH_URMA=ON is not covered by the jobs above: none of them set the flag,
# so src/brpc/urma/*.cpp and brpc_urma_unittest.cpp are never compiled.
# liburma is absent on the runner, so this job explicitly opts into the
# link-time mock (src/brpc/urma/mock_urma.cpp). No URMA hardware is needed.
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/install-essential-dependencies

# test/CMakeLists.txt does find_package(Gperftools) and links
# ${GPERFTOOLS_LIBRARIES} into every unittest target. The make-based
# unittest jobs never hit this, but the CMake generate step fails with
# NOTFOUND without it. Install libunwind-dev explicitly because
# libgoogle-perftools-dev depends on it on Ubuntu 22.04 runners.
- name: install gperftools
run: sudo apt-get install -y libunwind-dev libgoogle-perftools-dev

# DOWNLOAD_URMA_HEADERS fetches from atomgit.com, which is slow and often
# unreachable from CI. openEuler mirrors the same repo (identical tags and
# layout) on GitHub, so clone that and hand it to CMake via URMA_ROOT.
- name: fetch UMDK headers
run: |
git clone --depth 1 --branch v26.06.0_CAM \
https://github.com/openeuler-mirror/umdk.git $GITHUB_WORKSPACE/umdk
test -f $GITHUB_WORKSPACE/umdk/src/urma/lib/urma/core/include/urma_api.h

- name: gcc with URMA
env:
URMA_ROOT: ${{ github.workspace }}/umdk
run: |
export CC=gcc && export CXX=g++
mkdir urma_build && cd urma_build
cmake -DWITH_URMA=ON \
-DWITH_URMA_MOCK=ON \
-DBUILD_UNIT_TESTS=ON -DBUILD_BRPC_TOOLS=OFF \
-DCMAKE_BUILD_TYPE=Debug -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ..
# brpc_urma_unittest links brpc-shared-debug, built from
# SOURCES_DEBUG_LIB, which contains every urma_*.cpp plus
# mock_urma.cpp -- so this target compiles all the URMA code.
make -j ${{env.proc_num}} brpc_urma_unittest

- name: run brpc_urma_unittest
run: cd urma_build/test && ./brpc_urma_unittest

gcc-compile-with-make-protobuf:
runs-on: ubuntu-22.04
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Build on Macos

on:
push:
branches: [ master ]
branches: [ master, urma_transport_review_fixes ]
paths-ignore:
- '**.md'
pull_request:
branches: [ master ]
branches: [ master, urma_transport ]
paths-ignore:
- '**.md'

Expand Down
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ 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_URMA_MOCK
"Explicitly allow linking brpc's URMA link-time mock when liburma is not found (WITH_URMA only). The mock cannot talk to real URMA hardware, so this must be opted into rather than silently substituted."
OFF)
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 @@ -371,10 +374,17 @@ if(WITH_URMA)
if(URMA_LIB)
message(STATUS "Found URMA library: ${URMA_LIB}")
set(URMA_USE_MOCK 0)
else()
elseif(WITH_URMA_MOCK)
message(STATUS
"liburma not found; building with the URMA link-time mock")
"liburma not found; WITH_URMA_MOCK=ON, building with the URMA "
"link-time mock")
set(URMA_USE_MOCK 1)
else()
message(FATAL_ERROR
"Fail to find liburma. Install liburma, set URMA_ROOT, or "
"explicitly opt into brpc's link-time mock with "
"-DWITH_URMA_MOCK=ON (the mock cannot talk to real URMA "
"hardware; only enable it for CI/tests without URMA hardware).")
endif()
endif()

Expand Down
8 changes: 8 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,12 @@ git_repository(
build_file = '//bazel/third_party/umdk:umdk.BUILD',
remote = 'https://atomgit.com/openeuler/umdk.git',
commit = '564ee727a55523d4351a8fb3c94292b388ebb924', # v26.06.0_CAM
# umdk ships its own src/urma/BUILD.bazel, which turns src/urma into a
# separate Bazel package and silently empties the glob() in umdk.BUILD
# (glob cannot cross package boundaries). Drop it so the headers under
# src/urma/lib/urma/**/include stay part of this repository's root
# package.
patch_cmds = [
'rm -f src/urma/BUILD.bazel',
],
)
8 changes: 8 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@ git_repository(
build_file = "//bazel/third_party/umdk:umdk.BUILD",
remote = "https://atomgit.com/openeuler/umdk.git",
commit = "564ee727a55523d4351a8fb3c94292b388ebb924", # v26.06.0_CAM
# umdk ships its own src/urma/BUILD.bazel, which turns src/urma into a
# separate Bazel package and silently empties the glob() in umdk.BUILD
# (glob cannot cross package boundaries). Drop it so the headers under
# src/urma/lib/urma/**/include stay part of this repository's root
# package.
patch_cmds = [
"rm -f src/urma/BUILD.bazel",
],
)

# Header-only JSON library used by iobuf_unittest's IOBuf<->std::iostream
Expand Down
17 changes: 17 additions & 0 deletions bazel/third_party/umdk/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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.
#
# This empty BUILD.bazel file is required to make Bazel treat
# this directory as a package.
11 changes: 8 additions & 3 deletions config_brpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ else
LDD=ldd
fi

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' -- "$@"`
TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,with-rdma,with-urma,with-urma-mock,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_URMA_MOCK=0
WITH_MESALINK=0
WITH_BTHREAD_TRACER=0
WITH_ASAN=0
Expand Down Expand Up @@ -92,6 +93,7 @@ while true; do
--with-thrift) WITH_THRIFT=1; shift 1 ;;
--with-rdma) WITH_RDMA=1; shift 1 ;;
--with-urma) WITH_URMA=1; shift 1 ;;
--with-urma-mock) WITH_URMA_MOCK=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 @@ -554,9 +556,12 @@ if [ $WITH_URMA != 0 ]; then
append_to_output_libs "$URMA_LIB"
append_to_output "DYNAMIC_LINKINGS+=-lurma"
append_to_output "URMA_USE_MOCK=0"
else
elif [ $WITH_URMA_MOCK != 0 ]; then
append_to_output "URMA_USE_MOCK=1"
print_info "liburma not found; using URMA link-time mock"
print_info "liburma not found; --with-urma-mock given, using URMA link-time mock"
else
>&2 $ECHO "Fail to find liburma. Install liburma, or explicitly opt into brpc's link-time mock with --with-urma-mock (the mock cannot talk to real URMA hardware; only use it for CI/tests without URMA hardware)."
exit 1
fi
fi

Expand Down
32 changes: 29 additions & 3 deletions docs/cn/urma.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ WR。完成事件既可由 JFC 忙轮询获取,也可通过 JFCE 事件 fd 获
### CMake 编译

```bash
# 带 URMA 支持编译 brpc
# 带 URMA 支持编译 brpc(需要 liburma;无硬件/CI 场景见下方 mock 说明)
cmake -B build -DWITH_URMA=ON
make -C build -j$(nproc)

Expand All @@ -30,11 +30,37 @@ cmake -B build
make -C build -j$(nproc)
```

未安装 `liburma` 时(例如 CI 环境),需显式开启链接期 mock,而不是依赖
隐式回退:

```bash
cmake -B build -DWITH_URMA=ON -DWITH_URMA_MOCK=ON
make -C build -j$(nproc)
```

`WITH_URMA=ON` 使用上游 UMDK 头文件进行编译。CMake 优先使用系统安装的
SDK;找不到头文件时,会参照 Mooncake 的 mock 构建方式下载固定版本的
UMDK,可通过 `DOWNLOAD_URMA_HEADERS=OFF` 禁止下载。找到 `liburma` 时使用
真实硬件数据通路,否则链接 brpc 的 mock,使 URMA 代码和测试仍可在无硬件
环境编译。
真实硬件数据通路;否则默认直接报错终止构建,避免静默回退到 mock 而产出
一个看似支持 URMA、实际无法访问真实硬件的产物。需要在无硬件环境(例如
CI)编译和测试 URMA 代码时,显式传入 `-DWITH_URMA_MOCK=ON`
(Make 对应 `config_brpc.sh --with-urma-mock`)以主动选择链接 brpc 的
mock。

### Bazel 编译

```bash
# 带 URMA 支持编译 brpc
bazel build --define=BRPC_WITH_URMA=true //:brpc
```

Bazel 下的 URMA 头文件来自 `WORKSPACE` / `MODULE.bazel` 中固定 commit 的
`umdk` `git_repository`,没有 CMake `DOWNLOAD_URMA_HEADERS` 那样的开关:
既不能改用系统已安装的 SDK 头文件,也无法禁止下载。此外 Bazel 构建目前
未提供检测/链接真实 `liburma` 的逻辑,`src/brpc/urma/mock_urma.cpp` 会
无条件编入,因此 Bazel 构建的 URMA 始终使用 mock 数据通路;如需链接真实
硬件,请使用 CMake 或 Make 构建。`urma_performance` 示例目前也只有
CMake/Make 构建脚本,尚无对应的 Bazel target。

## 使用

Expand Down
37 changes: 33 additions & 4 deletions docs/en/urma.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ from a JFC either by busy polling or through a JFCE event fd.
### Build with CMake

```bash
# Build brpc with URMA support
# Build brpc with URMA support (requires liburma; see below for CI/mock builds)
cmake -B build -DWITH_URMA=ON
make -C build -j$(nproc)

Expand All @@ -30,13 +30,42 @@ cmake -B build
make -C build -j$(nproc)
```

Without `liburma` installed (e.g. in CI), explicitly opt into the link-time
mock instead of relying on an implicit fallback:

```bash
cmake -B build -DWITH_URMA=ON -DWITH_URMA_MOCK=ON
make -C build -j$(nproc)
```

`WITH_URMA=ON` compiles against upstream UMDK headers. CMake prefers an
installed SDK and, following Mooncake's mock setup, downloads a pinned UMDK
release when the headers are unavailable. Set `DOWNLOAD_URMA_HEADERS=OFF` to
disable downloading.
When `liburma` is found it is linked for the hardware data path. Otherwise,
brpc uses its link-time mock so URMA code and tests can still be built without
hardware.
When `liburma` is found it is linked for the hardware data path. Otherwise
the build fails by default, since silently falling back to the mock could
mask a broken environment and ship a binary that looks URMA-capable but
cannot reach real hardware. Pass `-DWITH_URMA_MOCK=ON`
(`config_brpc.sh --with-urma-mock`) to explicitly opt into brpc's
link-time mock so URMA code and tests can still be built without hardware
(e.g. in CI).

### Build with Bazel

```bash
# Build brpc with URMA support
bazel build --define=BRPC_WITH_URMA=true //:brpc
```

Bazel fetches the UMDK headers from the `umdk` `git_repository` pinned to a
fixed commit in `WORKSPACE` / `MODULE.bazel`. There is no Bazel equivalent of
CMake's `DOWNLOAD_URMA_HEADERS`: Bazel can neither use a locally installed SDK
nor disable the download. Bazel builds also have no detection/linking logic
for a real `liburma` yet — `src/brpc/urma/mock_urma.cpp` is compiled in
unconditionally, so a Bazel build of URMA always uses the mock data path. Use
CMake or Make to link against real hardware. The `urma_performance` example
currently only has CMake/Make build files; there is no Bazel target for it
yet.

## Usage

Expand Down
8 changes: 8 additions & 0 deletions example/cmake/BrpcExample.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ macro(brpc_example_find_common_deps out_libs)

find_package(OpenSSL REQUIRED)

# brpc built with -DWITH_URMA=ON carries undefined urma_* symbols. Link
# liburma by best effort for examples built against that configuration.
find_library(URMA_LIB NAMES urma)
if(NOT URMA_LIB)
set(URMA_LIB "")
endif()

set(_common_libs
Threads::Threads
${GFLAGS_LIBRARY}
Expand All @@ -132,6 +139,7 @@ macro(brpc_example_find_common_deps out_libs)
${OPENSSL_CRYPTO_LIBRARY}
${OPENSSL_SSL_LIBRARY}
${THRIFT_LIB}
${URMA_LIB}
dl
)

Expand Down
8 changes: 1 addition & 7 deletions example/urma_performance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ brpc_example_find_common_deps(DYNAMIC_LIB)

protobuf_generate_cpp(PROTO_SRC PROTO_HEADER test.proto)
set(BRPC_EXAMPLE_WITH_URMA ON)
find_library(URMA_LIB NAMES urma)
if(URMA_LIB)
list(APPEND DYNAMIC_LIB ${URMA_LIB})
else()
message(STATUS
"liburma not found; using the URMA implementation linked into brpc")
endif()


add_executable(urma_performance_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
brpc_example_configure_target(urma_performance_client)
Expand Down
Loading
Loading