Skip to content

Improve performance of StringUtils#cleanPath#24674

Merged
jhoeller merged 1 commit intospring-projects:masterfrom
dreis2211:stringutils-cleanpath-performance
Mar 23, 2020
Merged

Improve performance of StringUtils#cleanPath#24674
jhoeller merged 1 commit intospring-projects:masterfrom
dreis2211:stringutils-cleanpath-performance

Conversation

@dreis2211
Copy link
Copy Markdown
Contributor

Hi,

I noticed an optimization opportunity in StringUtils#cleanPath while profiling one of our apps. I noticed that a lot of times, strings like file:/Users/christoph.dreis/project/xyz/build/resources/main/META-INF/spring.factories or similar absolute file paths are passed. E.g. in ClassPathResource (which is called 100.000 times in the mentioned app). For those strings we can shortcut a bit earlier and save the overhead from collectionToDelimitedString.

Benchmark                                          Mode  Cnt     Score     Error   Units
MyBenchmark.testNew                               thrpt   10  2188,511 ±  64,208  ops/ms
MyBenchmark.testNew:·gc.alloc.rate                thrpt   10  2561,819 ±  75,078  MB/sec
MyBenchmark.testNew:·gc.alloc.rate.norm           thrpt   10  1536,000 ±   0,001    B/op
MyBenchmark.testNew:·gc.churn.G1_Eden_Space       thrpt   10  2558,410 ± 141,016  MB/sec
MyBenchmark.testNew:·gc.churn.G1_Eden_Space.norm  thrpt   10  1533,735 ±  57,896    B/op
MyBenchmark.testNew:·gc.churn.G1_Old_Gen          thrpt   10     0,002 ±   0,001  MB/sec
MyBenchmark.testNew:·gc.churn.G1_Old_Gen.norm     thrpt   10     0,001 ±   0,001    B/op
MyBenchmark.testNew:·gc.count                     thrpt   10   145,000            counts
MyBenchmark.testNew:·gc.time                      thrpt   10    84,000                ms
MyBenchmark.testOld                               thrpt   10  1345,572 ±  52,746  ops/ms
MyBenchmark.testOld:·gc.alloc.rate                thrpt   10  2264,133 ±  88,387  MB/sec
MyBenchmark.testOld:·gc.alloc.rate.norm           thrpt   10  2208,000 ±   0,001    B/op
MyBenchmark.testOld:·gc.churn.G1_Eden_Space       thrpt   10  2263,917 ± 116,378  MB/sec
MyBenchmark.testOld:·gc.churn.G1_Eden_Space.norm  thrpt   10  2208,212 ± 102,736    B/op
MyBenchmark.testOld:·gc.churn.G1_Old_Gen          thrpt   10     0,003 ±   0,005  MB/sec
MyBenchmark.testOld:·gc.churn.G1_Old_Gen.norm     thrpt   10     0,003 ±   0,005    B/op
MyBenchmark.testOld:·gc.count                     thrpt   10   158,000            counts
MyBenchmark.testOld:·gc.time                      thrpt   10    85,000                ms

Let me know what you think.
Cheers,
Christoph

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 10, 2020
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Mar 11, 2020
@sbrannen sbrannen requested a review from jhoeller March 11, 2020 12:44
@jhoeller jhoeller self-assigned this Mar 23, 2020
@jhoeller jhoeller removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 23, 2020
@jhoeller jhoeller added this to the 5.2.5 milestone Mar 23, 2020
@jhoeller jhoeller merged commit 1c6dda3 into spring-projects:master Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants