Improve Inherited Context Lookup in getConfigResources
Description
This PR improves the performance and clarity of the getConfigResources method in the ModuleDefinitionSet class.
Previously, getConfigResources traversed the entire module hierarchy on each call, redundantly re-computing inherited context resources from parent modules. This change introduces memoization using a configResourcesMap. The result is a more efficient and maintainable implementation, especially as the number of modules grows.
The work builds upon PR #11042, which added unit test coverage for this method. With tests in place, this change now optimizes the implementation while maintaining the same expected behavior.
I’m submitting this PR in draft form to:
- Get feedback on the approach.
- Make sure it aligns with broader architectural expectations.
Types of changes
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [X] Enhancement (improves an existing feature and functionality)
- [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
- [ ] build/CI
- [ ] test (unit or integration test code)
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
- [X] Major
- [ ] Minor
Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [ ] Major
- [ ] Minor
- [ ] Trivial
Screenshots (if appropriate):
How Has This Been Tested?
Verified using the unit tests introduced in PR #11042
How did you try to break this feature and the system with this change?
Verified that duplicate traversal across inherited modules no longer occurs
good initiative @he1l0world , let’s wait till we have #11042 merged with further work on this one. It would be interesting to see if any positive performance impact is given on startup, by this change.
Codecov Report
Attention: Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
Project coverage is 16.57%. Comparing base (
5b7c3b4) to head (7361031).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| .../module/model/impl/DefaultModuleDefinitionSet.java | 94.11% | 0 Missing and 1 partial :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #11048 +/- ##
=========================================
Coverage 16.57% 16.57%
- Complexity 13967 13968 +1
=========================================
Files 5743 5743
Lines 510468 510476 +8
Branches 62073 62073
=========================================
+ Hits 84616 84623 +7
- Misses 416390 416391 +1
Partials 9462 9462
| Flag | Coverage Δ | |
|---|---|---|
| uitests | 3.90% <ø> (ø) |
|
| unittests | 17.47% <94.11%> (+<0.01%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
good initiative @he1l0world , let’s wait till we have #11042 merged with further work on this one. It would be interesting to see if any positive performance impact is given on startup, by this change.
Sure!