HomePhabricator

[Chronik] Deduplicate indentical consecutive WebSocket messages

Description

[Chronik] Deduplicate indentical consecutive WebSocket messages

Summary:
Currently, if a WS client subscribed to multiple scripts / token IDs and then a tx is received that matches the scripts / token IDs multiple times, it would be send to the WS client multiple times.

This is almost never what the user expects, and wastes bandwidth, especially for HD wallets that subscribe to many addresses.

We add a simple deduplication by keeping track of the last binary WS message sent to a WS client, and skipping sending the msg if the last msg is identical, in binary encoding.

Note that we have to match only to Binary messages because otherwise we would deduplicate pings, which is not what we want.

The implementation here still wastes some compute resources by building & serializing etc. the msg in the first place; however, the way the subscription system is designed makes it very difficult to deduplicate messages earlier. This solution here is extremely simple, memory friendly and easy to maintain.

Depends on D15389.

Test Plan: ninja check-functional

Reviewers: Fabien, #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D15390

Details

Provenance
tobias_ruckAuthored on Feb 12 2024, 12:13
tobias_ruckPushed on Feb 12 2024, 13:21
Reviewer
Restricted Project
Differential Revision
D15390: [Chronik] Deduplicate indentical consecutive WebSocket messages
Parents
rABC1d7770150082: Fix permission on numerous files.
Branches
Unknown
Tags
Unknown