BobSong-dev opened a new pull request, #7345:
URL: https://github.com/apache/shenyu/pull/7345

   Fixes #6796
   
   ## Background
   
   `BaseDataCache.selectorAccept`/`ruleAccept` rebuild and re-sort the whole 
per-plugin (or
   per-selector) list on every single event. 
`refreshSelectorData`/`refreshRuleData` process
   batch refreshes element by element through the same path, so a refresh of N 
selectors under
   one plugin costs O(N²) removals plus O(N² log N) re-sorts on the sync thread 
and delays all
   other configuration propagation (startup `MYSELF` resync sends the whole 
dataset in one batch).
   
   ## Changes
   
   - Extract a shared `upsertSorted` merge (remove same-id entries, append, 
sort once, return an
     immutable copy); the single-update path uses it with a one-element batch, 
which is
     semantically identical to the previous per-event code;
   - Batch refreshes are grouped per key (plugin name / selector id), so each 
key's list is
     merged and sorted exactly once — a batch of N entries now costs one O(n 
log n) sort per
     affected key instead of N of them;
   - Readers still receive immutable snapshots, and the map swap stays atomic, 
so concurrent
     readers never observe partially refreshed data (existing tests assert 
this).
   
   ## Verification
   
   Local:
   - `./mvnw test -pl shenyu-plugin/shenyu-plugin-base -am`: BUILD SUCCESS; 
Tests run: 133,
     Failures: 0 (BaseDataCacheTest 24 tests, including a new out-of-order 
batch upsert test and
     the existing atomicity/immutability tests unchanged);
   - `./mvnw checkstyle:check`: passed.


-- 
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