VelociPeek

Eric’s weblog on tech

Monday, October 30th, 2006

Marine Corps Marathon Finisher

Song Of The Day: Breathe - Artist: The Prodigy

After all the preparation, my wife and I ran the Marine Corps Marathon yesterday. It was a beautiful day with the sun shining, with the temperature at approximately 60 degrees, and with approximately 100K spectators. Under these conditions I’m happy to write that my wife and I completed the race with times of 4:39 and 4:37, respectively.

However, we both are pleased the most by finishing another marathon, my wife’s 4th and my 2nd.

Congratulations to the marines, to all runners and supporters–truly an inspiring event. When the photos are available, I’ll be sure to post a few of them. Rock on!

Tags: ,

Tuesday, October 24th, 2006

White & Nerdy

So I was up early this morning contemplating various “happenings,” when I stumbled across Weird Al Yankovic’s latest video, White & Nerdy. That is one of the funnest music videos I’ve seen! It made me forget all else for the moment, which was quite welcome :).

Truly, laughter is like a good medicine.

Tags: , ,

Monday, October 23rd, 2006

Google Website Optimizer

Song Of The Day: Calling All Angels - Artist: Train

I found the launch of Google Website Optimizer rather interesting. Why? Well, it reminded me of Mike Conners’, former President of AOL Technologies years back, and his adage for one: If you cannot measure it, you cannot manage it. Being a long-time IBMer I think Mr. Conners learned a lot about measuring and managing.

Also, I think, Google’s launch adds merit to my own efforts of measuring, and gaining visibility into performance (i.e., not just speed), with tools like dent.

Customers, developers or consumers, desire better technologies and products to achieve their goals.

The challenge is that performance enhancements, and associated tools, may be an after-thought in product development cycles. In computer science one is typically directed to make it work and then to focus on optimization later. I guess there are multiple reasons for this tendency: time constraints, resource constraints, pragmatism (i.e., at least get it working), but the result can be poor product visibility and a lack of manageability overall. There are numerous examples of the repercussions from a lack of proper forethought: Pointcast and its push performance, Microsoft and its security performance, monetization of ads, etc?

Balance is necessary. Moreover, the whole discussion reminds me of a quote from Michael B. Johnson of Pixar: “Good tools obviate bad process.”

To strike a proper balance optimization initiatives should be interwoven throughout the fabric of a development cycle and not entirely pushed until the end IMHO. This can obviate opaqueness and poor processes.

We’ll have to watch how the Website Optimizer evolves, but I bet that if the customers gain visibility and manageability into their ads and sites, both the customer and business will benefit.

Tags: ,

Sunday, October 22nd, 2006

Countdown To The Marine Corps Marathon (cont’d)

Song Of The Day: Spitfire - Artist: The Prodigy

Okay, just a quick update on my Marine Corps Marathon training since the last time. I ran my last long-run today: 12 miles in 1:57. This was after very few runs the past 2 weeks because I developed a shin splint in one leg. Perhaps the break will help my overall time more than hurt me in the end (i.e., not just from keeping free injury but from the overall recuperation).

Although I ran the marathon in ‘02, I have to admit I’m getting anxious as we countdown to Sunday 10/29. :) At least there are no DC snipers out this time around!

Tags: ,

Thursday, October 19th, 2006

OS X, Cocoa, and dentp

Song Of The Day: Pushin’ On (Instrumental) - Artist: Dent


  

A while back I published a couple of blog entries about my interest in web-based network performance, modeling of that performance, and an open source initiative, called dent, which I initiated for research purposes. Well, today, I’m releasing a simple yet interesting application under the dent open source project called dentp, notice the “p” :).

dentp is an OS X, Objective-C, Cocoa application (i.e., OS X 10.4 or higher; also a universal binary) that behaves similarly to the ping command-line utility. Although the ping capability within dentp is relatively simplistic, there are various parts of the design and implementation that may be of interest to OS X programmers. For example, the application uses Cocoa and Objective-C, the source includes the entire Xcode 2.4 project, and the application utilized various technologies and frameworks including Interface Builder, Cocoa Bindings, NSThread, BSD sockets, OS X deployment bundles, etc.

So for those interested in OS X programming, I’d imagine that the application’s source could be a good reference app. I have released it with a tag of 0.1a (alpha) because it needs more testing, and possibly a few other tweaks, so let me know if you find issues or bugs. Also, the IPv6 references are a work in progress: IPv6 is not supported at the moment.

Also, with the experience I plan to direct all future dent project work to Cocoa and Objective-C (i.e., combination of C/C++/Obj-C source) and then migrate or port components to Firefox plug-ins and complementary capabilities (i.e., merge what has been done with what I am currently doing). The short reason, for why, is that it is much faster for me to model what I want to do with Cocoa and Objective-C than to continue the way I was–at least until more people join the project. :)

The binary bundle and source code is released under the MPL 1.1, so please read it before downloading.

The code is located on sourceforge here.

The OS X package bundle can be downloaded from sourceforge here.

In future entries I may have to delve into OS X technology and framework minutia, but for now….

If you install and then want to uninstall dentp, just delete the dentp application (e.g., by dragging the icon/directory to the trash can).

Also, the dentp application writes some user defaults, so you may purge these if you want by first checking them in a terminal window with:


einstein:~ eolaughlen$ defaults read com.erico.dentp
{
prefsHostnameLastUsed = 1;
prefsHostnames = (localhost, “velocipeek.com”);
prefsSliderCheckbox = 1;
prefsVerbose = 1;
}

And then by purging them with the following:


einstein:~ eolaughlen$ defaults delete com.erico.dentp

The defaults domain will likely be titled net.sourceforge.dent(or p) in the future and hopefully be more automated and friendly.

600) )4j

Tags: ,

Thursday, October 5th, 2006

Tivo Meets Jeep

Song of The Day: People of the Sun - Artist: Rage Against The Machine

Okay, so what happens when the delivery person leaves your ~$700 DirecTV HDTV Tivo replacement at your garage door?

Well, you accidentally run over it with 31″ tires, like I did yesterday, of course :). Fun. Please have a laugh. Fortunately, DTV is working with me on a no-expense replacement.

Tags: , ,

Wednesday, October 4th, 2006

Integer Overflow (Part 2)

Update (11/08/06): I “#ifdef’ed out” the ASM in the source code so–at least–the C functions could be compiled and compared on PowerPC Mac’s.

As a follow-up to my last post on this subject, I decided to roll my own C version of the safe-add function and to port the code to GCC using g++. The code, which is here, ports the MS SafeInt class, Sree Kotay’s test and functions, and the various ASM and C functions contributed by me and others. It has had limited testing, so it is offered “as-is” and with no warranties.

WHY

Overall, the topic is interesting and promotes better practices — hopefully. The primary reason for the port was two-fold: I wanted to use the code on non-VC++/Windows-based machines for experimentation and I was interested in the performance and nuances of the code with GCC and inline ASM blocks with other OSes (e.g., Mac OS X). Moreover, this may help broaden the audience for input and research.

THE PORT

The port was pretty straight-forward except for the inline assembly :). However, be forewarned that the NDEBUG constant is defined (i.e., no assert statements in the code) for GNU compilations to avoid assert-based incompatibilities between the VC++ and g++. Since NDEBUG is defined for “release” builds within Visual Studio, this didn’t seem too bad of a route. However, it would be nice to port this correctly at some point.

MY C VERSION

My attempt at a semi-portable C function is below:

#ifdef __GNUC__
inline long ericoSafeAdd (long a, long b)
#else
__forceinline long ericoSafeAdd (long a, long b)
#endif
{
    long c=a+b;
     if (((((unsigned long)a) & 0×80000000) != (((unsigned long)c) & 0×80000000))
      && (((unsigned long)a) & 0×80000000) == (((unsigned long)b) & 0×80000000)) {
        SafeIntOnOverflow();
     }
    return c;
}

I decided to go with a 1 branch, 1 compare in best cases using the integer signs. As a note, Sree cooked up a clever approach using the compare and branch in the calculation of the integer signs. See his latest blog entry on it here.

PERFORMANCE

This function performed well in certain cases, even against Sree’s latest version, but didn’t do as well in other cases. For example, with GCC (*1) with optimization disabled, I received the following:

[eolaughlen@darwin:~/Desktop/safeint] ./safeadd
——————– Testing Addition
——————– Math requiring no overflow detection
——————– This is for speed (overhead)
Test Simple… total: 149994981 Time = 816.634 ms
Test ASM Safe… total: 149994981 Time = 1370.143 ms
Test MS Safe… total: 149994981 Time = 5959.449 ms
Test sree C Safe… total: 149994981 Time = 1826.744 ms
Test erico ASM Safe… total: 149994981 Time = 1551.537 ms
Test erico C Safe… total: 149994981 Time = 1668.906 ms




——————– Math requiring overflow exception
——————– This is for correctness - ignore timings for ‘Simple’
Test Simple… total: 2053634475 Time = 748.037 ms
Test ASM Safe… total: 2147483638 Time = 660.812 ms EXCEPTION
Test MS Safe… total: 2147483638 Time = 1950.118 ms EXCEPTION
Test sree C Safe… total: 2147483638 Time = 600.973 ms EXCEPTION
Test erico ASM Safe… total: 2147483638 Time = 534.301 ms EXCEPTION
Test erico C Safe… total: 2147483638 Time = 550.815 ms EXCEPTION


hit Enter to continue….

As shown, the ASM version performs best with my C function being second. However, with -O3 defined in the compilation, Sree’s version performs best (~13% difference) with all ASM versions failing due to the optimizations:

[eolaughlen@darwin:~/Desktop/safeint] ./safeadd

——————– Testing Addition
——————– Math requiring no overflow detection
——————– This is for speed (overhead)
Test Simple… total: 149994981 Time = 178.267 ms
Test ASM Safe… <failure>
Test MS Safe… total: 149994981 Time = 836.534 ms
Test sree C Safe… total: 149994981 Time = 516.035 ms
Test erico ASM Safe… total: 149994981 Time = 242.764 ms
Test erico C Safe… total: 149994981 Time = 586.174 ms




——————– Math requiring overflow exception

——————– This is for correctness - ignore timings for ‘Simple’
Test Simple… total: 2053634475 Time = 180.317 ms
Test ASM Safe… <failure>
Test MS Safe… total: 2147483638 Time = 288.723 ms EXCEPTION
Test sree C Safe… total: 2147483638 Time = 182.712 ms EXCEPTION
Test erico ASM Safe… total: 2053634475 Time = 237.482 ms <failure>
Test erico C Safe… total: 2147483638 Time = 188.184 ms EXCEPTION


hit Enter to continue….


On Windows (*2) Sree’s version performs best in most cases (~10% faster). Every once in a while, my C version would do best, but believe this was data dependent based upon the integer signs.

CONCLUSION

Learn. Experiment. Try it for yourself. As with most development, there may be trade-offs between design versatility and performance and varying approaches may have their rightful use at times.


*1. Intel Core Duo 2 Ghz, Intel MacBook with Mac OS X 10.4.7 and gcc 4.0.1 build 5363

*2. PIII 1.13 Ghz, Dell Inspiron 8100 with Windows XP Home SP2 and VS/VC++ .NET 2003 7.1.3088

|