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

fix(core-p2p): disable permessage-deflate #3518

Merged
merged 1 commit into from
Feb 20, 2020
Merged

fix(core-p2p): disable permessage-deflate #3518

merged 1 commit into from
Feb 20, 2020

Conversation

alessiodf
Copy link
Contributor

Summary

There is memory leak in core-p2p which also leads to workers not responding after a while. This is caused by enabling permessage-deflate (PMD) in the websockets. PMD was introduced in 2.5 but the problem only became apparent in 2.6 because PMD uses heuristics to determine whether to compress the data or send it uncompressed, for example, small packets are not compressed because the overhead would not be worth it. AIP11 introduced things like multipayments, which result in larger transaction payloads, triggering PMD compression whereas the smaller transaction payloads in Core 2.5 were below the threshold for PMD compression. This is why the problem only became apparent in 2.6 and also likely explains why 2.6 uses more CPU cycles as PMD is happening much more often, which requires more resources to compress/uncompress the data.

Due to the current p2p architecture, using PMD means the websocket can never be garbage collected (GC). Over time the number of websockets keeps rising and this causes a memory leak. Eventually, the leak stops the PMD compression queues from consuming their data, so any data to be compressed does not get sent to the destination websocket. This is what causes the workers to appear to stop responding, since their compressed output never gets consumed in the compression queue. It also explains why the p2p.peer.postTransactions endpoint still works -- it only returns an empty array, below the PMD compression threshold, whereas other endpoints return more data which would be compressed.

Due to the new optimised data transmission codec and serialisation, PMD is no longer required and will make for a leaner less resource-hungry Core.

Checklist

  • Documentation (if necessary)
  • Tests (if necessary)
  • Ready to be merged

@ghost
Copy link

ghost commented Feb 20, 2020

Thanks for submitting this pull request! A maintainer will review this in the next few days and explicitly select labels so you know what's going on.

If no reviewer appears after a week, a reminder will be sent out.

@ghost
Copy link

ghost commented Feb 20, 2020

A collaborator has approved this PR. A maintainer will merge this PR shortly. If it shouldn't be merged yet, please leave a comment saying so and we'll wait.

Thank you for your contribution!

@faustbrian faustbrian merged commit 7bbd962 into ArkEcosystem:2.6 Feb 20, 2020
@ghost
Copy link

ghost commented Feb 20, 2020

Your pull request has been merged and marked as tier 1. It will earn you $200 USD.

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.

None yet

2 participants