-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: enhancementA general enhancementA general enhancement
Milestone
Description
UrlResource computes a cleanedUrl in its constructor, but only uses it in a small number of methods (e.g. hashCode()). It has some String manipulations in it that can be expensive, so it might make sense to compute it lazily.
Some benchmarks (instantiate a FileUrlResource and check if it exists()):
class method median mean range
com.example.bench.ResourceBenchmark lazy 441889.554 460384.372 16671.778
com.example.bench.ResourceBenchmark default 415765.658 440910.870 18462.893
I think the fact that the median comparison is much more dramatic is probably because of garbage collection, which is quite noisy, and would be more common in the default case.
Spring Boot computes quite a few of these FileUrlResources on startup as it searches for application.properties files. The difference is just about noticeable (a few milliseconds on startup, and fewer GC failures).
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: enhancementA general enhancementA general enhancement