algorand / algorand/go-algorand
Perf: txn decoding - reuse encoded txn
- 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
Assessment
This issue has not been assessed yet.