Skip to content

Instantly share code, notes, and snippets.

@macobo
Created December 3, 2020 22:11
Show Gist options
  • Select an option

  • Save macobo/2706dac8f248c7664aba53a46f156c98 to your computer and use it in GitHub Desktop.

Select an option

Save macobo/2706dac8f248c7664aba53a46f156c98 to your computer and use it in GitHub Desktop.
Did some measurements on deflate:
For session recording:
- Current batches:
In general: deflate for /s was hovering between 18-25% data size, lz64 ~45-55%
Packing individual events hovered at around 23-27% of data size.
/s
deflate: 0.19086889535248105
lz64: 0.4443071067359241
raw:
deflate: 351015
lz64: 816548
normal: 1836024
requests: 60
/e
deflate: 0.24228434504792332
lz64: 0.6569968051118211
raw:
deflate: 15167
lz64: 41128
normal: 62600
requests: 17
Packing individual session recording events:
count: 287
normal: 1756870
packed: 362231
ratio: 0.20617974010598394
- When turning batching up to every 3 seconds:
/s
deflate: 0.22700383133167518
lz64: 0.5097736813031202
raw:
deflate: 243675
lz64: 547548
normal: 1072595
requests: 8
/e
deflate: 0.11431390879817181
lz64: 0.5046224161213254
raw:
deflate: 4402
lz64: 19432
normal: 38508
requests: 4
Advantage of individual compression: No need to do any backend changes. Can inflate again in the frontend.
Performance measurements:
500kb (posthog.com full snapshot):
- lzstring: 3.98 ops/s +- 2.8%
- pako.deflate: 16.39ops/s +- 8.56%
3kb request (normal /s events, /e)
- lzstring: 165.39 ops/s +- 16.5%
- pako.deflate: 1942.16 ops/s +- 3.75%
300b request (single /e)
- lzstring: 2830.78 ops/s +- 11.84%
- pako.deflate: 2476.65 ops/s +- 6.8%
Note: For some reason our bundled version of lzstring is much slower than the one on cdnjs - did not dig into why.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment