zchuango opened a new pull request, #3509:
URL: https://github.com/apache/brpc/pull/3509
### What problem does this PR solve?
Issue Number: #3463(Phase2)
Problem Summary:
This PR addresses the Phase 2 timer and lifecycle stability improvements for
UBShmTransport/UBRing discussed in #3463.
The existing UBRing timer and teardown implementation has several lifecycle
and scalability issues, including:
- a custom timerfd/epoll-based timer subsystem with per-fd state;
- stale fd / fd reuse risks and races between timer callbacks and deletion;
- blocking cleanup work running on the timer thread;
- cleanup races with `UbrTrx` release and slot reuse;
- SHM teardown ordering issues.
### What is changed and the side effects?
Changed:
- Replace the custom timerfd + epoll/kqueue implementation with
`bthread_timer_add` / `bthread_timer_del`.
- Introduce explicit timer task lifetime management and
`UbrTimerDelAndWait` for teardown paths that need to wait for in-flight
callbacks.
- Introduce `UbrCleanupCtl` to coordinate delayed cleanup and force-close
ownership independently of pooled `UbrTrx` objects.
- Add generation checks to prevent stale cleanup paths from affecting reused
trx slots.
- Remove the blocking `ub_flying_io_timeout_s` sleep from the timer callback
and use delayed cleanup instead.
- Move SHM cleanup SDK calls outside `shm_lock` and stop the cleanup timer
before `ubsmem_finalize`.
- Add exponential backoff for idle close-check polling.
- Make concurrently accessed UBRing I/O sequence counters atomic.
- Update the related UBRing documentation and clean up obsolete timer code.
Side effects:
- Performance effects:
- Removes the per-fd timer context table and dedicated timer thread.
- Reduces close-check polling while links are idle.
- Avoids blocking the timer thread during delayed cleanup.
- Breaking backward compatibility:
---
### Check List:
- Please make sure your changes are compilable.
- CI passes, including Linux Build and Test, macOS Build, and License
Check.
- When providing us with a new feature, it is best to add related tests.
- `brpc_ubring_unittest` passes.
- Client/master communication was verified successfully in a real UB
environment.
- Please follow [Contributor Covenant Code of
Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).
--
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]