You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The resource resolver in DevTools can cause performance degradation
during application restarts in large projects. Key methods like
isDeleted() and getAdditionalResources() rely on nested loops, leading
to O(n*m) complexity.
This commit refactors ClassLoaderFiles to use a pre-computed, flattened
map. This provides O(1) complexity for direct lookups and allows for
efficient single-loop iteration.
The ClassLoaderFilesResourcePatternResolver is updated to leverage this
new, efficient structure:
- getFile() and size() are improved from O(n) to O(1).
- isDeleted() and getAdditionalResources() are improved from O(n*m) to
O(m) by eliminating nested loops.
- Data consistency is maintained across all operations.
This optimization significantly improves restart performance with a
minimal memory footprint, while preserving the existing API and
exception handling behavior.
See gh-46289
Signed-off-by: DongHoon Lee <[email protected]>
Copy file name to clipboardExpand all lines: module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ClassLoaderFilesResourcePatternResolver.java
Copy file name to clipboardExpand all lines: module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFiles.java
+22-13Lines changed: 22 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -46,11 +46,18 @@ public class ClassLoaderFiles implements ClassLoaderFileRepository, Serializable
0 commit comments