Skip to content

Performance Optimization on getResultSetValue#773

Closed
DR9885 wants to merge 1 commit into
spring-projects:masterfrom
DR9885:patch-1
Closed

Performance Optimization on getResultSetValue#773
DR9885 wants to merge 1 commit into
spring-projects:masterfrom
DR9885:patch-1

Conversation

@DR9885

@DR9885 DR9885 commented Apr 9, 2015

Copy link
Copy Markdown

Performance Optimization, using ".equals" is signifigantly slower than "==".

When using "BeanPropertyRowMapper", we ran load tests and found significant lack of performance when calling "getColumnValue". I noticed that "getColumnValue" simply just calls "JdbcUtils.getResultSetValue". These tests were run on an table with roughly 70 columns.

After making change I ran three tests

  1. with existing BeanPropertyRowMapper
  2. with optimized BeanPropertyRowMapper
  3. with a Custom RowMapper, mapped exactly to the class.

Benchmark Results

  1. round: 0.38 [+- 0.11], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 1, GC.time: 0.01, time.total: 7.98, time.warmup: 0.28, time.bench: 7.70
  2. round: 0.23 [+- 0.02], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 0, GC.time: 0.00, time.total: 4.80, time.warmup: 0.22, time.bench: 4.58
  3. round: 0.22 [+- 0.02], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 0, GC.time: 0.00, time.total: 4.62, time.warmup: 0.19, time.bench: 4.43

As you can see the optimized version makes BeanPropertyRowMapper almost as fast as a custom made RowMapper.

Performance Optimization, using ".equals" is signifigantly slower than "==". 

When using "BeanPropertyRowMapper", we ran load tests and found significant lack of performance when calling "getColumnValue". I noticed that "getColumnValue" simply just calls "JdbcUtils.getResultSetValue". These tests were run on an table with roughly 70 columns.

After making change I ran three tests
1) with existing BeanPropertyRowMapper
2) with optimized BeanPropertyRowMapper
3) with a Custom RowMapper, mapped exactly to the class.

Benchmark Results
=============
1) round: 0.38 [+- 0.11], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 1, GC.time: 0.01, time.total: 7.98, time.warmup: 0.28, time.bench: 7.70
2) round: 0.23 [+- 0.02], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 0, GC.time: 0.00, time.total: 4.80, time.warmup: 0.22, time.bench: 4.58
3) round: 0.22 [+- 0.02], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 0, GC.time: 0.00, time.total: 4.62, time.warmup: 0.19, time.bench: 4.43

As you can see the optimized version makes BeanPropertyRowMapper almost as fast as a custom made RowMapper.
@jhoeller

Copy link
Copy Markdown
Contributor

Could you please create a JIRA issue for this one? We have quite a few equals comparisons between Class references in the codebase, so this might be worth revisiting on a wider scale. In any case, a JIRA issue will make sure it doesn't get lost...

Juergen

@DR9885

DR9885 commented Apr 17, 2015

Copy link
Copy Markdown
Author

Opened a Ticket: https://jira.spring.io/browse/SPR-12926

@panchenko

Copy link
Copy Markdown
Contributor

This PR can be closed, as the corresponding change was performed for the whole codebase in b4095c3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants