Repository navigation
SONARJAVA-7182 Replace frequently allocated streams with loops - #6349
Conversation
Bechmark:To assess the impact of the changes in this PR, a benchmark was run on a sample project (the core module in jOOQ, 2,217 Java files) before and after the changes. The benchmark repeatedly analyzed the same 2,127 jOOQ Java files with unchanged rules and settings. Each version had ten measured scans at both 2 GB and 4 GB heaps, using fresh JVMs, plus three separate 4 GB Java Flight Recorder allocation profiles. JFR estimated allocated bytes by object class and call stack; GC logs measured collection activity and heap occupancy, while process sampling measured CPU and peak RSS. Results below are medians, and allocation volume represents cumulative traffic rather than retained memory. Results:Replacing Streams with loops in
Both modified methods had zero sampled Stream allocations after replacement. GC pause counts fell by approximately 8%, but total pause time and peak RSS changed little. The clearest improvement was lower allocation volume, rather than lower peak memory or a reliably established speedup. Both versions produced identical analysis results. |
9c68953 to
fb155dc
Compare
Code Review ✅ Approved🟢 Low risk · Replacing two stream pipelines with equivalent loops is narrowly scoped and reduces allocation without changing matching or override-selection behavior. Replaces stream-based Verification Rules 2/2 metFunctional validation No results Rules 2 passed 1 not applicable
Auto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|




Summary by Gitar
anyMatchcalls inMethodMatchersListwith a loop-basedmatchesAnyhelperStream.ofpipeline inJMethodSymbol.findOverridesInTypeswith a for loop that breaks on first matchThis will update automatically on new commits.