ChainSafe / ChainSafe/forest

Limit unbounded channel usage

Open
#5,855 2 comments 0 reactions 0 assignees View on GitHub
Type: Task
Dominant language
Rust
Stars
697
Forks
200
Avg merge
1d 5h
Merged PRs (30d)
65

Description

# Summary

During recent memory profiling in Forest, we noticed the channels in the peer-to-peer module tend to be unbounded. This could have led to excessive memory usage.

Image

A likely scenario here is that messages in `handle_gossip_event` get deserialised and put into the network channel. Get enough of such events and the channels could grow quickly, each holding the deserialised message, leading to high memory usage.

This issue is not exclusive to the p2p layer; we should revisit all of the `flume::unbounded` in Forest and allow it only when it's justified.

# Completion Criteria

- [ ] re-visit `flume::unbounded` usages in Forest; all of them should be either justified or changed to `bounded` versions, with either constants or parameters with sane defaults. ⚠️ Important! Usage of these channels should also be revisited - pushing to a channel that is at its limits will block; this could lead to a deadlock.
- [ ] ban the usage of `flume::unbounded` in the clippy settings

# Additional Links & Resources

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.