matrix-rust-sdk icon indicating copy to clipboard operation
matrix-rust-sdk copied to clipboard

SSS repeatedly re-sends subscriptions on every single /sync request.

Open ara4n opened this issue 6 months ago • 1 comments

While debugging SSS in aurora (EWX test jig), I took a look at the requests in the network debugger. Each HTTP request body on the room-list connection looks like the below - with every single room which the user has most recently subscribed to via roomListService.subscribe() being included, with filter, on the every single long poll request.

This feels like a very significant waste of bandwidth and processing on the server (especially as clients don't typically compress the request body) - in this case an additional 10KB for every response. Surely we should only specify subscriptions when they change, rather than repeat the current new subscriptions on every request.

(See also https://github.com/element-hq/synapse/issues/18517 for another similarly large hunk of bandwidth being wasted in every sync response)

{
  "conn_id": "room-list",
  "txn_id": "d3935ddc39754acb90e715d421ae2975",
  "lists": {
    "all_rooms": {
      "ranges": [
        [
          0,
          152
        ]
      ],
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""]
      ],
      "timeline_limit": 1,
      "filters": {
        "not_room_types": [
          "m.space"
        ]
      }
    }
  },
  "room_subscriptions": {
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    },
    "!roomid:example.com": {
      "required_state": [
        ["m.room.name", ""],
        ["m.room.encryption", ""],
        ["m.room.member", "$LAZY"],
        ["m.room.member", "$ME"],
        ["m.room.topic", ""],
        ["m.room.canonical_alias", ""],
        ["m.room.power_levels", ""],
        ["org.matrix.msc3401.call.member", "*"],
        ["m.room.join_rules", ""],
        ["m.room.tombstone", ""],
        ["m.room.create", ""],
        ["m.room.history_visibility", ""],
        ["io.element.functional_members", ""],
        ["m.room.pinned_events", ""]
      ],
      "timeline_limit": 20
    }
  },
  "extensions": {
    "account_data": {
      "enabled": true
    },
    "receipts": {
      "enabled": true,
      "rooms": [
        "*"
      ]
    },
    "typing": {
      "enabled": true
    }
  }
}

ara4n avatar Jun 05 '25 11:06 ara4n

(I also find myself really questioning whether we've done the right thing by removing sticky params from SS in SSS. The way @kegsay & I originally designed the API was to only send request fields when they change, to avoid repeatedly sending anything in every longpoll request. While this turned out to be error-prone in terms of correctly calculating and applying the deltas, it would have automatically avoided the other problem of sending way too much like, like this)

ara4n avatar Jun 05 '25 11:06 ara4n