Skip to content

Commit 217dd2c

Browse files
authored
clippy.toml: Create config and disallow unbounded channels (#2823)
When using channels (e.g. `futures::channel::mpsc` or `std::sync::mpsc`) always use the bounded variant, never use the unbounded variant. When using a bounded channel, a slow consumer eventually slows down a fast producer once the channel bound is reached, ideally granting the slow consumer more system resources e.g. CPU time, keeping queues small and thus latencies low. When using an unbounded channel a fast producer continues being a fast producer, growing the channel buffer indefinitely, increasing latency until the illusion of unboundedness breaks and the system runs out of memory. One may use an unbounded channel if one enforces backpressure through an out-of-band mechanism, e.g. the consumer granting the producer send-tokens through a side-channel.
1 parent 3d3666e commit 217dd2c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

clippy.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
disallowed-methods = [
2+
{ path = "futures::channel::mpsc::unbounded", reason = "does not enforce backpressure" },
3+
]

0 commit comments

Comments
 (0)