Bear with me here…

While most of my blog entries are an example to the world on how to write in a way that can appeal to everybody, this one is going to be mostly a reminder to myself.

I’m having problems with my waypoint generator on the Linode, mostly because with only 96Mb of real memory, each individual generator task quickly becomes too big and then tasks start swapping, and everything gets horribly I/O bound.

At first it seemed that things were dying right at the very end, and so I lept to the conclusion that it must be in the sort phase, where it takes all the records that it’s retrieved from the database and stuck into an array of references to hashs, and sorts the array by ID. I solicited some opinions on that, and got some good ideas on how to sort by ID in the database while still allowing the priority of datasources that I use now. The most interesting one said

select ...
from waypoints w1
where ....
and field(datasource 'FAA', 'DAFIF', 'Thompson')
= (SELECT min(field(w2.datasource 'FAA', 'DAFIF', 'Thompson'))
from waypoints w2
where w1.id=w2.id)
order by w1.id

But before I had a chance to implement it, I did some testing on my own machine using “ulimit -v” to simulate the reduced memory size. I ran an example query that produces a result file with 71197 records in it, honing in on the minimum memory size that would allow it to finish without getting an “Out of memory” error. Then I cut out the sort stage and did it again. And what I found surprised me. Cutting out the sort stage only saved me 375 bytes, reducing the memory size from 107625 to 107250 bytes. And made the time go from 1:46 to 1:35, a scant 10 seconds or 10%.

Looks like I’m going to have to find another way to reduce the memory footprint. And I keep coming back to this idea I had where I do the sorted query and write each record out to a temporary file as I retrieve it, storing only the id, PDB “unique id”, record number and the offset from the beginning of the temporary file. Then when that’s done, I go back and write the PDB file header, and the PDB file index (which consists of the offset from the beginning of the file, attibutes, category and the unique id), and then append the contents of the temporary file. That way I can avoid having the entire contents of the database in memory.

Side note about the PDB “unique id”: Each record in a PDB file has a 3 byte “unique id”. Normally when you’re creating a PDB file, you leave that as zero and the PDA itself fills it in when it loads the file. But when Laurie Davis created the CoPilot application, it used the unique id as the key to reference the waypoint records from the flight plans. So if I did leave them as zero and let the PDA fill them in, every time you reloaded your waypoint file your flight plans would get scrambled. So I maintain a table with a unique mapping between waypoint ids and “unique ids”. That way, even if you got, say, “KROC” from the FAA data this time and from the DAFIF data next time, your flight plans including KROC would still work, because both KROC ids would get the same “unique id”. That also means every time I load new data into the database, I have to find any ids that don’t currently have a “unique id” for them and generate some new ones. Occasionally I should purge no longer used ids and re-use their unique ids, because 3 bytes doesn’t give you a lot to play with.

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.

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.

DVD arrived, still not satisfied

After the company ordering system said that it would be several days before I got my DVD burner, my boss sent his secretary out across the street to Staples, who have one on sale for $50. I got it and installed it, but unfortunately I can’t burn to it. I get the following error:
Blocks total: 2297888 Blocks current: 2297888 Blocks remaining: 948384
Starting to write CD/DVD at speed 4 in write mode for single session.
Last chance to quit, starting real write in 0 seconds. Operation starts.
Waiting for reader process to fill input buffer ... input buffer ready.
trackno=0
BURN-Free is OFF.
Performing OPC...
Sending CUE sheet...
Starting new track at sector: 1349670
Track 01: 0 of 2635 MB written./usr/bin/dvdrecord: Input/output error. write_g1: scsi sendcmd: no error
CDB: 2A 00 00 14 98 26 00 00 1F 00
status: 0x2 (CHECK CONDITION)
Sense Bytes: 70 00 05 00 00 00 00 12 00 00 00 00 21 02 00 00
Sense Key: 0x5 Illegal Request, Segment 0
Sense Code: 0x21 Qual 0x02 (logical block address out of range) [No matching qualifier] Fru 0x0
Sense flags: Blk 0 (not valid)
cmd finished after 0.003s timeout 200s

I think I’m going to have to shut down again and check that I’ve got the devices jumpered correctly.

That burning sensation

At work I’m working on a way to upgrade our systems in the field from RedHat 7.3 and the 3.3 version of our software to CentOS 3.4 and the 3.4 version of our software, while preserving as much as possible of our current content and state.

I’m experimenting with custom install DVDs with my own kickstart file. It’s been a process of trial and error, mostly error, so I’m burning about 3 or 4 DVDs a day. Each time I have to go bother the guy with the DVD burner to make sure he’s not burning anything, then copy my ISO file over to his machine, eject his blank CD (he always keeps on in the drive in case he has to burn something when he’s not here), burn the DVD, and run over to put the blank CD back.

I put in a request for a DVD burner. They cost about $50 these days, or $60 if you need the dual layer, which I don’t. My boss approved it, and I suggested that I go out after work and buy one at Circuit City, but for reasons I don’t quite understand, we have to go through “IT Purchasing”, aka “Mordoc, Preventer of Information Technology Upgrades”. Mordoc is charging our department $129 for this burner, and I’m told I should have it in two to three weeks, by which time I should be finished this project and not need to burn DVDs any more.

If I had any need for an IDE DVD burner at home, I’d buy one, install it at work, and when I’m done with this project take it home.

I’m trying to count up how many different ways this is wasting the company’s money doing it this way, and I keep running out of fingers.