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

performance: Cache hello packet encoding/decoding #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aikar
Copy link
Contributor

@aikar aikar commented Feb 10, 2020

Hello packets for the most part will never change. JSON and encryption are blocking operations
that occur some performance cost to use.

We can cache our outgoing hello packet, and clear the cache anytime the payload is expected
to be manipulated by .advertise().

Likewise, we can cache received hello messages based on IP+Port+data.

The size of these messages are small and should result in negligible memory increase, but
at the benefit of a major reduction in CPU cost to avoid repeatedly calling
encrypt/encrypt and JSON stringify/parse.

In a large ensemble of nodes, this can add significant CPU reduction.

Hello packets for the most part will never change. JSON and encryption are blocking operations
that occur some performance cost to use.

We can cache our outgoing hello packet, and clear the cache anytime the payload is expected
to be manipulated by .advertise().

Likewise, we can cache received hello messages based on IP+Port+data.

The size of these messages are small and should result in negligible memory increase, but
at the benefit of a major reduction in CPU cost to avoid repeatedly calling
encrypt/encrypt and JSON stringify/parse.

In a large ensemble of nodes, this can add significant CPU reduction.
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

1 participant