Static Analysis in Search of Performance Anti-Patterns Patrycja Wegrzynowicz Founder and CTO, Yonita Inc. Founder and CTO, Yon Labs and Yon Consulting.

Slides:



Advertisements
Similar presentations
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Advertisements

Executional Architecture
Software & Services Group PinPlay: A Framework for Deterministic Replay and Reproducible Analysis of Parallel Programs Harish Patil, Cristiano Pereira,
Client side performance in Web based Banking applications Divakar Prabhu Infosys Limited (NASDAQ: INFY)
Copyright © 2003, SAS Institute Inc. All rights reserved. Where's Waldo Uncovering Hard-to-Find Application Killers Claire Cates SAS Institute, Inc
Adding scalability to legacy PHP web applications Overview Mario A. Valdez-Ramirez.
G O B E Y O N D C O N V E N T I O N WORF: Developing DB2 UDB based Web Services on a Websphere Application Server Kris Van Thillo, ABIS Training & Consulting.
ManageEngine TM Applications Manager 8 Monitoring Custom Applications.
July 23 th, 2005 Software Architecture in Practice RiSE’s Seminars Bass’s et al. Book :: Chapter 16 Fred Durão.
©Company confidential 1 Performance Testing for TM & D – An Overview.
Session-02.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
Load Test Planning Especially with HP LoadRunner >>>>>>>>>>>>>>>>>>>>>>
31 January 2007Craig E. Ward1 Large-Scale Simulation Experimentation and Analysis Database Programming Using Java.
Advances in Language Design
Praxis Softek Solutions Statement Of Qualification – J2EE.
Chapter 3.1:Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access.
SEC(R) 2008 Intel® Concurrent Collections for C++ - a model for parallel programming Nikolay Kurtov Software and Services.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
CS 355 – Programming Languages
Patterns and Anti-Patterns in Hibernate Patrycja Wegrzynowicz CTO, Yonita, Inc. CTO, Yon Labs and Yon Consulting, LLC.
Using Runtime Information for Adapting Enterprise Java Beans Application Servers Mircea Trofin *, John Murphy ** Performance Engineering Laboratory * DCU,
Introduction Optimizing Application Performance with Pinpoint Accuracy What every IT Executive, Administrator & Developer Needs to Know.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Oracle PL/SQL Programming Steven Feuerstein All About the (Amazing) Function Result Cache of Oracle Database 11g.
JBoss Cache. Cache A place to temporarily store data that is expensive or difficult to compute or retrieve. Caches should be fast to access. May or may.
Computer Measurement Group, India Optimal Design Principles for better Performance of Next generation Systems Balachandar Gurusamy,
CD Database Server (CDDB) Zachary Carter Alan Savage Diana Abbas Kyle Dorman.
© Dennis Shasha, Philippe Bonnet – 2013 Communicating with the Outside.
Ideas to Improve SharePoint Usage 4. What are these 4 Ideas? 1. 7 Steps to check SharePoint Health 2. Avoid common Deployment Mistakes 3. Analyze SharePoint.
Oracle9i Performance Tuning Chapter 1 Performance Tuning Overview.
11 CORE Architecture Mauro Bruno, Monica Scannapieco, Carlo Vaccari, Giulia Vaste Antonino Virgillito, Diego Zardetto (Istat)
A Presentation to Oracle OpenWorld Blistering Web Applications with Oracle TimesTen In Memory Option.
Hibernate 3.0. What is Hibernate Hibernate is a free, open source Java package that makes it easy to work with relational databases. Hibernate makes it.
1 Optimizing compiler tools and building blocks project Alexander Drozdov, PhD Sergey Novikov, PhD.
Title Line Subtitle Line Top of Content Box Line Top of Footer Line Left Margin LineRight Margin Line Top of Footer Line Top of Content Box Line Subtitle.
Efficient RDF Storage and Retrieval in Jena2 Written by: Kevin Wilkinson, Craig Sayers, Harumi Kuno, Dave Reynolds Presented by: Umer Fareed 파리드.
JPA / HIBERNATE CSCI 6370 Nilayan Bhattacharya Sanket Sable.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool The problem fixed by ORM Advantage Hibernate Hibernate Basic –Hibernate sessionFactory –Hibernate Session.
Virtual Application Profiler (VAPP) Problem – Increasing hardware complexity – Programmers need to understand interactions between architecture and their.
Object Oriented Analysis and Design 1 Chapter 9 From Design to Implementation  Implementation Model  Forward, Reverse, and Round-Trip Engineering  Mapping.
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB Markus.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Topic : Hibernate 1 Kaster Nurmukan. An ORM tool Used in data layer of applications Implements JPA.
OOD OO Design. OOD-2 OO Development Requirements Use case analysis OO Analysis –Models from the domain and application OO Design –Mapping of model.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Copyright 2007, Information Builders. Slide 1 iWay Web Services and WebFOCUS Consumption Michael Florkowski Information Builders.
Cloud Computing: Pay-per-Use for On-Demand Scalability Developing Cloud Computing Applications with Open Source Technologies Shlomo Swidler.
SQL Database Management
COTS testing Torbjørn Skramstad.
Software Design and Architecture
课程名 编译原理 Compiling Techniques
Secure Software Development: Theory and Practice
Java programming lecture one
Database Performance Tuning and Query Optimization
COTS testing Tor Stålhane.
COTS testing Tor Stålhane.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
Introduction to Databases Transparencies
Lecture 1: Multi-tier Architecture Overview
Software Architecture
Testing a persistence layer
PROCESSES & THREADS ADINA-CLAUDIA STOICA.
Chapter 11 Database Performance Tuning and Query Optimization
Developing and testing enterprise Java applications
Design Yaodong Bi.
Database System Concepts and Architecture
Presentation transcript:

Static Analysis in Search of Performance Anti-Patterns Patrycja Wegrzynowicz Founder and CTO, Yonita Inc. Founder and CTO, Yon Labs and Yon Consulting

About me Past 10+ years of professional experience as software developer, architect, and head of software R&D PhD in Computer Science (automated code analysis) Speaker at JavaOne, JavaZone, ASE, OOPSLA, Jazoon, and others Present Founder and CTO of Yonita Inc., Yon Labs, and Yon Consulting Bridge the gap between the industry and the academia Future Who cares? Seize the day!

Agenda Performance issues Performance bottlenecks and how to deal with them Automated code analysis Semantic code query system Performance anti-patterns Code samples Code queries

PERFORMANCE ISSUES

This is Java.

Is Java slow? On most Intels Java is as fast or faster than C The Gaia Satellie and Data Processing William O’Mullane from European Space Astronomy Centre Jazoon 2010

Limited Resources Hardware OS Application Locks Pools FD Threads Network Processors RAMHD Memory

Sun’s SDK, Arrays.binarySearch, Joshua Bloch

The Way We Write Software Business Requirements Technology Stack Software Teams JSF JPA hibernate strut s Tapestr y iBati s JT A EJ B RM I GWT Swin g JS P JMS aw t JND I JD O

Performance Issues Root causes Bad architecture, design, or code Wrong configuration (app/db server, OS, RDBMS) Rarely insufficient hardware Bottlenecks usually unnoticed until happen Special conditions to happen: size of data, number of users The later discovered the more expensive to solve

Performance Tuning MIF cycle Dynamic analysis Log/traces Profiles Environments Testing Production Monitor Identify Fix

Our Code

A Single Spaghetti is Hard to See

(Anti-)Patterns in Our Spaghetti

Automated Code Performance Tuning + Automated code analysis Definions of performance anti-patterns

Detection of Performance Anti-Patterns Benefits Hints on performance on higher level of abstraction (architecture, design, programming constructs) instead of in terms of lower level concepts (CPU usage, memory consumptions etc.) Supports developers and development phase Promotes best practices (refactored solutions) Problems Lack of formalization, high-level concepts, textual description Implementation variants Size of code

AUTOMATED CODE ANALYSIS Think? Why think! We have computers to do that for us. – Jean Rostand

Semantic Code Query System Code query systems Explore relationships among program elements Structural and call-related predicates CodeQuest, JQuery Semantic code query systems Focus on behavior (in-depth data flow analysis) Behavioral predicates in addition to structural ones D-CUBED – my PhD thesis (focus on design patterns) Yonita – rewrite + queries

How does Yonita work? Analyses Parser Store Query Bytecode or Sources Asm/Recoder analyses: structural, call flow, data flow transitive closures relational (MySQL) or deductive (XSB) database SQL or Prolog (anti-)patterns bugs vulnerabilities...

Metamodel Structural elements Very similar to CodeQuest and Jquery Statements Instances Symbolic instances Behavioral predicates supporting call and data flows Output and input values Assignments

Instances Null New This Parameter Exception Multiple Return Instance Param Instance This Instance New Instance Null Instance Except. Instance … … …

Behavioral Predicates Calls makesCallConditionally(Callable, Callable) makesCallAlways(Callable, Callable) Input and output values hasInput(Callable, Instance) hasInput(Statement, Instance) hasOutput(Callable, Instance) hasOutput(Statement, Instance) Assignments assigns(Field, Instance)

Running Yonita Prototype Run Yonita to parse an application yonita [classes] [libs] –prolog –mysql MySQL configuration hibernate.cfg.xml Run MySQL console and ask queries (SQL) Prolog configuration -Dprolog.file=output.P -prolog=output.P Run XSB Prolog console and ask queries (Prolog) Yonita on Google App Engine In progress

PERFORMANCE ANTI-PATTERNS

Redundant Work – Example 1 (Web)

Multiple calls to database (7 calls!) Multiple security check Each call to getUser checks permissions What if getUser were a remote method?!

Redundant Work – Example 2 (agilefant)

Redundant Work – Example 2 (agilefant – sourceforge project) Thank you hibernate! Open Session in View Session cache

Redundant Work – Example 3 (agilefant) AJAX Calls

Redundant Work – Example 3 (agilefant) AJAX Calls

Redundant Work – Example 3 (agilefant) AJAX Calls

Redundant Work Description A time-consuming method is called many times on a single execution path Consequences A slower execution time Refactored solution Call the heavy method only once and store the result for further re- use Heavy

Redundant Work – Code Query redundantWork(X, Heavy) :- // method Heavy called at least twice... method(X), method(Heavy), isHeavy(Heavy), hasChild(X, Invocation1), methodInvocation(Invocation1, Heavy), hasChild(X, Invocation2), methodInvocation(Invocation2, Heavy), //...with the same parameters setof(I1, (hasInput(Invocation1, newInstance(I1)), All), setof(I2, (hasInput(Invocation2, newInstance(I2)), All). isHeavy(X) :- isWebService(X). isHeavy(X) :- isDatabaseService(X).

Fine Grained Remote Calls Entity Beans EJB1 EJB2 Remote Calls Remote calls have significant impact on application performance Client Bean getX() getY() getZ()

One by One Processing – Example 1 Add users to a group Performed in the web layer one by one Multiple calls to the service layer Multiple loads and updates each in a separate transaction! Multiple authorization!

One by One Processing – Example 2 Delete a group Detach a group from every user in a group one by one

One by One Processing Description The objects in a collection are processed one by one and a single processing requires a call to a time-consuming method (e.g. database access, remote call) Consequences A significant increase in time with the increase of collection size Refactored solution Consider batch processing Heavy

Unused Object – Example (richfaces 3.2.2)

Unused Object Description An object created (usually retrieved from a database), passed to further methods (usually a long chain of method calls), and than not used Consequences Higher memory consumption that may lead to performance issues Refactored solution Create objects only if you need them.

Unused Objects – Hibernate Mapping

Unused Objects - Standard Collection Mapping

Unused Objects - Immutable Collection

Summary We need to write better code! Performance anti-patterns High-level concepts Many implenentation variants Static analysis can help in discovery of performance issues Useful tool but it does not replace a traditional approach to performance tuning (measure, identify, fix)

Contact Patrycja twitter.com/YonLabs Yonita