Obviously there’s something wrong with the way I’m profiling perl scripts

I’m trying to reduce the memory foot print of my waypoint generation scripts. In order to see how much memory they use, I’ve been doing a (ulimit -v NNNN; ./CreateCoPilot.pl ….) and adjusting NNNN up and down to bracket where it fails due to lack of memory. I’ve had two problems with that:

  • The break point isn’t constant – a number will work on time and give me an out of memory error on the next run.
  • The numbers are nothing close to what I’d expect.

That second problem is the worst. Near the end of my script, after generating this huge (15,000 record) array of references to hashes, I sort it using the following code:

my $recordsArrRef = $self->{records};
my @newrecs = sort { $a->{waypoint_id} cmp $b->{waypoint_id} }
@{$recordsArrRef};
$self->{records} = \@newrecs;

It appears that at one point, there should be two arrays with 15,000 records in them, and yet when I benchmark the one where I’ve commented this code out against the one that has it, the unsorted one only saves 350 bytes. Ok, maybe it’s sorting in place, and all I’m saving is the actual code. Or maybe that isn’t the point of maximum memory usage. So then I looked in the Palm::PDB code, which is a library from somebody else. And at the end, after getting this array of hashes together, he goes through the array and encodes each one into binary, putting that into a different array. AHA, I thought, that means I’ve got the array of hashes and an array of encoded data records. Maybe what I should do is shrink the array of hashes as we build the array of encoded data. So I changed

foreach $record (@{$self->{records}})
{
...
$data = $self->PackRecord($record);

push @record_data, [ $attributes, $id, $data ];
}

to

while (defined($record = shift(@{$self->{records}})))
{
...
$data = $self->PackRecord($record);

push @record_data, [ $attributes, $id, $data ];
}

and I seem to have saved over 5,000 bytes. Not bad. But I think the has *got* to be a better memory profiling tool for Perl. Time to hit CPAN, I guess.

Oh oh

My linode has been off-line since 8:50 this morning. I checked thier support forum, and evidently 4 or 5 machines were off-line, linodes 39-43. (I’m on 41). The technician was checking into it. Then about 9:50, I suddenly couldn’t get into their support forum either. It looks like their whole site has gone tits up.

All my mailing lists are going to be dead until this gets fixed. Waaaa.

Time Warner is pissing me off

Time Warner were supposed to come to the new house to install cable (and more importantly, cable modem) some time between 4pm and 7pm today. Vicki was at the house from 1:30 on because some new furniture was delivered today, but she wanted me there to point out to the cable installer where I wanted the cable modem and the two TV drops. So I grabbed my laptop and the Linksys router which I’m not using any more (see many, many blog entries) and headed over. Got there at the stroke of 4pm. And waited. And waited. And waited. Helped Vicki put the curtains back up. Tightened some screws. Put some more screens in. And waited some more. Vicki went out and bought some food. Watched the last Doctor Who episode which I happened to have on my hard drive.

At 7:45 I called Time Warner to find out where the fuck the installer was. And they told me that the installer had been there at 4:59 and was unable to get in. I told her that her installer was a fucking bullshitter, as the house was continually occupied with both front and rear doors wide open and nobody drove down our driveway, nobody knocked on either door, and nobody rang any doorbells (actually I’m not 100% sure we have a door bell, but that’s besides the point). She then asked if I’d gotten the two messages they’d left me, and I said no, because I was away from my home phone at the new house WAITING FOR HER GOD DAMNED INSTALLER TO COME.

I got home, and found messages on our voicemail from 4:35 and 4:44 asking for me to confirm that I was going to be there for the installer. Since I told them when I booked the appointment that this was a house we hadn’t moved into, and since they called and left a message reminding me of the appointment yesterday, what the hell do they need me to confirm this? And why are they calling after the scheduled appointment time to confirm?

And just to make my annoyance complete, that 15 minutes I was on hold I was subject to continual commercials telling me how much better Time Warner’s customer service is than the satellite companies. Unless satellite companies actively come over and kick you in the balls while you’re waiting and then leave without installing anything, I can’t see how they could be any worse.

When did I become such a weather wimp?

Back in the day, I’d ski all winter in a skin tight lycra suit. If it was really cold, I might add poly underwear (Lifa brand, of course) to wick the sweat away and a T-shirt, and shorts because frostbite “down there” is excruitiatingly painful, believe you me. I’d orienteer in the spring and fall, and in the summer I was backpacking and canoeing, all of these things done in every condition from hot and humid to freezing rain and snow. I won’t say I was comfortable all the time, but I coped.

Now I can’t seem to get comfortable. Other people’s houses (like my dad and step-mother’s this weekend) are air conditioned to the point where I’m freezing, outside the heat and humidity hit me like a solid wall, and even in my own car where I have complete control over the airconditioning and heat felt like I could get the temperature about right but were still too humid. At least in the airplane I can get up to where the air is thin and cold and turn on the heat. But I just feel “wrong” all the time. And it sucks.

I wonder if the secret to being able to stand the seasons is to spend more time outside in them and less time in over heated or over air conditioned cocoons?

And this is supposed to save me time… how?

I got my DVD burner today. It’s a 16X, only $50 at Staples. I took a couple of DVD blanks from Steve, the guy whose DVD burner I’ve been using all along. They’re Verbatim 4x and I’ve never had any problem with them in Steve’s drive. But the first couple gave me some weird-ass error, as mentioned in a previous post. My cow orker Rob suggested I try K3B, which is what he uses. In the process of installing it, I needed to chase some dependencies, and one of them suggested that the version of the Linux kernel that I’m forced to use (for ClearCase dependencies) has a SCSI bug. I get it installed and Rob comes over with a blank DVD. This one is a Memorex 4X, but I didn’t think the different media was signficant. It burns cleanly while I’m logged in as root. I log in as myself and try to burn another DVD. I get a few percent through burning, but then the LEDs on my keyboard start flashing and the computer is hung. I power cycled. I thought maybe I’d corrupted that DVD on a previous burn attempt, so I try a few more, with different combinations of being logged in as root or not, being booted to the 2.4.20-8 versus 2.4.20-13.9 kernel, etc. Sometimes burning woudl get part way through and then tell me that I don’t have any media in the drive, other times I get the flashing LEDs and a hung computer. I made a bunch of coasters.

Then Rob tells me that DVD burners are far more sensitive to the media than CD burners are, and I should try the Memorex blanks again. I do, and it works first time.

On the way home, I stopped off and bought a 10 pack of Memorex blanks. Hopefully tomorrow I’ll actually get some work done instead of making coasters.

UPDATE: The Memorex DVD+Rs I bought burn nicely at 16X, and they boot just fine.