Monday, August 28, 2006

Summer Vacation Part III - Hood River

Breaking camp early in the morning on the 4th of July, we made the 8+ hour drive from Lake Shasta to Hood River, OR. Driving along the banks of the Columbia River provided a nice view of two waterfalls, and as we drove I thought about Lewis and Clark, and their most excellent adventure which took them from the interior of the then new country, all the way out West.

We spent two nights at my sister-in-law's house, and had a nice time watching the fireworks display on the 4th. The following day, we drove around the countryside, bought locally made fresh fruit products (jams, pies, etc.), and saw Mt. Hood. At one of our stops, the kids fed a few goats, which they enjoyed.

After two nights, it was time to head further North once again...

Wednesday, August 16, 2006

Porting a Win32 Delphi App to .net - Part 2

When we last left our hero, he was struggling to figure out why the .net compiled engine was so damn slow. When it comes to diagnosing performance issues with an application, the smart programmer reaches for a profiler.

From the wikipedia article:
A profiler is a performance analysis tool that measures the behavior of a program as it runs, particularly the frequency and duration of function calls.

Knowing what I needed to do, I sought out the tools which would allow me to profile the library. I downloaded Microsoft's CLR Profiler (there are separate versions for .net 1.1 and 2.0). However, after installing it, I could not get it to work.

Next, I searched Google for .net profilers that support Delphi. On of the first ones I spotted was called ANTS, by Red Gate Software. It only supports .net languages, so the profiler wouldn't be able to help me with the Win32 side of our product line, but I gave it a go anyhow - and it worked beautifully and intuitively.

Finally, I investigate a profiler which would work both with our Win32 library and our future .net library. The only one which meets this criteria is AQTime, by AutomatedQA. Unfortunately, to use AQTime, you must have Administrator privileges. I only use my administrator account for system maintenance, so this was a deal breaker for me. It will also be the subject of an upcoming post on dumb-ass software development for the Windows platform.

So ANTS it was! Using the profiler results from the 15 day free demo, I was quickly able to see where a large chunk of time was being spent - and it wasn't in any code I wrote! One of the data structures in the library is a very large array, which is exposed as a property of one of our objects. It seemed as if a call to initialize this large array was occurring way too many times, since only once instance of it should have been created.

Stumped, I turned to ildasm - Microsoft's Intermediate Language DisASseMbler. It allows you to look at the byte code generated by the .net compiler, and see what the heck is going on at a much lower level. Sure enough, in one routine I saw that it was requesting seven local copies of the large array I mentioned above - each of which needed to be initialized, and copied!

Investigating further, I found the cause of the problem. Instead of using the private field names for the large array (e.g. FArray), a property (e.g. Array) with get and set methods was being called, and for some reason this resulted in local copies being created. By replacing Array with FArray, I saw the calculation time plummet from the 2+ seconds observed before, down to around 1/3 or a second.

I cut the calculation time by another 10% using targeted fixes, and then measuring the results. Since then, I've further profiled the library, tuning code most likely to benefit, and not worrying about code which has little impact on the overall time. Just this morning, I reduced they profiling the calculations again. Now, I believe I am at a point of diminishing returns, and will stop profiling and optimizing until a later time.

Next step: see if I can use the library using mono on linux!

Friday, August 11, 2006

Porting a Win32 Delphi App to .Net

I have been using Delphi since version 1.0. When Delphi first appeared on the market, it blew the doors off Visual Basic 3.0. It was a rapid application development platform which compiled code down to native machine code, and allowed the creation of all new visual components using the same Delphi environment. Delphi used a beautiful object oriented language, Turbo Pascal, which had proven itself in past Borland products. Since everything was compiled into a single EXE or DLL, you avoided the Visual Basic DLL/VBX version hell. Delphi version 2.0 brought 32 bit support, and continued dominance over VB 4.0.

And now, to the present! The company I work for provides a fairly complex loan calculation engine, which is written using Borland Delphi for the 32 bit Windows platform. Lots of numerical calculations wrapped in iterative loops, etc. Since it is a standard, 32 bit Windows DLL, we can provide many different ways for our customers to access it:
  1. The standard LoadLibrary() / GetProcAddress() win32 routines.
  2. We provide a wrapper class for those developing on the .Net platform in vb or C#.
  3. If using Java on Windows, we even provide a Java wrapper class which accesses the DLL via JNI.
  4. If using Delphi, you can link to it in code easily.
  5. We even provide a Win32 service which listens on a specified TCP/IP port to service requests from non-win32 platforms.
All this is well and good. Performance is outstanding, with a couple hundred requests per second being handled under optimal situations - and there was much rejoicing!

However, a situation has come up wherein a potential client who uses C# to develop their application has requested that we port the DLL over to the .Net platform. Why? Because one of their huge selling points is that, "Our software is pure .Net".

I won't go into my initial "WTF?" reaction, and rant against rewriting a perfectly good and accessible calculation engine just for the sake of what amounts to code related religious fanaticism. When it comes down to it, the customer asks, and we do what we can to accommodate.

With this in mind,we looked at a few possible options: rewrite it the 70K+ lines of code in C#, license our source code to the prospective customer and have them rewrite it, or investigate Delphi for .net.

We dismissed option #1 as being too time consuming for a small company, considered option 2 as sub optimal, and have for now gone with option #3. In about a week, I was able to compile a portion of our calculation engine DLL using Delphi for .Net.

And then I ran a test calculation... and waited... and waited. It took 2 seconds to complete a simple calculation which would have been done in the merest fraction of a second using the native Win32 DLL. We are talking about a performance differential of around 99%. Le ouch!

So now I need to look at profiling the .Net assembly, and try and figure out what the hell is causing the problem. The .Net platform could not be this horrible slow with numeric calculations, can it? It must b some sort of Borland.Vcl.dll .net implementation issue, right? Right!?!?!?

Gahhhhhhhhhh! If anyone has any ideas and/or suggestions, I'm ready and willing!

Tuesday, July 25, 2006

Summer Vacation Part II - Lake Shasta (cont.)

Other than camp and eat near-gourmet quality food (if I do say so myself) while at Lake Shasta, what else did we do? For each of the two full days there, we planned something different.

On our first full day in the Shasta area, we decided to visit Lake Shasta Caverns. After a brief boat ride across the Lake, and a shuttle ride up a twisting and turning path, we all delved into the natural caverns discovered above the McCloud arm of the lake.


The caverns were a good twenty degrees cooler than the outside temperature, which was quite welcome. The caves had some pretty amazing formations, which don't show up to well in the photos I took due to a distinct lack of good lighting. In total, we made out way up, down, and around 695 steps on our round trip explorations of the caverns.


No children were harmed in the taking of this picture:


The second full day found us traveling a bit North and then a bit east, to hike up and see the Middle McCloud falls.

The middle falls are around 100 ft. wide and 50 ft. tall, and quite breathtaking.

After snapping a few pictures, we made our way down to the Lower McCloud falls, and tempted fate by changing into bathing suits and braving the near pure snow-melt. I didn't have a thermometer with me, but I'd estimate the water temperature to be in the 40s - much colder than any ocean water I surf during the winter here in San Diego (with a full suit). The water was so cold that your feet felt a bit numb after a few minutes in the water. However, the weather was so beautiful that we braved the chilly temperatures and had a good time.


The next day we said our farewells to Lake Shasta, broke camp early in the morning, and continued on our journey heading further North.

(To be continued!)

Thursday, July 20, 2006

Summer Vacation Part I - Lake Shasta

Prior to this summer, our family had not driven farther than the distance from Oceanside to San Mateo, to visit my brother and his family up in the bay area. It also has been two years since our last summer vacation (camping at South Carlsbad State Beach). So, this summer we planned a long road trip from Oceanside up to Seattle , stopping at points in between.

The first leg of our journey found we five hardy travelers making our way up to Lake Shasta. From Oceanside, that is approximately a 10.5 hour trip. The kids handled it well, and we only stopped once for breakfast at 9:00 AM, around 5 hours after we left the house. Yes, those of you who are handy with numbers will quickly deduce that we left the homestead at 4:00 AM. Doing this, I can avoid the traffic in LA and the kids will go back to sleep for a while.

The drive up I-5 went well, except for a closure in LA due to who knows what. We made it up to our camp site at Shasta Lake RV Resort and Campground by 2:30, and boy was it warm! I think it was in the mid 90s as we pulled in to our site. Thankfully, the tent sites there are almost all shaded, and very spacious. So long as you were not doing much physical, the temperature wasn't too bad. The picture to the right gives a decent overall view of the campsite.

The campground had hot showers, a swimming pool, and a nice little camp store that sold ice, beer, and other life or death items. The people who worked there were polite and friendly, and I wouldn't hesitate camping there again in the future. The RV sites looked a bit close together, however.

I cooked all meals using charcoal and my two dutch ovens. We ate well, cooking dinners of stew, cornbread, dump cake, tequila lime turkey breast, home made sourdough bread, apple crisp, etc. Breakfast was also cooked, featuring: bacon, eggs, potatoes, pancakes, etc. We kept lunches simple with PB&J sandwiches. Unfortunately, I was so busy cooking that I forgot to take pictures, except for the following from breakfast one morning.


So, what did we do for the three days we were there? That'll be the subject of my next entry...

Tuesday, July 18, 2006

Torn Calf Muscle

About 4 weeks ago, the little league baseball season was wrapping up, and we held our end of the season team party at a park close by. Around 6:00 pm, after everyone had eaten their fill, we held a parents vs. kids whiffle ball game. No gloves, no helmets - just one whiffle ball and one big plastic orange bat.

After crushing the ball in my first at bat (batting opposite to try and even the odds a bit), I approached my second at bat with something resembling a smidgen of over confidence. Oh, how the proud are laid low!

I hit the pitch offered, and started down towards first. I am still unsure of the exactly what happened. All I do know is that it felt as if someone with a real baseball bat smashed my right calf muscle, and I gimped up immediately, barely making it to first on one leg, being put out at first.

I could barely walk for the next 24 hours, and things didn't start really improving for another 2 to 3 days. By the end of the week, I noticed my right foot was swollen, so I bit the bullet and made an appointment to see the doctor. After 15 minutes and a $30 co-pay, my doc cheerfully told me that I had described a text-book muscle tear, hitting the nail on the head with the "hit like a bat" description.

He massaged my calf seductively, and said that while he couldn't actually feel the tear (which was a good thing), it seemed to be fairly high up on the muscle (also a good thing). If the tear is lower, where there is less muscle to tear, then at times it is necessary to cast the lower leg. So, he said that like Woody Williams of the San Diego Padres (who tore his left calf muscle running the bases a few weeks before I did), I was on the "DL" for 4 - 6 weeks, and to try to take it easy.

Later that day I took my son to The Wave Waterpark, and stupidly tried to ride the Flow - rider wave machine, and tweaked the hell out of my calf again. Stupid me. After another 5 days of pain, it started getting better.

So here I am, roughly 4 weeks after the injury, and things are looking up. I went surfing last Thursday and today, with not too many issues. I'm taking it easy, while still trying to exercise it a bit to prevent too much muscle atrophy. Hopefully in another 2 weeks I'll be back to 100%.

Thursday, June 15, 2006

Cleveland Rocks!

Over the weekend, I attended a conference in the suburbs of scenic Cleveland, Ohio. During our stay, we saw a few of the following sights:

First up was Lake Erie (it's sort of hard to miss it as you fly over it on landing approach). We drove through Sandusky and up North to the Marblehead peninsula to get a good look at Lake Erie, the shallowest of the Great Lakes (maximum depth of 210 ft.). In the past, it has frozen completely over, allowing people and cars to traverse the lake over ice to the islands. Ice fishing is also fairly popular, or so I was told.

Thankfully, the weather was very pleasant while we were there so no cold weather gear was required! :> While on the Marblehead peninsula, we visited the Marblehead lighthouse, which is the oldest lighthouse on the US side of the Great Lakes. We managed to visit on the one day of the week it is closed (Sunday), so we had to make due looking at its exterior and watching folks catch fish nearby.

On the way back to our resort, we stopped at the Firelands winery, on the outskirts of Sandusky. For $1, we were able to sample some of the local wines and then took a self-guided tour through the winery. The wine was good enough to persuade us to purchase a bottle, so I'd easily recommend the stop to anyone.

I didn't have a chance to do any more sight seeing until our departure date, as I was busy attending seminars, presentations, and the like. However, our last stop was the best by far. We stopped at the Rock and Roll Hall of Fame and Museum for about an hour and a half, and were quite impressed. With a $20 admission price, I'm glad to say that I think the museum is worth it. A fan of rock and roll could easily spend a half day there, and a whole day isn't out of the question. Two thumbs up, definitely!

After four days away from home, I was glad to slip back into the ocean yesterday! There's just no place like home.

Tuesday, May 30, 2006

Springsuit Surf Report

Ah yes, that wonderful time of the year has come when the water warms up enough to put away the 3mm/2mm wetsuit I've been wearing for the past several months, and get back out the springsuit! The water has warmed up significantly over the last several days, and if this trend continues, I'll be able to ditch the springsuit in no time as well!

Last week, the onshore winds were extremely strong in southern CA (10-15+ knots in the afternoon), which really kills the surf. Yesterday, I woke up and noticed that the wind wasn't blowing much, and took a Memorial Day jaunt down to Oceanside Harbor. The waves weren't great, but there was some fun short period wind swell with a few occasional set waves making a rare appearance. I surfed for almost 2 hours, and the overall weather conditions were amazing. I was wearing my wetsuit, and actually felt too hot as noon approached.

During lunch today, I broke out the springsuit and headed down to D street. Another beautiful day with playful surf, and the water just felt perfect. Of course, this means that the crowds will start to increase as well... ;<

Thursday, May 11, 2006

2006 Fish Fry


Last Sunday was the annual Fish Fry - a gathering of surfers and shapers who enjoy surfing fish surfboards. A "fish" surfboard is usually shorter and wider than your usual shortboard, customarily with a swallowtail. A standard fish has two fins (or keels), although more modern designs are now popular as well, like the quad canard fins on my GH board.

As I was getting ready to paddle out, with a crowd-induced grimace on my face, Mike Miller of ppb-photos snapped a rare picture of me. Note to self - need to cut back a bit on the red trolley ale...

Monday, April 24, 2006

Thy Dungeonman 3

Ok, this post is brought to you by the fine folks at Homestarrunner.com. If you can remember the first generation graphical adventure games, then you will certainly get a kick out of Thy Dungeonman 3. While it is a parody of the old games, it is in fact a complete mini-adventure game, which I just finished in something under 10 minutes or so. Give it a spin, and relive ye olde monochrome graphics adventure.

And yes, I know that Zork I was not a graphical adventure. However, it sort of defines the genre (sans graphics, admittedly), so bugger off!

Tuesday, April 11, 2006

On Vacation

So, I decided that since I had to cut my Christmas / New Year's vacation one week short (due to work) that now seemed as good a time as any to take that week off. The weather has been improving (today was gorgeous, perfect Spring weather for San Diego), the kids are on break from school, and I could use the break from work.

Today I made a killer steak and eggs burrito breakfast, surfed and had fun with the kids at the beach, rested a bit at home, then tackled baseball practice in the afternoon. You know, I think I could seriously live like this, sans work, if you know what I mean! If only we didn't have those nagging monetary needs... ;>

So, I'll be out of the office for a few more days, and plan to enjoy all of it.

Saturday, March 25, 2006

What's Up?

Well, things have been real quiet around the blog lately because things are anything but quiet in life. Baseball and softball monopolize four out of the five work evenings, as well as Saturday. That leaves Friday night to collapse and Sunday afternoon to get done all the things that should have been done during the week.

However, it is fun watching and helping the kids play ball. The AA baseball team I am managing (the Raptors ) won our first game today, 10-9. We now have one win, one loss, and two ties (3-3 and 16-16!). Life is good.

Friday, February 24, 2006

The Launching Pad


The picture above is from Wednesday, December 21st, 2005. With the winter sun lower and to the southwest, I thought the back-lit take-off zone at Swami's was particularly beautiful. Watching the wave regularly jack up and over the reef is one of the more amazing sights on a large swell day. Posted by Picasa

Wednesday, February 22, 2006

Swami's, Big Wednesday - Dec. 21, 2005


The day after I took the picture below (at D Street), the bulk of northwest swell slammed into North San Diego county. Swami's picks up these winter NW swells exceptionally well, and the reef can hold wave sizes of triple-overhead plus... as the picture above can attest!

Friday, February 17, 2006

D Street in December


December was very good to surfers in North San Diego county. The above picture was taken on December 20, 2005 at D street in Encinitas. An alternate title for the picture I like is, "A Shoulder to Cry For". Posted by Picasa

Thursday, February 16, 2006

It's Baseball Season Again


... and our brief period of no youth sport practices and games has come to an end. Between the end of soccer (November or so) and the beginning of baseball / softball (February), Theresa and I enjoy a couple of months when we don't need to be somewhere just about every day of the work week plus Saturdays.

But baseball season is now back, and our rest is over! I am managing my son's AA team this year - the Ogden Raptors (that would be the real team web site, not our team web site). Being a manager is a bit of a handful, especially when about half of my team has never played ball before. Ay carumba!

Still, it is my sincere hope that rushing around and keeping up with the kids helps to keep us young. If you have found this to be untrue, please keep it to yourself as it's what I'm going with for the time being.

My oldest (and only) daughter is playing softball again this year, and thankfully my youngest son is too young to play any sports yet. So, we have softball practices on Monday and Wednesday. Then there are the baseball practices on Tuesday and Thursday. Games will be held on Saturdays and at least one game during the week. Oh yeah!

In all seriousness, I really do believe it keeps us (my wife and I) active. We meet lots of new people, and get to know better those we already know. I love working with the kids, almost all of whom are out there just having a good time playing a team sport. And with the cutbacks in physical education I've seen at our elementary school just over the past 5 years, it is a good way to get the kids outside and off their butts.

"Take me out to the ball game.
Take me out with the crowd.
Buy me some peanuts..."

Well, I gotta get ready for practice now! :>

Friday, February 03, 2006

How to Salvage a Subversion Screw-Up

Yesterday, one of the developers at work attempted to add approximately 14,000 files to one of our subversion (aka svn) source control repositories. The svn server itself resides on a linux box, but the interface the developer used was TortoiseSVN, a Windows explorer based interface that is pretty slick.

Anyhow, the attempted addition of 14K files caused TortoiseSVN to choke. Futhermore, actually checking out the repository with all of these files added takes almost an eternity in developer time, and also causes TortoiseSVN to choke.

So, I knew what I had to do - remove the files added in the offending transaction. Now, how do I do that?

After a bit of googling about and reading through the administration chapters of the svn book, I realized that I would have to dump the repository (minus the offending transaction), and then rebuild a new one.

Looking over Trac (our project management app that integrates nicely with svn and provides bug/ticket tracking etc.), I found that revision 688 was the culprint. Thus, after a bit of trial and error, I finally zeroed in on the following comman (executed from the bash shell on the linux box) to dump the repository as desired:

svnadmin dump [repository path] --deltas --revision 1:687 | gzip > ~/dumpfile.gz

Next, I renamed the old repository directory to [repository path].old, and created a new repository to fill back up.

Finally, the step I was waiting for - loading the new repository up with the good transactions:

gunzip -c ~/dumpfile.gz | svnadmin load [repository path]

After a few minutes of churning away, svn finally notified me that revision 687 was committed, and I am now ready to go! Woo-hoo!

Friday, January 20, 2006

The Great Pink Eye Epidemic of 2006

Ah yes... the first major infectious epidemic of 2006 to ravage through our house seems to finally be contained. I am speaking of Pink Eye, clinically known as conjunctivitis. Like a trained fictional CSI agent, let us relive the infection by winding back time in CGI generated timeline goodness:

Dec. 26, 2005: A grand time is had by all while visiting with my relatives up in Orange County. My brother's newest child (almost 1 year of age) has pink eye, so we are all careful to wash our hands after holding him, letting him jab us in the eye, etc.

January 2, 2006 (aka I-day): It seems not all of us were as careful as needed. Peter, my youngest son of 3 years, now has pink eye. I simply can not tell you in words how much fun it is to try and get the eye drops actually in his eyes. Oh joy.

I-day + 3: Jasmine (my daughter) now in infected. She handles the eye drops with aplomb, and Peter is now getting used to them. Perhaps we will contain this strain to these two?

I-day + 6: My other son, Alan has fallen to the microscopic varmints. Curses! Who will fall next? I look at my wife knowingly and realize that it is just a matter of time... Perhaps if I were to go feral and live outside with the dog I could escape becoming a victim?

I-day + 9: Mother has fallen to the ranks of the eye-terrorists! On the other hand, Peter is done with his run of the medicine. At least that's a good thing.

I-day + 11: Peter is infected again. Man, does it get any better than this?

I-day + 13: I guess it does! Now we are all infected, but that means we are all also on medication.

I've been on my meds for almost four days now, and it looks as if the quarantine has been lifted on our residence by the CDC. Everyone but me has finished their run of eye drops, and it looks as if we will win this battle in the next few days. HOO-RA!

Monday, January 09, 2006

First Surf Report of 2006

subtitled, "It's About Damn Time"
The holidays have come and gone, and we are all still alive. That's always a good thing, I think you'll agree. I need to post up a few pictures from the holidays, but they are at home and I am at work, so those will have to wait for another update.

During the end of December and the beginning of January, I took 7 days off. During this time, I did many things having absolutely nothing to do with surfing. I got a lot of stuff done, saw a movie with my kids, and enjoyed sleeping in for those seven days - but I didn't surf one day.

So, when I came back to work last week and got back into the water with big surf, you can guess the consequences. As I get older, I find that taking time off from surfing will make me pay dearly when next I go in. And pay dearly indeed, I did.

On Thursday and Friday of last week, I paddled against the oncoming waves, duckdiving and paddling until my arms resembled wet vermicelli noodles. After 20 minutes of paddling both days, I consoled myself with this hollow platitude: "Well, at least I got some exercise".

Today (Monday) was the beginning of a new week. Over the weekend I performed minor ding repair surgery on my beautiful turbo canard quad fish (shaped by Gary Hanel), and decided to take her out for a spin today.

Victory at last! The smaller waves and increased endurance from my previous two outings allowed me to get out there and catch a few fun waves. My arms are now tired, but in a good tired kind of way, if you know what I mean. I'm not back to my pre-vacation form, but I can feel myself getting there!

Here's hoping you had a wonderful Christmas, and a safe and prosperous New Year to come.

Tuesday, December 20, 2005

Monday Surf Report - "Humbled"

I haven't posted to the blog in a while, since I've been extremely busy at work (getting ready for my vacation) and at home (getting ready for the holidays). Furthermore, a plague descended upon our family over the last week, infecting all but the strongest of our clan (my wife - mothers aren't allowed to get sick, I guess).

So feeling moderately better yesterday (Monday), which means I was spewing out a relatively smaller amount of chunky green phlegm balls, I decided to try and hit the water again and get a few waves under my wetsuit. Great idea - poor timing!

All this week we have some good sized swell coming to our coast, with some truly gargantuan waves forecasted for tomorrow (Wednesday). So, not being in the best paddling shape, I tried to paddle out through the crushing beach break. After 20 minutes of fighting against mother nature, my arms were spent. Humbled for the first time in I don't know how long, I paddled back into shore.

I'm getting ready to go and give it another shot today, before the monster swell arrives tomorrow. Tomorrow will be a picture day, I'm thinking...