PerfAnal – a simple but workable approach for Java Profiling using hprof on OS X

I have written a bit of Java code that does some financial analysis for me. Unfortunately it takes forever to run, even on my dual proc G5 w/a gig of ram it could literally run for over a day (it's those pesky 5 nested for loops, hey don't look at me, the equation it's solving has 12 variables and using some algebra and domain knowledge I could get it down it down to 5 independent variables but at that point I just had to iterate). Thankfully there were lots of obvious optimizations that I could apply that got the program down to around 4 minutes and then making the program multi-threaded got it down to around 3 minutes. But that is still a while to wait. So I decided I wanted to do some performance profiling.

I use Eclipe so it was natural to look a Hyades but the requirements included the Eclipse SDK which, near as I can tell, isn't currently available for OS X and anyway the whole project just seemed a bit complex and what I needed was really simple. I next tried out jMechanic which looked to be at just the right level of sophistication for my needs. Unfortunately it never seemed to quite run right. I would create a profile, run the program, see some hprof output in the console, etc. but when I tried to view the results using window->show view->other->profiler->etc. I never saw any data. I even got various errors from Eclipse.

I briefly considered using a commercial product but come on, my needs are trivial and the commercial stuff is expensive. So finally I decided to look into hprof directly. This is the performance profiling technology built into the JVM. Hprof is more than powerful enough to give me the level of detail I needed but the output is, to put it kindly, a bit hard to read. After looking around for a hprof viewer I found one that seems to do a pretty good job, PerfAnal.

It's very simple and doesn't have many features but it does a good job of providing a view of what the code is doing. This article gives a very nice overview and got me up and running within about two minutes. The end result? It helped me find some snags in my code (I never realized just how incredibly expensive it is to declare arrays in Java and I had left in some error checking code that I no longer needed) which got my performance down to around a minute. So I'm a pretty happy camper.

Innovation, Premature Standardization and Caveat Emptor

Adam Bosworth's blog had a pointer to an interesting entry in another blog on innovation and standards which itself pointed to another good blog entry on the subject. All three came to the same conclusion – Standards shouldn't innovate. As anyone who has read my rule's of standardization knows, I agree wholeheartedly. And yet, premature standards, standards in areas that are not well understood, keep getting churned out. Why?

Continue reading Innovation, Premature Standardization and Caveat
Emptor

More DVD Fun with OS X

Marina had the idea of sending my father a copy of UNCONSTITUTIONAL. My father returned the favor by sending us CELSIUS 41.11. Ironically enough while both UNCONSTITUTIONAL and OUTFOXED ran fine on VLC but caused my machine to crash on Apple's DVD player pretty much the opposite happened with CELSIUS 41.11. It ran on Apple's DVD player without problem but if I tried it on VLC then VLC got an error that screwed up the sound. In fact, if I ran VLC and then ran Apple's DVD player the sound stayed broken. The only way to get the DVD to play right was to kill VLC and run Apple's DVD player which for the first time didn't crash my machine! I guess Apple must be right wing.

OS X + G5 != DVD Player, but there is hope!

I just got a new DVD, UNCONSTITUTIONAL. I intentionally didn't run it full screen because I didn't want my machine to crash again. Unfortunately that didn't work. After running for twenty seven minutes and fifty seconds my machine died hard. Keyboard, mouse, DVD player, everything dead. The only sound a stuttering from the speakers. The only difference from my previous experience is that a friend told me to hold down the power button for five seconds or more instead of just pressing it the way I did last time. That did work so I didn't have to pull the plug. Of course the point of buying a Mac was to not have to know things like that.

It appears that I'm not alone in having this problem. The previously mentioned thread suggested two possible solutions. One was to turn off one of my dual processors but a number of people said this still caused problems for them. The other was to use a different video player than Apple's DVD player. VLC was suggested. As an experiment I played OUTFOXED full screen in VLC, turned off the sound and went to bed. I came back to my computer the next morning to find it running just fine. So for the moment I have a workaround. But I can't say it's a great work around because the VLC player is no where near as easy to use as the Apple player. Also note that at least on my LCD screen I found switching to video-deinterlace-blend made a big difference when blowing the picture up beyond normal size.

Come on Apple, this is pathetic! The previously referenced thread lists numerous people having this problem and you can safely assume for every person who posts there are many, many people like me who have the problem but didn't post. Just admit the problem exists and fix it already!

RelaxNG – The Best Way To Write XML Schemas

In a previous article I explained why XML Schema 1.0 is incapable of implementing the XML ignore rule and why this means that validating multiple versions of the same document is impossible using XML Schema in the general case. In this article I look at RelaxNG and show why it can handle multiple version validation without a hitch. I then discuss how to use RelaxNG in the real world, including with Web Services and conclude that the time has come for the XML and especially Web Services community to transition from XML Schema 1.0 to RelaxNG.

Continue reading RelaxNG – The Best Way To Write XML Schemas

Running Linux Live on a Dell Inspiron 8200

My wife's WinXP box died, again. I've been running the box for two years and that is just too long for windows. It really needs a full reformat and reinstall. But I don't have the time to deal with it now so I decided to instead to put Linux on my wife's machine. 98% of her time is spent in FireFox so she doesn't really care what the OS is. Wanting something easy I decided to try out several 'live Linux' distributions. These are distributions that run completely off a CD, no hard disk installation required. The one I found worked best on my wife's Dell was Mepis but even that will never stay up more than two days.
Continue reading Running Linux Live on a Dell Inspiron 8200