Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send publisher permissions using a watch channel to address heap growth #118

Conversation

alexheretic
Copy link
Contributor

Fixes heap growth if Exporter::update_our_prices is not called as often as updates.

Running agent --config config/config.sample.pythtest.toml would previously appear to "leak" memory quite quickly over time as Exporter::update_our_prices was not being called to drain the channel. The existing publisher permissions is bounded, but bounded at 10k would take a long time to fill and has a huge memory ceiling.

The fix is straightforward as the receiver side only ever used the latest value sent anyway, replacing the mpsc bounded channel with a watch channel produces equivalent behaviour but with a drastically reduced memory ceiling as it holds a single clone of the publisher_permissions map no matter the behaviour/frequency of the rx side.

Fixes heap growth if Exporter::update_our_prices is not called as often as updates
@@ -86,8 +86,7 @@ pub mod network {
logger: Logger,
) -> Result<Vec<JoinHandle<()>>> {
// Publisher permissions updates between oracle and exporter
let (publisher_permissions_tx, publisher_permissions_rx) =
mpsc::channel(config.oracle.updates_channel_capacity);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was the only use of the updates_channel_capacity config. Let's remove the config as well if that's the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updates_channel_capacity is still used for the "updates" channel (updates_tx,updates_rx).

@ali-bahjati ali-bahjati merged commit 4985864 into pyth-network:main Apr 25, 2024
2 checks passed
@alexheretic alexheretic deleted the fix-publisher-permissions-heap-usage branch April 29, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants