During implementation our https://github.com/input-output-hk/catalyst-libs/tree/main/rust/cardano-chain-follower we have faced a necessity to decode auxiliary data by our own and not for every transaction.
Which means that if we will skip CBOR decoding for such transactions in which we are not interested in, we can increase a performance of the blockchain synchronisation.
This PR introduces a naive and a strait forward implementation and basically shows at least what we need on the cardano-chain-follower side. So we are open to any suggestions how to change/improve this approach.
Added a new MultiEraBlockWithRawAuxiliary and MultiEraTxWithRawAuxiliary structures which does not actually decode Auxiliary data and keeps a raw bytes (replaced the usage of KeepRaw<'b, T> with the new OnlyRaw<'b, T>).
This allows in the cases where user do not want to use pallas specific encoding of the metadata and decode by ourselves avoid redundant decoding by pallas.
With the added benchmarks OnlyRaw<'b, AuxiliaryData> 5x faster in decoding rather than KeepRaw<'b, AuxiliaryData >:
https://github.com/input-output-hk/catalyst-pallas/blob/feff0ef1ffe458d4fb61036d2290307ec67388c1/pallas-primitives/benches/alonzo_decoding.rs#L7.
Alonzo Auxilary Data Decoding/KeepRaw<AuxiliaryData>
time: [4.8648 µs 5.0116 µs 5.2403 µs]
change: [-2.6346% +3.1304% +8.9719%] (p = 0.31 > 0.05)
No change in performance detected.
Found 13 outliers among 100 measurements (13.00%)
4 (4.00%) high mild
9 (9.00%) high severe
Alonzo Auxilary Data Decoding/OnlyRaw<AuxiliaryData>
time: [983.42 ns 988.56 ns 994.95 ns]
change: [+0.7429% +1.3247% +2.0350%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 12 outliers among 100 measurements (12.00%)
3 (3.00%) high mild
9 (9.00%) high severe
Changes
Added new structs MultiEraBlockWithRawAuxiliary and MultiEraTxWithRawAuxiliary, preserving the same API as original
MultiEraBlock and MultiEraTx. Except that MultiEraTxWithRawAuxiliary does not have metadata method.
Added new OnlyRaw struct which skips any cobra decoding and store only original cbor raw bytes for the corresponded object.
Added criterion benchmarks to compare OnlyRaw<'b, AuxiliaryData> with KeepRaw<'b, AuxiliaryData > decoding.
Added new model types for each era (where it is appropriate) like MintedBlockWithRawAuxiliary or MintedTxWithRawAuxiliary.
During implementation our https://github.com/input-output-hk/catalyst-libs/tree/main/rust/cardano-chain-follower we have faced a necessity to decode auxiliary data by our own and not for every transaction. Which means that if we will skip CBOR decoding for such transactions in which we are not interested in, we can increase a performance of the blockchain synchronisation.
This PR introduces a naive and a strait forward implementation and basically shows at least what we need on the
cardano-chain-follower
side. So we are open to any suggestions how to change/improve this approach.Added a new
MultiEraBlockWithRawAuxiliary
andMultiEraTxWithRawAuxiliary
structures which does not actually decodeAuxiliary
data and keeps a raw bytes (replaced the usage ofKeepRaw<'b, T>
with the newOnlyRaw<'b, T>
). This allows in the cases where user do not want to usepallas
specific encoding of the metadata and decode by ourselves avoid redundant decoding by pallas. With the added benchmarksOnlyRaw<'b, AuxiliaryData>
5x faster in decoding rather thanKeepRaw<'b, AuxiliaryData >
: https://github.com/input-output-hk/catalyst-pallas/blob/feff0ef1ffe458d4fb61036d2290307ec67388c1/pallas-primitives/benches/alonzo_decoding.rs#L7.Changes
MultiEraBlockWithRawAuxiliary
andMultiEraTxWithRawAuxiliary
, preserving the same API as originalMultiEraBlock
andMultiEraTx
. Except thatMultiEraTxWithRawAuxiliary
does not havemetadata
method.OnlyRaw
struct which skips any cobra decoding and store only original cbor raw bytes for the corresponded object.OnlyRaw<'b, AuxiliaryData>
withKeepRaw<'b, AuxiliaryData >
decoding.MintedBlockWithRawAuxiliary
orMintedTxWithRawAuxiliary
.