icse2014 v3

33
Detecting Performance Anti-patterns for Applications Developed Using Object-Relational Mapping 1 Mohamed Nasser, Parminder Flora Tse-Hsun(Peter) Chen Ahmed E. Hassan Weiyi Shang Zhen Ming Jiang

Upload: sailqu

Post on 16-Aug-2015

88 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Icse2014 v3

1

Detecting Performance Anti-patterns for Applications Developed Using

Object-Relational Mapping

Mohamed Nasser, Parminder Flora

Tse-Hsun(Peter) Chen Ahmed E. HassanWeiyi Shang Zhen Ming Jiang

Page 2: Icse2014 v3

2

Databases are essential in large-scale software systems

Database

Page 3: Icse2014 v3

3

Application developers work with objects

More intuitive if we can map objects directly to DB

Page 4: Icse2014 v3

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

Ahmed Hassan
Boss as I said beforeI want these two slides 4/5 merged!at bottom of slide haveDB ORMPRoblem Solution
Page 5: Icse2014 v3

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

Page 6: Icse2014 v3

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

Page 7: Icse2014 v3

Accessing the database using ORM

7

User u = findUserByID(1);

ORMdatabase

select u from user where u.id = 1;

u.setName(“Peter”);

update user set name=“Peter” where user.id = 1;

Objects SQLs

Page 8: Icse2014 v3

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!

Ahmed Hassan
Get a tutrle.. all by itself.
Page 9: Icse2014 v3

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

Page 10: Icse2014 v3

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)

Page 11: Icse2014 v3

ORM excessive data anti-patternClass User{

@EAGERList<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!

Ahmed Hassan
I changed the title
Page 12: Icse2014 v3

Detecting excessive datausing static analysis

12

First find all the objects that eagerly retrieve data from DB

Class User{@EAGERList<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

Page 13: Icse2014 v3

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

Page 14: Icse2014 v3

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

Page 15: Icse2014 v3

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

Page 16: Icse2014 v3

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:

Ahmed Hassan
These screen captures are blury!!!Please zoom all the way into your PDF then do the copy and paste then shrink the pasted pic
Ahmed Hassan
This one line.. again just melts with the rest of the text!1. It needs to stand out.. Also I feel instead of wasting time on the cohen.. explain to me what youa re doing. instead of a slide telling me a cohen mapping!
Page 17: Icse2014 v3

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 systemOnline system for a pet clinic

51 files 3.3K LOC

482 excessive data > 10 excessive data 10 excessive data

17

Ahmed Hassan
Not clear what you mean by PetClinic system
Page 18: Icse2014 v3

Performance impact

Research questions

Ranks of the anti-patterns at different scales

18

Page 19: Icse2014 v3

Performance impact

Research questions

Ranks of the anti-patterns at different scales

19

Page 20: Icse2014 v3

Assessing anti-pattern impact by fixing the anti-patterns

ExecutionResponse 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

Ahmed Hassan
Add more colour.. the good vs bad.. Go with green and red backgrounds and white text for the boxes.Also I do not get what you mean by rank.. Need more example.
Page 21: Icse2014 v3

Performance anti-patterns have medium to large effect sizes

Excessive Data0%

20%

40%

60%

80%

100%

BL EA

PC

21

% im

prov

emen

t in

resp

onse

tim

e

large effect size

large effect size medium

effect size

Ahmed Hassan
Huh so where is the t-test... I am confused.. the link bet 17 and 18 is no clearI fixed typo in slide title
Page 22: Icse2014 v3

Performance impact

Research questions

Ranks of the anti-patterns at different scales

22

Removing anti-pattern improves response by ~35%

Page 23: Icse2014 v3

Performance impact

Research questions

Ranks of the anti-patterns at different scales

23

Removing anti-pattern improves response by ~35%

Page 24: Icse2014 v3

Performance problems usually arise under large load

24

Ahmed Hassan
I did not like the other one the resolution did not feel sharp enough..Can you try to find something better.. I found this.. or if you feel both resoultions look the same then sure..But right now I feel the older (just behind the new one) has lower resolution)
Page 25: Icse2014 v3

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

Page 26: Icse2014 v3

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

Ahmed Hassan
use new turtle.I do not think this will be readable at all at ICSE!Font is way too smallAlso use different fonts.. font for the text and font for the code.. The whole slide just melts on itself.. you cannot see the text from your comments.. May be your comments need to show up in boxes with colored backgrounds and white fonts for example
Ahmed Hassan
Populating to... is not english
Page 27: Icse2014 v3

Anti-patterns have large effects on performance even at smaller data scales

27

05

1015202530354045

00.5

11.5

22.5

33.5

44.5

Effec

t size

Effect sizes and the ranks of the anti-patterns are consistent in different data scales

Ahmed Hassan
I want all these boxes to have either blue or red.. background with white font.Do not ever put grey background.. you just lose the contrast and it makes it much harder to read especially for projectors
Page 28: Icse2014 v3

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

Page 29: Icse2014 v3

29

Page 30: Icse2014 v3

30

Page 31: Icse2014 v3

31

Page 32: Icse2014 v3

32