Search |
||
Refactoring for PerformancePosted by giovanisalvador on April 28, 2008 at 7:36 AM PDT
I was working on a kind of Outlook entirely based on the web and written 100% in Java. I was part of a team responsible for maintaining that application for thousands of users and performance was a critical piece. Actually, still is a critical piece because the application still exists and it is there for almost ten years. The problem was that the application didn't have in place Transfer Objects or Value Objects. It was relying on maps and the application was facing performance problems on building those maps and suffering when accessing get methods of those maps, specially in those days where the load was so huge. That's what Optimizeit was telling me. So I decided to make a small refactoring in my local environment after assessing the application with Optimizeit. I switched from maps to Transfer Objects in all layers of that piece of the application. Instead of making maps and collection of maps I created Transfer Objects and made them being accessed by the listing page. The Facade was responsible for returning the collection of Transfer Objects instead of a collection of maps. When I ran Optimizeit again I noticed a gain of 20% in performance. After showing the results to the team we decided to release to production after some tests in Development Environment. - User: Hey, have you guys modified anything in the application? You guys may be surprised with this. Today, almost all applications rely on Transfer Objects, not on hashmaps. But at that time, with the knowledge of the former team, that's what was being used. The bottom line here is that small modifications may affect user experience. We don't need to make big refactorings to achieve that. Simple is better. but I would like to know from you: »
Related Topics >>
Performance Comments
Comments are listed in date ascending order (oldest first)
Submitted by tobega on Wed, 2008-04-30 08:16.
Simple or not, what I see as interesting is that the change you made not only improved performance but also improved the structure of the code, making it more understandable and more maintainable. I wish I'd known the performance aspect in a project where I tried to get this kind of change accepted for maintenance purposes.
Along similar lines, I recently found that by using the state pattern to make a class easier to understand and then making it thread-safe by having an AtomicReference to immutable instances of state, it actually improved performance over the synchronization I'd been doing earlier. (see http://tobega.bogspot.com )
Submitted by giovanisalvador on Tue, 2008-04-29 10:46.
Hey Greeneyd.
awesome post. bottom line in you case was the cost for object creation. And it was a very simple modification that made the difference.
Best regards
Submitted by greeneyed on Tue, 2008-04-29 07:35.
That was my last event like the ones you describe:
http://www.jroller.com/greeneyed/entry/don_t_throw_your_scriptengines
Caching expensive-to-create objects has usually been the case in my code. So I first start doing it the "normal" way and then see if there is anything like that that can be improved.
S!
|
||
|
|