Commit 1c8fa69
committed
leverage lazy bytestring for 'Serialise' CBOR-in-CBOR.
The main use case for this type lies within the StateQuery protocol, where it can be particularly useful to obtain a plain CBOR response. This is particularly useful for large query results such as DebugNewEpochState (multiple GB on mainnet). The network library makes a great effort at trying to serialise and deserialise bytes lazily throughout; and these efforts are unfortunately destroyed by this implementation that would here evaluate the entire ByteString when decoding and encoding. So on a machine that would have both a server and client using this library, we would pay twice the cost of fully evaluating in memory the entire response, instead of leverage lazy IO as, I believe, is originally intended.
Note that 'decode' and 'encode' here rely on the default implementation for lazy ByteString in Codec.Serialise, which do the right thing: encode lazy bytestrings as indefinite sequences of byte chunks; effectively preserving the laziness in both directions.1 parent df7e419 commit 1c8fa69
1 file changed
+2
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | 476 | | |
480 | 477 | | |
481 | 478 | | |
482 | | - | |
| 479 | + | |
483 | 480 | | |
484 | 481 | | |
485 | 482 | | |
486 | 483 | | |
487 | 484 | | |
488 | | - | |
| 485 | + | |
0 commit comments