RE: [ljc] Performance Tuning of a large Method

From: Stephen S.
Sent on: Tuesday, October 23, 2012 5:58 PM
Sounds like fun.

Here are a few points worth considering:

- Why is the method synchronised?  What state is shared and potentially mutating?

- What size are the Collections?  Are the data structures and algorithms efficient?

- What processing is actually taking place?  Is it all actually required?

- Can the processing be farmed out to helper object(s), reducing the number of components that the method needs to know about?

- Are the Collections just POJOs or do they represent something that is being fetched from an database?

Once you understand each section you can do your colleagues a favour by splitting it out into smaller methods with meaningful intention-revealing names.

Given that this is a 185 line method with significant cyclomatic complexity I won't assume that you have fantastic test coverage, so good luck.


From: [address removed]
To: [address removed]
Subject: [ljc] Performance Tuning of a large Method
Date: Tue, 23 Oct 2012 09:34:38 -0400

Good morning,

I'm working on a rather high trafficked ecommerce platform at the moment where I seem to having some performance issues.

I've hooked visualJVM up to the application to find that one particular method is taking over 40 seconds to complete when load is high. Looking at the method, I see it's a 185 line copy and paste job from a legacy codebase that has some rather verbose conditionals and lots of interactions with Collections.

I know I haven't given enough information for anyone to really help me but I'm curious as to how you would generally go about dealing with a 185 line, synchronised java method that was lifted out of a legacy codebase. Where am I supposed to begin when refactoring this mess?


Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Craig Silk ([address removed]) from LJC - London Java Community.
To learn more about Craig Silk, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, PO Box 4668 #37895 New York, New York 10163-4668 | [address removed]

Our Sponsors

  • Our Blog

    Read the latest news from the LJC

  • RecWorks Ltd

    Fixing Tech Recruitment using the Power of Community

  • jClarity

    Java/JVM Performance Analysis Tools & mentoring for Java related matters

  • LJC Aggrity

    Our LJC Aggrity site contains blog posts from our members

  • LJC Book Club

    Our Book club with book reviews from our members

  • Devoxx UK

    Java Community Conference, in collaboration with the LJC 12/13 Jun 14

  • SkillsMatter

    "Host, help organise, promote, film many of our meetings."

  • Atlassian

    See here for details -

  • Packt Publishing

    A publishing company specializing on specific technologies and solutions

  • Java.Net

    We are an official Java User Group recognised by Oracle's JUG program

  • JRebel

    Free 3 month J-Rebel license.

  • O'Reilly

    40% discount on printed books and 50% on e-books.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy