Replace atomics with watch or oneshot channels #2268
Labels
A-rust
Area: Updates to Rust code
C-cleanup
Category: This is a cleanup
I-invalid-data
Zebra relies on invalid or untrusted data, or sends invalid data
Motivation
Some atomic sizes and atomic operations are not available on some platforms. Others come with a performance penalty on some platforms.
It's also easy to use a memory ordering that's too weak. Future code changes might require a stronger memory ordering. It's hard to test for memory ordering bugs. Some memory ordering bugs can only be discovered on non-x86 platforms. And when they do occur, they can be rare.
Channels take care of all these portability, maintainability, testing, and correctness issues. So in general, Zebra should avoid atomics.
Fixing this issue is a low priority, unless atomic-using code starts failing tests or causing bugs.
Designs
The "Replacing Atomics with Channels" section of the Zebra async Rust RFC:
https://github.com/ZcashFoundation/zebra/edit/main/book/src/dev/rfcs/0011-async-rust-in-zebra.md#replacing-atomics
Tokio channels:
https://docs.rs/tokio/*/tokio/sync
Solution
watch
oroneshot
channelswatch
oroneshot
channelsAlternatives
We could keep using atomics, and accept these portability, maintainability, testing, and correctness risks.
Related Work
#1678 Design and implement graceful shutdown for Zebra
The text was updated successfully, but these errors were encountered: