It’s all in the predicate

Although I might have ordered a new zippy MacBook – my old PowerBook is still proving its use: highlighting pieces of code that are just too slow.

In the iOnTV UI application the schedule grid (list of what’s on) is a critical part of the main window. I noticed that as the database of program information got larger scrolling performance in the schedule grid (going backwards/forwards in time) was terribly slow on my PowerBook.

A little time with Shark showed that I was spending 80% my time in the ‘fetch schedules on a station between two times’ method. This method used a simple predicate to fetch only those schedule details fulfilling the arguments :

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"((station == %@) AND (time >= %@) AND (time <= %@)) OR ((station == %@) AND (time < %@) AND (endTime > %@))", self, startDate, endDate, self, startDate, startDate];

A little thinking about it and I realized that the logic was overly complex and could be simplified :

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(station == %@) AND (((time >= %@) AND (time <= %@)) OR ((endTime >= %@) AND (endTime <= %@)))", self, startDate, endDate, startDate, endDate];

I don’t need to compare against the station more than once – start with everything on this station, and then consider only those things that start between the two times or end between the two times.

Result ? The fetch is now less than 10% of the CPU usage when changing the start time in the schedule grid ! Much better ! I still have a couple more optimizations to make – but watch those predicates !

Posted under Development, iOnTV

This post was written by awk on February 26, 2008

Roof Disposal

One of the more dangerous traditions at Be was that of ‘roof disposal’.

In the late 1990′s Flat Screens were completely unheard of other than on laptop PCs. Old CRT monitors were everywhere – and they weren’t necessarily very reliable. At Be CRT Monitors that died would usually end up in a pile in a cube or hallway and be labeled ‘roof disposal’.

Then a few times a year the actual act of ‘roof disposal’ would take place :

Or for an alternative view :

And yes – we knew that monitors contain a lot of pretty nasty chemicals, and yes we were careful to sweep up throughly afterwards.Also these events took place on the weekends when the Charles Schwab office on the ground floor was closed – and lookouts were posted. Not that it prevented JLG from coming out of the building and seeing the cleanup effort and saying “So that’s what Roof Disposal means”.

I’d been looking for these videos for a long time (even trying to resurrect an old BeOS installation to recover them – they were included on the BeOS R5 release CDs) – my thanks to a colleague at VMware who found them on YouTube and sent me the link.

Posted under Be

This post was written by awk on February 26, 2008

Fusion Developer Video

Shawn Morel is one of the developers on the Fusion Team here at VMware.Last year he gave a presentation (along with local Boston Mac Developer Daniel Jalkut) at the C4[1] developer conferenceWolf Rentzsch the conference organizer has started putting videos of the presentations on-line, he just posted the video of Shawn’s presentation. Daniels presentation was posted last week.

Posted under VMware

This post was written by awk on February 26, 2008

Finally !

It what was probably one of the most anticipated and predicted Apple Hardware announcements – Apple today announced new MacBook Pro’s and MacBooks.Like many I’ve been waiting since the beginning of the year to upgrade – my order is now in, it’s supposed to arrive by March 3.  

Posted under Apple

This post was written by awk on February 26, 2008