Reduce POM parsing and resolution allocations - #17
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves performance of Maven POM parsing and effective-model resolution by reducing allocations in hot paths (XML decoding, interpolation, and merge/resolution bookkeeping) while tightening resolver memoization semantics across profile modes and BOM imports.
Changes:
- Introduces a selective XML decoder used by
ParsePOM, with tests validating parity againstencoding/xmldecoding for fixture POMs and error cases. - Replaces regexp-based property interpolation with a scanner-based implementation and extends interpolation tests for additional edge cases.
- Refactors resolver memoization to cache separate effective models for default, pessimistic, and BOM contexts; pre-sizes merger structures using parent-chain-derived capacities; adds offline benchmarks for large/deep resolution scenarios.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| resolver.go | Splits cached models by profile/BOM semantics and reduces merger allocations via capacity planning and lower-overhead dependency profile tracking. |
| resolver_test.go | Adds coverage ensuring cache separation across profile modes and BOM effective models. |
| pom.go | Switches ParsePOM to use the new selective decoder while preserving existing size checks and XML decoder configuration. |
| pom_test.go | Adds parity tests comparing the selective decoder to encoding/xml across fixtures, errors, and nested text behavior. |
| parse.go | Implements the selective XML decoding logic for the subset of POM fields used by the resolver. |
| interpolate.go | Replaces regexp interpolation with a pass-based scanner, including whole-string fast path and capped growth handling. |
| interpolate_test.go | Extends interpolation tests to cover concatenated expressions and malformed/empty-expression edge cases. |
| bench_test.go | Adds benchmarks targeting deep parents, BOM imports, repeated properties, dependency management, and multi-artifact resolver reuse. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reduce CPU time and allocations in POM parsing and effective-model resolution.
This adds a selective XML decoder for fields used by resolution, replaces regexp interpolation with a zero-allocation scanner for common expressions, and reduces temporary maps, slices, and dependency keys during inheritance and BOM merging. Resolver memoization now separates default, pessimistic, and BOM effective models so cached results keep profile semantics.
Adds offline benchmarks covering large POM parsing, deep parents, imported BOMs, repeated properties, dependency management, and multi-artifact resolver reuse.