Profiling



  • Good Lord; three in one day. I'm going home after I post this.

    After this past hack-it-right-up-until-we-deploy-it release, absolutely no testing, let alone performance testing was done. Now that it's been running for a week, they've noticed it's a lot slower than it was before. My boss asked me to do some performance testing.

    Sure, I'll just get JProbe, wire it up and run it.

    Oh no, we're no longer allowed to download or install software. You need to requisition it.

    But there's no money in the budget.

    That's right, the request won't even be considered until the backlog clears in January. However, you can print a timestamp at the entry and all exit points of every method, dump it to the db, and then do an analysis on that.

    But we have nearly 400K LOC. That'll take forever!

    We have no other options, get started on it...

    Personally, I'm going to try and figure out how to use AOP to do it with logging, then write some scripts to try and parse the output.

    But NOT today!



  • @snoofle said:

    no money in the budget [...] That'll take forever! We have no other options, get started on it...

    ... what.



  • Hey Boss, check out these calculations I did!

    Cost of JProbe: $2000

    Amount of time it would take to add all this monkey code: 2 weeks

    Cost in developer time (@$40/hr): $3200

    (Change numbers to suit)



  • JVisualVM is standard part of the JDK these days ... press 'profile' then 'cpu' and enjoy?

    Oh, right you can't 'touch' production? Maybe remote connections?



  • Disclaimer:  I am not a developer so this question is likely to be naive.

    Would/could this...

    @snoofle said:

    However, you can print a timestamp at the entry and all exit points of every method, dump it to the db, and then do an analysis on that.

    ...affect performance to such a degree as to invalidat, or at least skew, performance testing?



  • Get a parser, then insert the trace statements automatically. Do I need to explain everything around here? We're in the automation business!

    Good luck btw :P



  • @RTapeLoadingError said:

    Disclaimer:  I am not a developer so this question is likely to be naive.

    Would/could this...

    @snoofle said:

    However, you can print a timestamp at the entry and all exit points of every method, dump it to the db, and then do an analysis on that.

    ...affect performance to such a degree as to invalidat, or at least skew, performance testing?

    It certainly could.  The "best" way to do it would be to keep track of the values as you go, and then dump them all at once.  If you were making a call to the database every time, the performance would be so horrid as to probably slow your processes to a crawl.


  • @Sutherlands said:

    @RTapeLoadingError said:
    ...affect performance to such a degree as to invalidat, or at least skew, performance testing?

    It certainly could.  The "best" way to do it would be to keep track of the values as you go, and then dump them all at once.  If you were making a call to the database every time, the performance would be so horrid as to probably slow your processes to a crawl.
     

    Ah, but if you are a little bit lucky it'll will only change the magnitude of the numbers, not their relationship.  Well, it probably well change that too, but you can hope it changes it by little enough that you can still pinpoint bottlenecks or slow areas of code.  Sometimes things pop right out at you in these cases.

    If you aren't a little bit lucky, you'll be chasing ghosts in the machine and optimizing things that are wonderfully tight.  But, hey, it won't be any worse than not fixing it at all!

     



  • Snoofle, good buddy, I suggest a sublethal dose of Valium (for yourself). If you can put up with all this in any way, it's job security through January 19, 2038 at least.



  •  Snoofle has replaced Blakeyrat as the main post-Morbius-Wilters reason I come to TDWTF.



  • Don't you know anything about how business works.  The cost of a developer is a fixed cost.  At $40 an hour thats $1600 a week that would be incurred no matter what he does that week so long as he worked the full 40 hours.

    There for buying software is not approved because that's an additional cost added to the time of the developer. Duh!

    I recommend making a note that you did this work without JProbe so on your performance review you can say you saved the company $2000.



  •  I recommend using a trial version JProbe and give snoofle a 2 week unpaid vacation to compensate. That way the boss can explain he saved 5200$ and propose that now snoofle be a half-time employee to make it a recuring save.



  • If you're using Netbeans, it has profiling support built in for both local and remote profiling. I've found that pretty much all profiling that I do to code shows that String manipulation takes up the vast majority of cycles. Even nested method calls don't add much overhead. The problem is that String concatenation is slow because you have to allocate memory (which is always in O(n) time) and do a memcpy(). Just a thought.



  • How is memory allocation O(n)?

     



  • I'm pretty sure the OS's MM has to walk the page table to find a chunk. I'm not aware of any real time algorithms. Though I could be wrong. I haven't looked at it in a long time.



  • Hierarchical bitmaps can get the time down to O(log N) with extremely small constant factors (only a dozen or so instructions required per allocation)


  • Discourse touched me in a no-no place

    @asquithea said:

    @Gazzonyx said:
    The problem is that String concatenation is slow because you have to allocate memory (which is always in O(n) time) and do a memcpy(). Just a thought.
    How is memory allocation O(n)?
    I think it's possibly a vague misunderstanding of something like this.



  • @asquithea said:

    How is memory allocation O(n)?

    Because Java guarantees to initialise your arrays to the default value ('\u0000' for char arrays). In principle a VM could do that using certain clever tricks which slightly more than double the memory consumption, but in practice I doubt any do.



  • @PJH said:

    @asquithea said:
    @Gazzonyx said:
    The problem is that String concatenation is slow because you have to allocate memory (which is always in O(n) time) and do a memcpy(). Just a thought.
    How is memory allocation O(n)?
    I think it's possibly a vague misunderstanding of something like this.

    Yeah, that must be where I picked up the idea that allocation is O(n). I remember reading that years ago.


Log in to reply