go-algorand
go-algorand copied to clipboard
Perf: txn decoding - reuse encoded txn
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:
- How much time is spent encoding txns (can check txn profiler)
- 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
- Possibly: measure time spent encoding txn (via txn profiler) to gauge opportunity
- Identify areas of duplicate encoding
- Implementation
- For block proposals:
- Introduce
RawPayset []msgp.Raw
to Block in order to use it as needed. - In
Eval
iterateRawPayset
and decode as needed instead of pre-decoding the Payset.
- Introduce
- For block proposals: