gnodet opened a new pull request, #13031:
URL: https://github.com/apache/maven/pull/13031

   ## Summary
   
   Two targeted hot path optimizations identified by JFR profiling on a 
4,383-module reactor:
   
   ### 1. `computeLocations()` optimization (model.vm)
   - Replace `Stream.concat().collect(Collectors.toUnmodifiableMap(...))` with 
`HashMap.putAll()` + `Map.copyOf()`
   - Return `oldlocs` directly when `newlocs` is empty (avoids unnecessary 
`Map.copyOf` since the base locations map is already immutable)
   - Reduces `KeyValueHolder` allocations from stream-based map construction
   
   ### 2. `ModelObjectPool.PoolKey` location comparison optimization
   - **Precomputed `locationsHashCode`**: cached at build time in generated 
model constructors, used by `PoolKey` for fast inequality checks before full 
map comparison
   - **Direct map equality**: `getLocations().equals()` replaces per-key 
iteration through `getLocationKeys()` + `getLocation(key)`, avoiding 
`KeyValueHolder` allocations
   - **Empty-map fast path**: short-circuits when both maps are empty (common 
for imported dependencies)
   - Removes redundant `getLocationKeys()` equality check (now subsumed by map 
equality)
   
   ### What was dropped from #12653
   
   The original PR (#12653) also included Builder getters, `*ToBuilder` merger 
variants, deferred `build()` in `DefaultDependencyManagementInjector`, and 
Velocity template changes for list-of-model-object builders. Benchmarks on both 
a 4,383-module diamond reactor and a 256-module BOM stress project (230 managed 
deps, 3-6 BOM imports/module) showed no measurable improvement from those 
changes on Apple M4 Pro / JDK 21. This PR retains only the low-risk, targeted 
optimizations.
   
   ## Test plan
   
   - [x] `mvn verify -B` (all existing tests)
   - Changes are limited to generated code patterns (`model.vm`) and the object 
pool (`DefaultModelObjectPool`)
   


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