You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While updating the golden test for LedgerState in ouroboros-consensus, which is basically NewEpochState + some extras, I noticed that the binary encoding of the overlay schedule (Map SlotNo (OBftSlot crypto) where data OBftSlot crypto = NonActiveSlot | ActiveSlot !(GenKeyHash crypto) is very repetitive:
For each slot in the overlay schedule, which, if I'm not mistaken, is the number of slots in the epoch = 21600, it will contain either an empty element (NonActiveSlot) or a hash (ActiveSlot !(GenKeyHash crypto)).
The binary encoding is wasteful as the same 7 (= number of core nodes) hashes end up many, many times in the encoding.
We can optimise this by converting the Map SlotNo (OBftSlot crypto) type to the following representation before/after en/decoding:
Map (OBftSlot crypto) (NonEmptySlotNo)
Now each hash will only be stored exactly once.
P.S. using Map SlotNo (OBftSlot crypto) as the in-memory representation is less bad, because the hashes should be shared (which would be the case after deserialising the above encoding, but not after deserialising the current one!). Nevertheless, I would be inclined to optimise this too.
The text was updated successfully, but these errors were encountered:
While updating the golden test for
LedgerState
inouroboros-consensus
, which is basicallyNewEpochState
+ some extras, I noticed that the binary encoding of the overlay schedule (Map SlotNo (OBftSlot crypto)
wheredata OBftSlot crypto = NonActiveSlot | ActiveSlot !(GenKeyHash crypto)
is very repetitive:For each slot in the overlay schedule, which, if I'm not mistaken, is the number of slots in the epoch = 21600, it will contain either an empty element (
NonActiveSlot
) or a hash (ActiveSlot !(GenKeyHash crypto)
).The binary encoding is wasteful as the same 7 (= number of core nodes) hashes end up many, many times in the encoding.
We can optimise this by converting the
Map SlotNo (OBftSlot crypto)
type to the following representation before/after en/decoding:Now each hash will only be stored exactly once.
P.S. using
Map SlotNo (OBftSlot crypto)
as the in-memory representation is less bad, because the hashes should be shared (which would be the case after deserialising the above encoding, but not after deserialising the current one!). Nevertheless, I would be inclined to optimise this too.The text was updated successfully, but these errors were encountered: