Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(replay): More efficient deserialization (#1782)
After deploying #1678, we saw a rise in memory consumption. We narrowed down the reason to deserialization of replay recordings, so this PR attempts to replace those deserializers with more efficient versions that do not parse an entire `serde_json::Value` to get the tag (`type`, `source`) of the enum. A custom deserializer is necessary because serde does not support [integer tags for internally tagged enums](serde-rs/serde#745). - [x] Custom deserializer for `NodeVariant`, based on serde's own `derive(Deserialize)` of internally tagged enums. - [x] Custom deserializer for `recording::Event`, based on serde's own `derive(Deserialize)` of internally tagged enums. - [x] Custom deserializer for `IncrementalSourceDataVariant`, based on serde's own `derive(Deserialize)` of internally tagged enums. - [x] Box all enum variants. ### Benchmark comparison Ran a criterion benchmark on `rrweb.json`. It does not tell us anything about memory consumption, but the reduced cpu usage points to simpler deserialization: #### Before ``` rrweb/1 time: [142.37 ms 148.17 ms 155.61 ms] ``` #### After ``` rrweb/1 time: [31.474 ms 31.801 ms 32.137 ms] ``` #skip-changelog --------- Co-authored-by: Colton Allen <[email protected]> Co-authored-by: Oleksandr <[email protected]>
- Loading branch information