Skip to content

Sync Optimizations Report #112

@lamat1111

Description

@lamat1111

The Action Queue we implemented has surfaced some pre-existing sync issues. I'm keeping track here of what I'm doing (minor fixes). I know you want to revamp sync @CassOnMars , so this is to keep you up to speed.

Ref.
In 49c19ae

  • .agents\docs\features\action-queue.md
  • .agents\reports\sync-optimizations_2025-12-19.md

⚠️ AI-Generated: May contain errors. Verify before use.

This report tracks sync-related optimizations implemented in the quorum-desktop codebase. These optimizations improve message delivery latency, throughput, and reliability. The lead dev can review these changes to understand the rationale and decide whether to adopt, modify, or replace them.

Optimizations

1. WebSocket Queue Separation - 002e1a9

The WebSocketProvider.processQueue() function used a single lock (processingRef) for both inbound and outbound message processing. This caused:

  1. Blocking: If inbound handler hangs, outbound messages blocked indefinitely
  2. Artificial latency: Outbound messages wait for all inbound processing to complete
  3. Sequential bottleneck: Independent operations unnecessarily serialized

Before (Sequential):

Inbound processing ────────────────────> Outbound processing ────────>
[━━━━━━━━ 500ms ━━━━━━━━]              [━━━━ 100ms ━━━━]

User action (send DM, edit, profile update) delayed by inbound processing time

Solution

Separate inbound and outbound into independent functions with independent locks:

const inboundProcessingRef = useRef(false);
const outboundProcessingRef = useRef(false);

const processInbound = async () => { /* inbound only */ };
const processOutbound = async () => { /* outbound only */ };

After (Parallel):

Inbound processing ────────────────────>
[━━━━━━━━ 500ms ━━━━━━━━]

Outbound processing ────────>  (starts immediately, no wait)
[━━━━ 100ms ━━━━]

User actions execute immediately

Sync Performance Benefits

Metric Before After
Outbound latency Blocked by inbound Immediate
User action responsiveness Delayed Instant
Throughput during high traffic Sequential Parallel
Reliability Single point of failure Independent failure domains

Verification

  • feature-analyzer agent: Confirmed inbound/outbound are independent
  • No hidden dependencies: WebSocket API send() is thread-safe
  • Ordering preserved: Outbound FIFO maintained

Pre-existing Issue

Bug exists in develop branch since initial commit. Not caused by Action Queue, but Action Queue made it more visible by routing ALL DM sends through enqueueOutbound.


Summary Table

# Optimization Status Impact Risk File
1 WebSocket Queue Separation Pending High Low WebsocketProvider.tsx

For Review

Decision Points

  1. WebSocket Queue Separation: Accept as-is, or prefer different approach?

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions