GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Performance: [#7756 follow-up] Room-broadcast NEW_CHANGES fan-out to drop ~5-7% per-recipient packet construction · Issue #7780 · ether/etherpad Open Labels DescriptionBackgroundCPU profiling against develop (and against #7775 + #7776 stacked, which removes the upstream log4js cost) attributes ~10% of total process CPU at the dive cliff to socket.io's per-recipient packet construction chain inside The fan-out loop today does // src/node/handler/PadMessageHandler.ts:950-1008 exports.updatePadClients = async (pad: PadType) => { const roomSockets = _getRoomSockets(pad.id); // ... await Promise.all(roomSockets.map(async (socket) => { while (sessioninfo.rev < pad.getHeadRevisionNumber()) { // ... build msg ... socket.emit('message', msg); // packet construction per recipient sessioninfo.rev = r; } })); }; In steady state every socket is at `head - 1`, so for N sockets behind by 1 rev that's N packet constructions of essentially identical content. The only per-recipient differing fields in `msg` are `timeDelta` and `currentTime` — and those fields are only consumed by the timeslider (`broadcast.ts`), not the live editor (`collab_client.ts:191-209` reads `{newRev, changeset, author, apool}` and nothing else). The opportunitysocket.io's `room.emit()` / `io.in(roomId).emit()` uses the adapter `broadcast()` path, which calls the encoder once and then loops `writeToEngine` per recipient: // socket.io-adapter/dist/in-memory-adapter.js:112 broadcast(packet, opts) { const encodedPackets = this._encode(packet, packetOpts); // ONCE // ... socket.client.writeToEngine(encodedPackets, packetOpts); // per socket } Switching the steady-state path from `socket.emit` per recipient to `io.in(padId).emit` would collapse N packet constructions into 1. The realistic CPU savings at the dive cliff are 5-7% (some portion of the ~10% socket.io overhead — encoding and packet construction are shared, but the per-socket transport write still happens N times). Why this needs design before implementingNaively swapping `socket.emit` for `io.in(padId).emit` in the loop breaks the catch-up case:
Two viable shapes: Shape A — split steady-state from catch-up.
Shape B — push catch-up out of `updatePadClients`.
I'd favour Shape A as a first cut — local change, no protocol additions, the straggler-tracking is cheap (`sessioninfo.rev !== headBefore` check per socket once per fan-out). Acceptance
Out of scope
Discovered as part of the #7756 scaling dive (dive doc PR #7765). Activity
MetadataMetadataAssigneesLabelsTypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |