SlideShare a Scribd company logo
Detecting Performance Anti-patterns for
Applications Developed Using
Object-Relational Mapping
1
Mohamed Nasser, Parminder Flora
Tse-Hsun(Peter) Chen Ahmed E. HassanWeiyi Shang Zhen Ming Jiang
Databases are essential in large-scale
software systems
2
Database
3
Application developers work with objects
More intuitive if we can
map objects directly to DB
4
Object-Relational Mapping eliminates
the gap between objects and SQL
Database
• Lots of boilerplate code
• Need to manage object-DB
translations manually
Object
Classes
Problem of using raw SQLs
ORM
Much less code and shorter
development time
ORM is widely used in practice
5
• Java Hibernate has more than 8
million downloads
• In 2013, 15% of the 17,000 Java
developer jobs require ORM
experience (dice.com)
Different ORM technologies
An example class with ORM code
6
@Entity
@Table(name = “user”)
public class User{
@Column(name=“id”)
private int id;
@Column(name=“name”)
String userName;
@OneToMany(fetch=FetchType.EAGER)
List<Team> teams;
public void setName(String n){
userName = n
}
… other getter and setter methods
User.javaUser class is
mapped to “user”
table in DB
id is mapped to the
column “id” in the
user table
A user can belong
to multiple teams
Eagerly retrieve
associated teams
when retrieving a
user object
Accessing the database using ORM
7
User u = findUserByID(1);
ORM
database
select u from user
where u.id = 1;
u.setName(“Peter”);
update user set
name=“Peter”
where user.id = 1;
Objects SQLs
Developers may not be aware of
database access
Wow! I don’t
need to worry
about DB code!
ORM code with
performance anti-patterns
8
Bad system
performance
The performance difference can be LARGE!
Performance anti-pattern
detection framework
Performance anti-pattern detection and
ranking framework
Ranked according to
performance impact
Ranked
Performance
anti-patterns
Source
Code
detection
ranking
9
Performance anti-pattern
detection framework
Performance anti-pattern detection and
ranking framework
Ranked according to
performance impact
Ranked
Performance
anti-patterns
Source
Code
detection
ranking
10
Discuss only one anti-pattern
in the presentation
(more patterns in the paper)
ORM excessive data anti-pattern
Class User{
@EAGER
List<Team> teams;
}
User u = findUserById(1);
u.getName();
EOF
11
Objects
SQL
Eagerly retrieve
teams from DB
User Table Team Table
join Team data is never
used!
Detecting excessive data
using static analysis
12
First find all the objects that
eagerly retrieve data from DB
Class User{
@EAGER
List<Team> teams;
}
Identify all the data usages of
objects
User user = findUserByID(1);
Check if the retrieved data is ever
used
user.getName();
user team
user team
Performance anti-pattern
detection framework
Performance anti-pattern detection and
ranking framework
Ranked according to
performance impact
Ranked
Performance
anti-patterns
Source
Code
detection
ranking
13
Performance anti-pattern
detection framework
Performance anti-pattern detection and
ranking framework
Ranked according to
performance impact
Ranked
Performance
anti-patterns
Source
Code
detection
ranking
14
Performance anti-patterns have
different impacts
15
User user_in_1_team = findUserByID(1);
Retrieving 1 user and 1 team
User user_in_100_teams = findUserByID(100);
Retrieving 1 user and 100 teams!
One can only reveal performance
impact by execution
Measuring the impact using repeated
measurements and effect sizes
16
We use effect sizes (Cohen’s D) to measure
the performance impact
Effect sizes =
We repeat each test 30 times to obtain stable
measurement results
Size of performance impact is not defined:
Performance measurements are unstable:
Studied systems and detection results
Large open-source
e-commence system
> 1,700 files
> 206K LOC
Enterprise system
> 3,000 files
> 300K LOC
Spring open-source system
Online system for a pet clinic
51 files
3.3K LOC
482 excessive data > 10 excessive data 10 excessive data
17
Performance impact
Research questions
Ranks of the anti-patterns at
different scales
18
Performance impact
Research questions
Ranks of the anti-patterns at
different scales
19
Assessing anti-pattern impact by
fixing the anti-patterns
Execution
Response timeuser.getName()
Code with
anti-patterns
fetchType.set(LAZY)
user.getName()
Code without
anti-patterns
20
Execute test
suite 30 times
Response time
after fixing the
anti-patterns
Avg. %
improvement and
effect sizes
Execution
Execute test
suite 30 times
Performance anti-patterns have
medium to large effect sizes
0%
20%
40%
60%
80%
100%
Excessive Data
BL
EA
PC
21
%improvementinresponsetime
large
effect size
large
effect size medium
effect size
Performance impact
Research questions
Ranks of the anti-patterns at
different scales
22
Removing anti-pattern
improves response by ~35%
Performance impact
Research questions
Ranks of the anti-patterns at
different scales
23
Removing anti-pattern
improves response by ~35%
Performance problems usually arise
under large load
24
Performance problems revealed at
small scales may be more serious
25
We should first fix the anti-patterns that
have larger effects at smaller scales
Input scales may have
exponential effects on
performance
Different input scales Performance at
different input scales
Comparing ranked anti-patterns at
different data scales
26
Ranked
Performance
anti-patterns
from small data
detection
ranking
Ranked
Performance
anti-patterns
from large data
?
Small size input
Large size input
Anti-patterns have large effects on
performance even at smaller data scales
27
0
10
20
30
40
50
0
1
2
3
4
5
Effectsize
Effect sizes and the ranks of the anti-patterns
are consistent in different data scales
Performance impact
Research questions
Ranks of the anti-patterns at
different scales
28
Removing anti-pattern
improves response by ~35%
Ranks of the anti-patterns
are consistent in different
data scales
29
30
31
32
33
tsehsun@cs.queensu.ca

More Related Content

PPTX
TSE 2016 - Finding and Evaluating the Performance Impact of Redundant Data Ac...
PPTX
ICSE2017 - Analytics Driven Load Testing: An Industrial Experience Report on ...
PPTX
Improving the Performance of Database-Centric Applications Through Program An...
PPTX
CSER2016 - Detecting Problems in Database Access Code of Large Scale Systems
PDF
Icse2018 autonomic
PPTX
MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational...
PPTX
ICSE2016 - Detecting Problems in Database Access Code of Large Scale Systems ...
PPTX
FSE2016 - CacheOptimizer: Helping Developers Configure Caching Frameworks for...
TSE 2016 - Finding and Evaluating the Performance Impact of Redundant Data Ac...
ICSE2017 - Analytics Driven Load Testing: An Industrial Experience Report on ...
Improving the Performance of Database-Centric Applications Through Program An...
CSER2016 - Detecting Problems in Database Access Code of Large Scale Systems
Icse2018 autonomic
MSR2016 - An Empirical Study on the Practice of Maintaining Object-Relational...
ICSE2016 - Detecting Problems in Database Access Code of Large Scale Systems ...
FSE2016 - CacheOptimizer: Helping Developers Configure Caching Frameworks for...

What's hot (20)

PPTX
Icse2014 v3
PPTX
iPerfDetector: Characterizing and Detecting Performance Anti-patterns in iOS ...
PPTX
Testclass [Autosaved]
PDF
Software Mining and Software Datasets
PDF
Software Analytics: Towards Software Mining that Matters
PPTX
Automating the process of continuously prioritising data, updating and deploy...
PPTX
Certification preparation - Error Handling and Troubleshooting recap.pptx
PDF
.Net Classes and Objects | UiPath Community
PPTX
Certification preparation - Net classses and functions.pptx
PPTX
Automatically Build Solr Synonyms List using Machine Learning - Chao Han, Luc...
PDF
Automated parameter optimization should be included in future 
defect predict...
PPT
Henk Doornbos & Rix Groenboom - Test Patterns: A New Concept For Testing
PPTX
Scenario $4$
PDF
Software Analytics: Data Analytics for Software Engineering
PPTX
Best Great Ideas on Java Research Papers
PDF
Making solubility models with reaxy
PPTX
How accurate are the Wearable fitness tracker showing 10000 steps in a day: A...
DOCX
efficient prediction of difficult keyword queries over databases
PDF
professional fuzzy type-ahead rummage around in xml type-ahead search techni...
PDF
NEXT- A System for Real-World Development, Evaluation, and Application of Act...
Icse2014 v3
iPerfDetector: Characterizing and Detecting Performance Anti-patterns in iOS ...
Testclass [Autosaved]
Software Mining and Software Datasets
Software Analytics: Towards Software Mining that Matters
Automating the process of continuously prioritising data, updating and deploy...
Certification preparation - Error Handling and Troubleshooting recap.pptx
.Net Classes and Objects | UiPath Community
Certification preparation - Net classses and functions.pptx
Automatically Build Solr Synonyms List using Machine Learning - Chao Han, Luc...
Automated parameter optimization should be included in future 
defect predict...
Henk Doornbos & Rix Groenboom - Test Patterns: A New Concept For Testing
Scenario $4$
Software Analytics: Data Analytics for Software Engineering
Best Great Ideas on Java Research Papers
Making solubility models with reaxy
How accurate are the Wearable fitness tracker showing 10000 steps in a day: A...
efficient prediction of difficult keyword queries over databases
professional fuzzy type-ahead rummage around in xml type-ahead search techni...
NEXT- A System for Real-World Development, Evaluation, and Application of Act...
Ad

Viewers also liked (12)

PDF
5 Anti-Patterns in Api Design - buildstuff
PPTX
Patterns and Antipatterns for Adopting IBM DevOps Tools
PPTX
APIs: the Glue of Cloud Computing
PDF
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
PDF
Using Spark and Riak for IoT Apps—Patterns and Anti-Patterns: Spark Summit Ea...
PDF
WS-* vs. RESTful Services
PPT
Antipatrones de Software
PDF
Anti patrones
PPTX
Antipatrones de desarrollo de software
PDF
ICSE2014
PDF
Opensouthcode: Microservicios sobre MEAN Stack
KEY
Api anti patterns
5 Anti-Patterns in Api Design - buildstuff
Patterns and Antipatterns for Adopting IBM DevOps Tools
APIs: the Glue of Cloud Computing
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Using Spark and Riak for IoT Apps—Patterns and Anti-Patterns: Spark Summit Ea...
WS-* vs. RESTful Services
Antipatrones de Software
Anti patrones
Antipatrones de desarrollo de software
ICSE2014
Opensouthcode: Microservicios sobre MEAN Stack
Api anti patterns
Ad

Similar to ICSE2014 - Detecting Performance Anti-patterns for Applications Developed using Object-Relational Mapping (20)

PPTX
Mechanisms for Database Intrusion Detection and Response
PPTX
Software Defect Prediction on Unlabeled Datasets
PPTX
Improving the quality of large scale database-centric software systems by ana...
PPTX
Improving the quality of large scale database-centric software systems by ana...
PPTX
ICDE2015PhD - Improving the Quality of Large-Scale Database-Centric Software ...
PDF
"Быстрое обнаружение вредоносного ПО для Android с помощью машинного обучения...
PDF
Fast detection of Android malware: machine learning approach
PPT
Getting Unstuck: Working with Legacy Code and Data
PPTX
Top TCS Interview Questions And Answers | How to Crack An Interview At TCS | ...
PDF
What are the Unique Challenges and Opportunities in Systems for ML?
PPTX
Test data generation
PPTX
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
PDF
Agile_goa_2013_clean_code_tdd
PPTX
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
PDF
Data Management for Quantitative Biology - Database Systems (continued) LIMS ...
ODP
Effective unit testing
PPTX
STRICT: Information Retrieval Based Search Term Identification for Concept Lo...
DOCX
Latest .Net Questions and Answers
PPT
Dev411
PPT
B2 2005 introduction_load_testing_blackboard_primer_draft
Mechanisms for Database Intrusion Detection and Response
Software Defect Prediction on Unlabeled Datasets
Improving the quality of large scale database-centric software systems by ana...
Improving the quality of large scale database-centric software systems by ana...
ICDE2015PhD - Improving the Quality of Large-Scale Database-Centric Software ...
"Быстрое обнаружение вредоносного ПО для Android с помощью машинного обучения...
Fast detection of Android malware: machine learning approach
Getting Unstuck: Working with Legacy Code and Data
Top TCS Interview Questions And Answers | How to Crack An Interview At TCS | ...
What are the Unique Challenges and Opportunities in Systems for ML?
Test data generation
52 - The Impact of Test Ownership and Team Structure on the Reliability and E...
Agile_goa_2013_clean_code_tdd
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
Data Management for Quantitative Biology - Database Systems (continued) LIMS ...
Effective unit testing
STRICT: Information Retrieval Based Search Term Identification for Concept Lo...
Latest .Net Questions and Answers
Dev411
B2 2005 introduction_load_testing_blackboard_primer_draft

Recently uploaded (20)

PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
ai tools demonstartion for schools and inter college
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
System and Network Administration Chapter 2
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
medical staffing services at VALiNTRY
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
top salesforce developer skills in 2025.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Design an Analysis of Algorithms I-SECS-1021-03
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
VVF-Customer-Presentation2025-Ver1.9.pptx
ai tools demonstartion for schools and inter college
2025 Textile ERP Trends: SAP, Odoo & Oracle
System and Network Administration Chapter 2
Design an Analysis of Algorithms II-SECS-1021-03
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Reimagine Home Health with the Power of Agentic AI​
medical staffing services at VALiNTRY
Which alternative to Crystal Reports is best for small or large businesses.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Wondershare Filmora 15 Crack With Activation Key [2025
top salesforce developer skills in 2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Softaken Excel to vCard Converter Software.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf

ICSE2014 - Detecting Performance Anti-patterns for Applications Developed using Object-Relational Mapping

  • 1. Detecting Performance Anti-patterns for Applications Developed Using Object-Relational Mapping 1 Mohamed Nasser, Parminder Flora Tse-Hsun(Peter) Chen Ahmed E. HassanWeiyi Shang Zhen Ming Jiang
  • 2. Databases are essential in large-scale software systems 2 Database
  • 3. 3 Application developers work with objects More intuitive if we can map objects directly to DB
  • 4. 4 Object-Relational Mapping eliminates the gap between objects and SQL Database • Lots of boilerplate code • Need to manage object-DB translations manually Object Classes Problem of using raw SQLs ORM Much less code and shorter development time
  • 5. ORM is widely used in practice 5 • Java Hibernate has more than 8 million downloads • In 2013, 15% of the 17,000 Java developer jobs require ORM experience (dice.com) Different ORM technologies
  • 6. An example class with ORM code 6 @Entity @Table(name = “user”) public class User{ @Column(name=“id”) private int id; @Column(name=“name”) String userName; @OneToMany(fetch=FetchType.EAGER) List<Team> teams; public void setName(String n){ userName = n } … other getter and setter methods User.javaUser class is mapped to “user” table in DB id is mapped to the column “id” in the user table A user can belong to multiple teams Eagerly retrieve associated teams when retrieving a user object
  • 7. Accessing the database using ORM 7 User u = findUserByID(1); ORM database select u from user where u.id = 1; u.setName(“Peter”); update user set name=“Peter” where user.id = 1; Objects SQLs
  • 8. Developers may not be aware of database access Wow! I don’t need to worry about DB code! ORM code with performance anti-patterns 8 Bad system performance The performance difference can be LARGE!
  • 9. Performance anti-pattern detection framework Performance anti-pattern detection and ranking framework Ranked according to performance impact Ranked Performance anti-patterns Source Code detection ranking 9
  • 10. Performance anti-pattern detection framework Performance anti-pattern detection and ranking framework Ranked according to performance impact Ranked Performance anti-patterns Source Code detection ranking 10 Discuss only one anti-pattern in the presentation (more patterns in the paper)
  • 11. ORM excessive data anti-pattern Class User{ @EAGER List<Team> teams; } User u = findUserById(1); u.getName(); EOF 11 Objects SQL Eagerly retrieve teams from DB User Table Team Table join Team data is never used!
  • 12. Detecting excessive data using static analysis 12 First find all the objects that eagerly retrieve data from DB Class User{ @EAGER List<Team> teams; } Identify all the data usages of objects User user = findUserByID(1); Check if the retrieved data is ever used user.getName(); user team user team
  • 13. Performance anti-pattern detection framework Performance anti-pattern detection and ranking framework Ranked according to performance impact Ranked Performance anti-patterns Source Code detection ranking 13
  • 14. Performance anti-pattern detection framework Performance anti-pattern detection and ranking framework Ranked according to performance impact Ranked Performance anti-patterns Source Code detection ranking 14
  • 15. Performance anti-patterns have different impacts 15 User user_in_1_team = findUserByID(1); Retrieving 1 user and 1 team User user_in_100_teams = findUserByID(100); Retrieving 1 user and 100 teams! One can only reveal performance impact by execution
  • 16. Measuring the impact using repeated measurements and effect sizes 16 We use effect sizes (Cohen’s D) to measure the performance impact Effect sizes = We repeat each test 30 times to obtain stable measurement results Size of performance impact is not defined: Performance measurements are unstable:
  • 17. Studied systems and detection results Large open-source e-commence system > 1,700 files > 206K LOC Enterprise system > 3,000 files > 300K LOC Spring open-source system Online system for a pet clinic 51 files 3.3K LOC 482 excessive data > 10 excessive data 10 excessive data 17
  • 18. Performance impact Research questions Ranks of the anti-patterns at different scales 18
  • 19. Performance impact Research questions Ranks of the anti-patterns at different scales 19
  • 20. Assessing anti-pattern impact by fixing the anti-patterns Execution Response timeuser.getName() Code with anti-patterns fetchType.set(LAZY) user.getName() Code without anti-patterns 20 Execute test suite 30 times Response time after fixing the anti-patterns Avg. % improvement and effect sizes Execution Execute test suite 30 times
  • 21. Performance anti-patterns have medium to large effect sizes 0% 20% 40% 60% 80% 100% Excessive Data BL EA PC 21 %improvementinresponsetime large effect size large effect size medium effect size
  • 22. Performance impact Research questions Ranks of the anti-patterns at different scales 22 Removing anti-pattern improves response by ~35%
  • 23. Performance impact Research questions Ranks of the anti-patterns at different scales 23 Removing anti-pattern improves response by ~35%
  • 24. Performance problems usually arise under large load 24
  • 25. Performance problems revealed at small scales may be more serious 25 We should first fix the anti-patterns that have larger effects at smaller scales Input scales may have exponential effects on performance Different input scales Performance at different input scales
  • 26. Comparing ranked anti-patterns at different data scales 26 Ranked Performance anti-patterns from small data detection ranking Ranked Performance anti-patterns from large data ? Small size input Large size input
  • 27. Anti-patterns have large effects on performance even at smaller data scales 27 0 10 20 30 40 50 0 1 2 3 4 5 Effectsize Effect sizes and the ranks of the anti-patterns are consistent in different data scales
  • 28. Performance impact Research questions Ranks of the anti-patterns at different scales 28 Removing anti-pattern improves response by ~35% Ranks of the anti-patterns are consistent in different data scales
  • 29. 29
  • 30. 30
  • 31. 31
  • 32. 32