foxglove / mcap

MCAP is a modular, performant, and serialization-agnostic container file format, useful for pub/sub and robotics applications.
https://mcap.dev
MIT License
496 stars 90 forks source link

perf(ts): McapStreamDispatcher, a faster iterator #1219

Open AaronO opened 1 month ago

AaronO commented 1 month ago

Showcases an alternative, more optimal iterator, that's easier to optimize for the chunk message hot path.

McapStreamReader
        4.90±0.05 op/s  Heap Used: 40.03±2.24 MB/op     Heap Total: 28.38±3.87 MB/op    ArrayBuffers: 106.73±12.33 MB/op
McapStreamDispatcher
        6.43±0.01 op/s  Heap Used: 52.63±0.35 MB/op     Heap Total: 36.23±0.71 MB/op    ArrayBuffers: 12.70±0.98 MB/op
McapIndexedReader
        2.37±0.01 op/s  Heap Used: 69.54±1.53 MB/op     Heap Total: 50.37±2.92 MB/op    ArrayBuffers: 17.86±1.85 MB/op
McapIndexedReader_reverse
        2.38±0.00 op/s  Heap Used: 59.60±1.20 MB/op     Heap Total: 35.24±0.93 MB/op    ArrayBuffers: 18.40±0.98 MB/op