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

Add a size estimator to the message encoder and serializers #1774

Closed
3 tasks
teor2345 opened this issue Feb 18, 2021 · 1 comment
Closed
3 tasks

Add a size estimator to the message encoder and serializers #1774

teor2345 opened this issue Feb 18, 2021 · 1 comment
Labels
A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement

Comments

@teor2345
Copy link
Contributor

teor2345 commented Feb 18, 2021

Is your feature request related to a problem? Please describe.

In #1773, we removed an allocation by double-serializing outgoing network messages. But we could be even more efficient if the ZcashSerialize trait had a size estimate function.

Describe the solution you'd like

  • create a consistent design for size estimates

The TrustedPreallocate trait is also effectively a (minimum) size estimator. So we might want to combine all these different estimates into a single trait:

  • min size estimate - TrustedPreallocate

  • largest allowed array size (typically message 2 * 2^10 or block 2 * 10^3 bytes) - TrustedPreallocate

  • max size estimate - message preallocation (this ticket)

  • Add a max size estimate to serialised data types

  • Use the max size estimate to avoid double-serialising during outgoing message encoding

Describe alternatives you've considered

Do nothing: we'll waste a bit of CPU double-serialising things

Additional context

Zebra probably has a lot more pressing performance issues, so this is low priority.

This change would add a lot of extra code that effectively duplicates serialization logic. It might be more trouble to write and maintain than its worth. We might do better using the visitor pattern.

@teor2345 teor2345 added A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage P-Low labels Feb 18, 2021
@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label Feb 26, 2021
@teor2345
Copy link
Contributor Author

We haven't needed this yet.

@mpguerra mpguerra closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2023
mpguerra added a commit that referenced this issue May 19, 2023
mergify bot pushed a commit that referenced this issue May 23, 2023
* ZIPs were updated to remove ambiguity, this was tracked in #1267.

* #2105 was fixed by #3039 and #2379 was closed by #3069

* #2230 was a duplicate of #2231 which was closed by #2511

* #3235 was obsoleted by #2156 which was fixed by #3505

* #1850 was fixed by #2944, #1851 was fixed by #2961 and #2902 was fixed by #2969

* We migrated to Rust 2021 edition in Jan 2022 with #3332

* #1631 was closed as not needed

* #338 was fixed by #3040 and #1162 was fixed by #3067

* #2079 was fixed by #2445

* #4794 was fixed by #6122

* #1678 stopped being an issue

* #3151 was fixed by #3934

* #3204 was closed as not needed

* #1213 was fixed by #4586

* #1774 was closed as not needed

* #4633 was closed as not needed

* Clarify behaviour of difficulty spacing

Co-authored-by: teor <teor@riseup.net>

* Update comment to reflect implemented behaviour

Co-authored-by: teor <teor@riseup.net>

* Update comment to reflect implemented behaviour when retrying block downloads

Co-authored-by: teor <teor@riseup.net>

* Update `TODO` to remove closed issue and clarify when we might want to fix

Co-authored-by: teor <teor@riseup.net>

* Update `TODO` to remove closed issue and clarify what we might want to change in future

Co-authored-by: teor <teor@riseup.net>

* Clarify benefits of how we do block verification

Co-authored-by: teor <teor@riseup.net>

* Fix rustfmt errors

---------

Co-authored-by: teor <teor@riseup.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code C-enhancement Category: This is an improvement
Projects
None yet
Development

No branches or pull requests

2 participants