Skip to content

spring-jdbc : Improve memory allocations when substituting named parameters. [SPR-16170] #20718

@spring-projects-issues

Description

@spring-projects-issues

Benoit opened SPR-16170 and commented

Create the buffer with at least the original sql length to avoid multiple re-allocations
Add a fast path if the original sql doesn't contain any parameters

JMH results

MyBenchmark.old                                                  thrpt   50   429702,315 ±   8526,336   ops/s
MyBenchmark.oldgc.alloc.rate                                   thrpt   50     1089,447 ±     21,757  MB/sec
MyBenchmark.oldgc.alloc.rate.norm                              thrpt   50     3992,001 ±      0,001    B/op
MyBenchmark.oldgc.churn.PS_Eden_Space                          thrpt   50     1102,400 ±     29,500  MB/sec
MyBenchmark.oldgc.churn.PS_Eden_Space.norm                     thrpt   50     4039,513 ±     71,742    B/op
MyBenchmark.oldgc.churn.PS_Survivor_Space                      thrpt   50        0,180 ±      0,027  MB/sec
MyBenchmark.oldgc.churn.PS_Survivor_Space.norm                 thrpt   50        0,659 ±      0,098    B/op
MyBenchmark.oldgc.count                                        thrpt   50      783,000               counts
MyBenchmark.oldgc.time                                         thrpt   50      333,000                   ms
MyBenchmark.newVersion                                           thrpt   50   478496,476 ±   5144,476   ops/s
MyBenchmark.newVersiongc.alloc.rate                            thrpt   50     1008,926 ±     10,849  MB/sec
MyBenchmark.newVersiongc.alloc.rate.norm                       thrpt   50     3320,001 ±      0,001    B/op
MyBenchmark.newVersiongc.churn.PS_Eden_Space                   thrpt   50     1023,339 ±     21,646  MB/sec
MyBenchmark.newVersiongc.churn.PS_Eden_Space.norm              thrpt   50     3368,042 ±     68,881    B/op
MyBenchmark.newVersiongc.churn.PS_Survivor_Space               thrpt   50        0,156 ±      0,033  MB/sec
MyBenchmark.newVersiongc.churn.PS_Survivor_Space.norm          thrpt   50        0,514 ±      0,109    B/op
MyBenchmark.newVersiongc.count                                 thrpt   50      647,000               counts
MyBenchmark.newVersiongc.time                                  thrpt   50      285,000                   ms

MyBenchmark.oldNoParams                                          thrpt   50  1642986,386 ±  47483,217   ops/s
MyBenchmark.oldNoParamsgc.alloc.rate                           thrpt   50     2857,392 ±     82,456  MB/sec
MyBenchmark.oldNoParamsgc.alloc.rate.norm                      thrpt   50     2738,400 ±      3,600    B/op
MyBenchmark.oldNoParamsgc.churn.PS_Eden_Space                  thrpt   50     2893,399 ±     96,256  MB/sec
MyBenchmark.oldNoParamsgc.churn.PS_Eden_Space.norm             thrpt   50     2773,357 ±     51,150    B/op
MyBenchmark.oldNoParamsgc.churn.PS_Survivor_Space              thrpt   50        0,186 ±      0,031  MB/sec
MyBenchmark.oldNoParamsgc.churn.PS_Survivor_Space.norm         thrpt   50        0,178 ±      0,029    B/op
MyBenchmark.oldNoParamsgc.count                                thrpt   50      882,000               counts
MyBenchmark.oldNoParamsgc.time                                 thrpt   50      382,000                   ms
MyBenchmark.newVersionNoParams                                   thrpt   50  2355892,983 ± 107644,968   ops/s
MyBenchmark.newVersionNoParamsgc.alloc.rate                    thrpt   50     2178,567 ±     99,614  MB/sec
MyBenchmark.newVersionNoParamsgc.alloc.rate.norm               thrpt   50     1456,000 ±      0,001    B/op
MyBenchmark.newVersionNoParamsgc.churn.PS_Eden_Space           thrpt   50     2186,719 ±    112,842  MB/sec
MyBenchmark.newVersionNoParamsgc.churn.PS_Eden_Space.norm      thrpt   50     1461,406 ±     35,027    B/op
MyBenchmark.newVersionNoParamsgc.churn.PS_Survivor_Space       thrpt   50        0,179 ±      0,030  MB/sec
MyBenchmark.newVersionNoParamsgc.churn.PS_Survivor_Space.norm  thrpt   50        0,121 ±      0,022    B/op
MyBenchmark.newVersionNoParamsgc.count                         thrpt   50      907,000               counts
MyBenchmark.newVersionNoParamsgc.time                          thrpt   50      401,000                   ms

Affects: 4.3.12, 5.0.1

Referenced from: pull request #1588, and commits 457c70c

Backported to: 4.3.13

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions