Aias00 opened a new issue, #7836:
URL: https://github.com/apache/shenyu/issues/7836
## Goal
Reduce intermediate JSON trees/maps, strings and repeated parsing while
receiving large gateway configuration messages. Keep the existing data contract
and sync correctness; this is separate from trimming payload fields in #7832.
## Current processing
The receiver currently follows:
```text
frame JSON
-> raw WebsocketData / generic data objects
-> data serialized back to JSON
-> event fingerprint
-> concrete typed DTO list parsed from JSON
```
-
[ShenyuWebsocketClient.handleResult:440–474](https://github.com/apache/shenyu/blob/04f7c2e8b7d282f14510157a9ab0bfaab538ecac/shenyu-sync-data-center/shenyu-sync-data-websocket/src/main/java/org/apache/shenyu/plugin/sync/data/websocket/client/ShenyuWebsocketClient.java#L440-L474)
first calls fromJson(result, WebsocketData.class), then
toJson(websocketData.getData()).
-
[AbstractDataHandler.handle:84–102](https://github.com/apache/shenyu/blob/04f7c2e8b7d282f14510157a9ab0bfaab538ecac/shenyu-sync-data-center/shenyu-sync-data-websocket/src/main/java/org/apache/shenyu/plugin/sync/data/websocket/handler/AbstractDataHandler.java#L84-L102)
converts that JSON into the group-specific list.
-
[WebsocketDataHandler:82–93](https://github.com/apache/shenyu/blob/04f7c2e8b7d282f14510157a9ab0bfaab538ecac/shenyu-sync-data-center/shenyu-sync-data-websocket/src/main/java/org/apache/shenyu/plugin/sync/data/websocket/handler/WebsocketDataHandler.java#L82-L93)
also constructs an eventType+JSON fingerprint input and hashes the complete
payload.
- handleResult computes result.getBytes(UTF_8).length solely for its INFO
size diagnostic, allocating a complete byte array even when the INFO call is
disabled.
## Scope and acceptance
- [ ] Parse the envelope once and adapt its data directly to the group's
typed representation, e.g. via an existing JSON element/type adapter; avoid a
generic-object -> JSON-string -> typed-object round trip.
- [ ] Preserve group/event validation, namespace isolation, fullSnapshot and
authoritative empty arrays, legacy MYSELF handling, initial-sync
completion/failure state, and exception/reconnect behavior.
- [ ] Keep duplicate suppression correct across event types. If fingerprint
input representation changes, specify equivalence and test field order,
whitespace, numeric/string values, UPDATE/DELETE/MYSELF, snapshots and
reconnect. Do not simply remove deduplication or hash only a subset of the
identity.
- [ ] Avoid full-size byte-array allocation solely for disabled diagnostics;
retain honest UTF-8 byte-size semantics if the log still says bytes.
String.length() is not an equivalent byte count.
- [ ] Cover malformed input, all supported groups, timestamp/number fidelity
and plugin handler callbacks with round-trip/regression tests.
- [ ] Compare 1k/10k+ configuration messages, unchanged repeats, incremental
events and realistic large handles; measure deserialize/dispatch time,
allocation and peak heap independently of #7832's field projection.
## Related work
#7832 changes which fields are transmitted; this task changes how the
received representation is processed. #7645 owns batching while applying DTOs
to caches. Neither requires this repeated JSON conversion.
## 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]