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 appendOrMergeRPC inefficiency in message size recalculation #582

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

algorandskiy
Copy link
Contributor

Summary

As discussed in #581 there an inefficiency in appendOrMergeRPC in calling Size() more times than needed.

Fix

Instead of calling lastRPC.Size() that iterates over RPC.Publish, save the last known size and sum with a current message size and protobuf upper bound overhead.

Status and Evaluation

This is draft since there is no performance improvement - TODO.

// maxProtobufOverhead denotes the protobuf encoding overhead for a message.
// it is based on the RPC.Size function excerpt:
// l = e.Size()
// n += 1 + l + sovRpc(uint64(l))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain where the 1 comes from?

@MarcoPolo
Copy link
Contributor

Generally looks good. Make sure to run the Fuzz tests as well. A benchmark might also be helpful here.

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.

2 participants