[BUG] AbstractShenyuPlugin cache-miss path: stream + ArrayList + Integer-boxing groupingBy + Pair per request
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
## Description
On cache miss, `matchSelector`/`matchRule` do `selectors.stream().filter(...).distinct().collect(Collectors.toList())` (new ArrayList), and `manyMatchSelector` builds `Collectors.groupingBy(Pair::getLeft)` with `Pair.of(sort, selector)` — autoboxing the `int sort` into `Integer` keys in a `Map>>`, plus `Collections.max(collect.keySet())` and a final `stream().map(...).min(...)`.
## Location
```
shenyu-plugin-base/.../AbstractShenyuPlugin.java:229-239 (matchSelector), 241-256 (manyMatchSelector), 268-292 (matchRule/manyMatchRule)
```
## Impact
Per cache-miss: 1 ArrayList + 1 HashMap (with Integer boxing) + N Pair objects. Steady garbage on cache churn (many distinct paths).
## Suggested fix
Replace the stream pipeline with a plain for-loop tracking the max-sort candidate directly; avoid `Pair` and the `Map` boxing.
## Related existing issue(s)
None
_Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in shenyu-plugin-base/.../AbstractShenyuPlugin.java at matchSelector, manyMatchSelector, matchRule, and manyMatchRule, focusing on their cache-miss paths. Trace the current selection and sorting behavior before replacing the stream/grouping logic. Done means the same selector and rule choices are preserved while avoiding the described ArrayList, boxed grouping map, and Pair allocations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100