Repository navigation
SONARJAVA-7189 Do not allocate lambdas on cache hits in JSema - #6362
Conversation
f751daf to
f993886
Compare
Bechmark:To assess the impact of the changes in this PR, a benchmark on a sample project (the core module in jOOQ) analyzed the same 2,127 Java files with identical 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. Warmups were excluded. JFR estimated allocation volume, GC logs measured collection activity, and process sampling tracked CPU and peak RSS. The results below are medians. Results:Adding cache-hit checks before creating lambdas in
GC pause time decreased by 13.5% at 2 GB and 12.1% at 4 GB, while peak RSS remained essentially unchanged. The optimization primarily reduced temporary allocations and collection work. All scans produced identical analysis results, and only |
f993886 to
900fe8b
Compare
900fe8b to
1cab89b
Compare
Code Review ✅ Approved 1 closed / 1 findings🟢 Low risk · These localized JSema cache fast paths avoid lambda allocation on cache hits, with no public interface or semantic-model behavior change indicated. Adds ✅ 1 closed✅ Quality: Initializer-block lookups still allocate a capturing lambda on each hit
Verification Rules 1/1 met PRs 2 inspectedFunctional validation No results Rules 1 passed 2 not applicable
Broader impact PRs 2 inspectedCross-PR 2 PRs inspected 0 open impactsAuto-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
getfast paths beforecomputeIfAbsentintype,typeSymbol,methodSymbol,variableSymbol,annotation, andgetClassTypeinJSematypenow passes the lambda parameterkinstead of capturingtypeBindinggetfast paths inpackageSymbol,initializerBlockSymbol, andstaticInitializerBlockSymbolinJSemakinstead of capturingownerThis will update automatically on new commits.