Add the missing BRPC_WITH_UBRING Bazel configuration, wire it through
the library and example targets, and document the supported build
commands.
Enable RDMA and UBRING in CI jobs whose all-options configurations did
not exercise those features. Run both feature suites in the existing
Bazel unit-test jobs and enable RDMA in the Make unit-test job.
Use unsigned literals for UBRING atomic counter operations to match the
counter type and avoid template deduction failures on stricter
compilers.
Signed-off-by: Zhengwei Zhu <141622927+ZhengweiZhu@users.noreply.github.com>
* build(cxx): align all builds on a C++14 baseline
CMake, Make, tests, tools, and examples now require C++14 so every supported build path shares the same minimum language level. The compiler checks and user-facing documentation reflect that baseline.
* fix(test): keep cores scoped to the failing test
Clear prior cores before each test binary. A passing death test can leave a core that would otherwise be used to diagnose an unrelated later failure.
* revert src/butil/type_traits.h
* add ubring transport
* fix the bug for ub ring transport
* fix the bug for ub ring transport and other
* add the license for ub transport
* Modifying the variable naming style
* optimize the log message and some field name
* fix some bug for ubring
* add some log ubring endpoint
* add todo
* fix the bug for handshake for ub endpoint
* fix the bug for client ub endpoint
* optimize the iobuf file code
* modify the log level
* fix the declare_shm_ubs define not found bug
* add the timer_mgr support for macos and format code style
* fix the bug for macos epoll
* fix the timespece bug
* adaptor the itimerspec for macos platform
* optimize the cmakelist config
* add the ubring docs for ubring transport
* modify some file name and directory structure
* modify some code style and optimize code logical
* add the cmake ubshm transport ci/testing
* add the dependency header
* bug fix the code
* Fix UB shm allocation cleanup crashes (#11)
Co-authored-by: 郭业昌 <lvpengfei@MacBook-Air.local>
* remove the brpc_ubshm_unittest
* Found and fixed two stability issues (#13)
* 修复ubring server端关闭连接coredump问题
* 修复PollIn/PollOut解引用已释放Socket指针的问题
PollIn/PollOut通过ep->_socket(裸指针)读取data socket,当data socket
被销毁时该指针悬空,导致Socket::Address读到垃圾id触发SIGSEGV。
改为存储_socket_id(SocketId),用Address获取引用计数的Socket,
并在整个回调期间持有该引用,避免解引用悬空指针。
* 修复client非正常退出导致UBRING shm残留的问题
client被强杀(SIGTERM/崩溃/OOM)时teardown没跑完,localShm(_C)的
shm_unlink未执行,导致/dev/shm残留_C文件。server的remoteShm只munmap
不unlink(正确),无法清理client的名字。
在握手ESTABLISHED时(client/server都确认对方已mmap自己的localShm)
立即unlink localShm名字。此时对端已持有mmap引用,unlink只删名字不
影响通信;进程任意时刻退出都不会残留文件名。
* Address chenBright's review: use English comments and BAIDU_CACHELINE_ALIGNMENT
- Convert all Chinese comments in ubshm to English (per chenBright's
'Please use English' on ub_endpoint.cpp:723, ub_ring.cpp:337,
shm_ubs.cpp:316, and similar)
- Replace __attribute__((aligned(64))) with BAIDU_CACHELINE_ALIGNMENT
in ubr_msg.h (per chenBright's comment on ubr_msg.h:41)
- Remove unnecessary TODO comment in ub_ring.cpp:551 (per chenBright's
'Unnecessary comments, please delete')
* Remove unused lock macros in thread_lock.h
Per chenBright's review, the functions and macros defined in
thread_lock.h are largely unused. Verified usage across ubshm:
- LOCK_GUARD / UnlockMutex: 8 call sites in shm_ubs.cpp and
ub_ring_manager.cpp, kept.
- SPIN_LOCK_GUARD, R_LOCK_GUARD, W_LOCK_GUARD, SEMAPHORE_WAIT_GUARD,
SEMAPHORE_WAIT_GUARD_WITH_CLOSE and their helper functions
(UnlockSpinLock, UnlockRWLock, PostSem, PostSemWithClose): 0 call
sites, removed.
* Apply chenBright's review on timer_mgr globals
Per chenBright's review on timer_mgr.cpp:32-37:
- Add explicit default values to uninitialized globals
(g_total_timer_num=0, g_max_system_fd=0, g_epoll_execute_thread=0,
g_timer_module_initialized=0)
- Rename globals to snake_case (g_epollFd -> g_epoll_fd,
g_totalTimerNum -> g_total_timer_num, g_timerFdCtxMap ->
g_timer_fd_ctx_map, maxSystemFd -> g_max_system_fd,
g_epollExecuteThread -> g_epoll_execute_thread,
g_timerModuleInitialized -> g_timer_module_initialized)
- maxSystemFd also gains the g_ prefix to match global naming style
Also fix the missing std:: qualifier on atomic_fetch_sub/add/load
(per chenBright's earlier comment on timer_mgr.cpp:80).
* Change CloseTimerFd fd type from uint32_t to int
Per chenBright's review on timer_mgr.cpp:399 (uint32_t -> int).
fd is a system file descriptor; POSIX APIs use int and -1 denotes an
invalid fd, which uint32_t cannot represent. Changed the CloseTimerFd
signature (header + definition) and removed the now-unnecessary
(uint32_t) casts at the two call sites.
* Use BAIDU_LIKELY/BAIDU_UNLIKELY instead of custom __builtin_expect
Per chenBright's review on common.h:27. Rather than redefine the
macros with __builtin_expect directly, forward LIKELY/UNLIKELY to
brpc's standard BAIDU_LIKELY/BAIDU_UNLIKELY (from butil/compiler_specific.h).
The 122 call sites keep using LIKELY()/UNLIKELY() unchanged; only the
macro bodies change, preserving semantics.
* Add unit tests for UBShmEndpoint
Per chenBright's request to add unit tests for UBShmTransport in this
PR (rather than a follow-up).
Adds test/brpc_ubring_unittest.cpp with tests covering the public
interface of UBShmEndpoint under the g_skip_ub_init=true mode (which
skips real shared-memory/poller setup):
- construct_and_destruct: lifecycle safety
- is_writable_false_when_skip_init: skip-mode behavior
- reset_is_idempotent: Reset() is safe to call repeatedly
The file follows the brpc_*_unittest.cpp naming convention so it is
auto-collected by test/CMakeLists.txt's file(GLOB). Verified: compiles,
links, and all 3 tests pass (g++ 15.2, C++17, gtest, BRPC_WITH_UBRING=ON).
* Rewrite UBShmEndpoint unit tests with real coverage
Per chenBright's feedback that the previous tests were too simple and
did not cover the main methods.
Source changes to enable testing:
- Move HelloMessage struct declaration from ub_endpoint.cpp to
ub_endpoint.h so tests can access it
- Expose private members under #ifdef UNIT_TEST (precedent:
butil/containers/stack_container.h) so tests can call
AllocateClientResources without -Dprivate=public (which breaks
GCC 15 + new libstdc++ <any>/<sstream>)
Tests (9, all passing on Ubuntu 26.04 g++ 15.2 C++17 gtest):
HelloMessageTest (5): serialize/deserialize roundtrip, network byte
order verification, uint64 max boundary, full shm_name, toString
UBShmEndpointTest (4): construct, real IPC shm
AllocateClientResources (g_skip_ub_init=false), reset cleanup, reset
idempotency
* rename the variable to snake_case style
---------
Co-authored-by: YeChang Guo <52730608+YChange01@users.noreply.github.com>
Co-authored-by: 郭业昌 <lvpengfei@MacBook-Air.local>
Co-authored-by: gure <740684863@qq.com>
* Add Power-of-Two-Choices Peak-EWMA load balancer (p2c)
Implements the p2c load balancing policy proposed in #3340: each
selection samples two random servers (configurable via choices=N) and
routes to the lower peak-EWMA latency * (inflight+1) / weight score.
Upward latency spikes take effect immediately while recovery decays
over tau_ms (default 10s), so a degraded server is shed within one
observation at O(1) selection cost.
Uses only existing LoadBalancer hooks (SelectServer/Feedback,
need_feedback) with DoublyBufferedData membership like rr/la; per-node
stats are shared_ptr-owned by both buffers. Registered as "p2c" in
global.cpp. Includes unit tests (functional, weighted, exclusion,
error punishment, concurrency churn) and docs in cn/en client.md.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Reuse SelectIn.begin_time_us to avoid extra clock read per selection
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Address review: gflags for tunables, cap error punishment, drop FlatMap init
- p2c_default_choices/p2c_default_tau_ms gflags as channel-overridable defaults
- p2c_max_punish_ms(default 30s) caps the doubled-EWMA error punishment so a
persistently failing server recovers in bounded time after turning healthy
- Servers::server_map relies on FlatMap small-map auto-init
- tests: error_punish_is_capped + feedback_lock_overhead benchmark
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: rajvarun77 <287367605+rajvarun77@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
- Fix outdated Travis CI badge in README_cn.md to GitHub Actions
- Unify all doc links in README.md to point to docs/en/ directory
- Add references for bthread tracer, coroutine, circuit breaker, RDMA, Bazel support
- Create 39 English placeholder docs pointing to Chinese versions
- Create Chinese placeholder for couchbase_example
* feat(backup_request): add rate-limited backup request policy (#3228)
* docs(backup_request): restructure rate-limiting section, add lifecycle guidance
- Promote built-in factory function to its own subsection (before custom interface)
- Add unique_ptr usage example for policy lifetime management
- Add RateLimitedBackupPolicyOptions parameter table with defaults/constraints
- Document NULL return on invalid params
- Keep cn/en docs in sync
* fix(backup_request): address review issues — sentinel fallback, comments, tests
- controller.cpp: When policy returns -1 (inherit sentinel), fall back
to _backup_request_ms set from ChannelOptions, so backup timer is
actually armed when using a policy with backup_request_ms=-1.
- backup_request_policy.cpp: Clarify OnRPCEnd comment to say 'RPC legs'
(both original and backup completions counted as denominator).
- backup_request_policy.cpp: Warn when update_interval_seconds exceeds
window_size_seconds (window would rarely refresh within its period).
- backup_request_policy.h: Fix comment typo ('Called when an RPC ends').
- brpc_channel_unittest.cpp: Replace nullptr with NULL to match codebase
convention; use ASSERT_TRUE(p != NULL) for unique_ptr null checks.
- brpc_channel_unittest.cpp: Add ValidMaxRatioAtBoundary behavioral assert
and AfterColdStartBackupSuppressedUntilRpcCompletes test.
* fix(backup_request): correct docs table defaults and add suppression test
- docs: fix backup_request_ms default (0→-1) and constraint (>=0→>=-1);
add note that -1 inherit only works via ChannelOptions injection path,
not Controller::set_backup_request_policy().
- test: replace no-op AfterColdStart test with a real behavioral assertion:
after cold-start backup fires, wait 1.2s for ratio refresh, verify
DoBackup() returns false (conservative ratio=1.0 path triggers).
* fix(backup_request): clarify comments — negative defer semantics and burst caveat
* fix(backup_request): address Copilot review — sentinel contract, OnRPCEnd comment, re-allow test, docs
- controller.cpp: treat -1 specifically (not all negatives) as the inherit
sentinel; other negatives still disable backup, preserving old behavior
for custom policies that return negative values to disable backup
- backup_request_policy.h: document the -1 sentinel contract on
GetBackupRequestMs() so custom implementors know the new interface
- backup_request_policy.cpp: fix OnRPCEnd comment — called once per
user-level RPC, not once per leg (total_count tracks user RPCs)
- test: add OnRPCEndDrivesRatioDownAndReAllows — fires 20 backups to
suppress, then completes 50 RPCs via OnRPCEnd, verifies DoBackup
re-allows once ratio refreshes below max_backup_ratio
- docs (EN+CN): rephrase backup_request_ms=-1 note to clarify the
channel-level fallback only applies when set via ChannelOptions
* fix(backup_request): explain why std::nothrow is intentionally omitted
Plain new follows brpc's project-wide OOM convention (abort rather than
return NULL). The factory's NULL return already exclusively signals invalid
parameters, not allocation failure — adding std::nothrow would conflate
the two. Comment added to suppress future linter/AI suggestions.
* docs(backup_request): clarify policy lifetime — channel must be destroyed before policy
The unique_ptr comment was ambiguous: 'released when goes out of scope,
as long as it outlives the channel' can be read as contradictory. Reword
to make the ordering explicit: destroy channel first, then policy.
* test(backup_request): fix inaccurate cold-start comment in ValidMaxRatioAtBoundary
ratio=1.0 conservative path only applies when backup>0 && total==0.
True cold start (both zero) sets ratio=0.0 and allows freely.
* Implemented Couchbase binary protocol support
* added support for single connection type for couchbase
* removed unnecessary cout statements
* added protocol code for helo packet
* fixed vbucketID code for identification, fixed add and get functions
* Added test cases for threaded get and add functions
* Added Error Handling code and made upsert and delete examples
* added makefile for example/couchbase_c++
* fixed bugs in couchbase header files
* Added License and formatted to google c++ norms
* fixed bugs, added support for collections and added couchbase_client.md
* fixed license issue
* added custom logic for caching collectionIDs
* added caching of collection manifests
* Added example code for multithreaded demonstration
* updated CMake
* Abstracted CRUD operations
* Added pipeline/batching support
* commented unused variables
* Updated support for C++17
* fixed some issue.
* Using Mutex instead of shared lock to support c++11
* Formatted code to google c++ format
* Introduced local cache per-instance of CouchbaseOperations and added functionality to handle server side manifest updates.
* Delete MODULE.bazel.lock
Unnecessary file
* Fixed bugs in local collection cache and collection refresh logic
* remove recurring statements
* Fixed bugs/repetitive calls to refreshing manifest on server
* Formatted function/variable naming scheme and formatted code in c++ google format
* removed unnecessary code
* updated comments
* updated comments
* updated documentation
* updated documentation
* updated documentation
* updated documentation
* Updated documentation
* Updated documentation
* Update documentation
* Added features and fixed bugs in multithreaded environment
Using connection_groups to differentiate between connections across CouchbaseOperations instances to different buckets.
Renamed CollectionManifestTracker class to CollectionManifestManager and all the related functionality inside it as before refreshing method was outside this class
Added two different authenticate method authenticate(not secure) and authenticateSSL(secure)
* Updated multithreaded and single threaded code.
Added an example where a single instance is being shared across the threads when operating on single bucket.
* updated documentation
updated the documentation on thread safe operations and fixed small small discrepancies.
* removed commented code and updated readme to have links for cluster download certificate
* removed unused code.
* Added traditional bRPC coding approach
Traditional bRPC coding approach doesn't uses high level functions but provides more control to the user
fixed formatting issues.
fixed the bug in couchbase.cpp where logic to check the cache is empty was inverted
* updated couchbase_example.md
* added unit test cases
* removed using namespace std from couchbase.h
* restored original CMakeLists.txt
* Fix libunwind linked by default on x86_64 cpu when build with bazel
* fix errors in getting_started.md english version
* add link libunwind instruction for bazel
* feat: batch create and accept stream
* fix protobuf 22.5 compilation error related to thread_local in MacOS
* refine style
* modify code based on the code review feedback and add more tests
modify code based on the code review feedback and add more tests
As term 'M:N' starts with a vowel sound [e], so it should be 'an' instead of
'a' grammatically.
Signed-off-by: freemandealer <freeman.zhang1992@gmail.com>