algorand / algorand/go-algorand

Perf: txn decoding - reuse encoded txn

Open
#4,548 0 comments 0 reactions 1 assignee Claimed by @cce View on GitHub
Performance Team Carbon-11
Dominant language
Go
Stars
1.4k
Forks
537
Avg merge
1d 7h
Merged PRs (30d)
18

Description

Re-use encoded txn objects to reduce redundant txn encoding.

### Context
When nodes receive gossipped txns, they decode them, perform checks (signature validation etc), and then re-encode them before forwarding them onwards. Currently, nodes re-encode transactions multiple times (calculating txn ID, encoding the txn to forward in gossip, etc), wasting resources.

To boost node performance, we can reduce the number of times they encode txns.

Unknowns:
1. How much time is spent encoding txns (can check txn profiler)
2. List of areas we duplicate txn encoding

Raw txn groups and block proposals both contain encoded txns, so we can save re-encoding effort for txns and proposals.
Goal: zero allocation for `Transaction` objects while evaluating it.

### Acceptance Criteria
1. Possibly: measure time spent encoding txn (via txn profiler) to gauge opportunity
2. Identify areas of duplicate encoding
3. Implementation
- For block proposals:
- Introduce `RawPayset []msgp.Raw` to Block in order to use it as needed.
- In `Eval` iterate `RawPayset` and decode as needed instead of pre-decoding the Payset.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.