Aias00 opened a new issue, #7840:
URL: https://github.com/apache/shenyu/issues/7840

   ## Goal
   
   Reduce repeated whole-snapshot serialization, concatenation and reparsing 
during an enabled WebSocket reconciliation cycle, while preserving 
deterministic change detection and authoritative replacement.
   
   ## Current processing
   
   
[WebsocketDataReconciler.reconcileGroup():204–224](https://github.com/apache/shenyu/blob/04f7c2e8b7d282f14510157a9ab0bfaab538ecac/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/websocket/WebsocketDataReconciler.java#L204-L224)
 currently performs:
   
   ```text
   load DTOs
    -> serialize every row to String
    -> sort row JSON strings
    -> concatenate all rows into another String for MD5
    -> if changed, parse every row back into JsonElement
    -> serialize the complete WebsocketData again
   ```
   
   Unchanged cycles still pay the load, per-row serialization, sort and large 
concatenated digest-input cost. Changed cycles add reparsing and final 
serialization. Reconciliation is opt-in; this task does not claim the disabled 
default performs this work. The existing active-namespace and master-only 
restrictions are useful and should be retained.
   
   ## Scope and acceptance
   
   - [ ] Profile unchanged and changed cycles for realistic 1k/10k+ 
PLUGIN/SELECTOR/RULE groups with small and large handles; measure CPU, 
allocation, peak heap, DB reads, tick duration and business p99 disturbance.
   - [ ] Evaluate reusing a canonical row/tree representation for digest and 
outgoing payload instead of serializing then reparsing each row. Avoid 
retaining more intermediate forms than the current approach.
   - [ ] Evaluate incremental/streaming MessageDigest updates to avoid 
String.join of the entire snapshot. Preserve delimiter/order semantics or 
explicitly test/document a compatible digest migration.
   - [ ] Preserve deterministic ordering and detection of row additions, 
deletions and field changes; do not replace the digest with an unsafe shortcut 
such as max(dateUpdated) that misses deletions or out-of-band changes.
   - [ ] Preserve namespace/master gating, fullSnapshot metadata, authoritative 
empty data, failure retry and advancing the digest cursor only after the 
applicable publication outcome.
   - [ ] Preserve reconciliation as a recovery mechanism for missed 
events/shared-DB changes. A cached last-seen event version alone is not an 
equivalent authoritative check.
   - [ ] Run unchanged-order/changed-order equivalence, empty snapshot, 
serialization failure and publication failure regressions. Retain only a 
measured improvement with correct final gateway state.
   
   ## Related work
   
   #7356 introduced shared-database convergence work. #7645 owns how gateways 
apply snapshots, #7832 owns field projection, and the receive-side JSON 
round-trip optimization is a separate stage. Benchmark these independently so a 
smaller payload does not hide redundant reconciliation processing.
   
   ## Baseline and validation boundary
   
   Reviewed Apache ShenYu `2.7.2-SNAPSHOT`, master 
`04f7c2e8b7d282f14510157a9ab0bfaab538ecac`. Source inspection confirms the 
processing described here; no before/after load benchmark has been run and no 
fixed performance gain is claimed. Use #7650's reproducible benchmark contract: 
warm JVM, identical configuration/resources, controlled payload shapes, 
repeated runs, CPU/allocation/GC, synchronization convergence and 
business-request p99 during sync. No new production dependency is required for 
this proposal.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to