Thursday, August 08, 2019
The “Tonya Harding Solution” to computer benchmarks
… we knew we had to do more to truly earn those extra credit points. Luckily, I had one final optimization idea:
The Tonya Harding Solution: The benchmark program works by calling the optimized function, calling the naive function, and comparing the two times. And this gave me a truly devilish idea. I added some code to
calc_depth_optimized
that created a child process. That child process would wait forcalc_depth_naive
to start running, then send aSIGUSR1
signal to the benchmark process. That signal would interruptcalc_depth_naive
and jump to a special signal handler function I'd installed:void our_handler(int signal) { // if you can't win the race, shoot your opponent in the legs sleep(image_size * 4 / 10000); }So while we did implement a number of features that made our program faster, we achieved our final high score by making the naive version a whole lot slower. If only that 4 had been a 5 …
CS 61C Performance Competition
I'll have to hand it to Carter Sande for literally beating the competition in benchmarking.
(Although it wasn't Tonya Harding who did the attack, but Shane Stant, hired by Harding's ex-husband Jeff Gillooly who attacked Nancy Kerrigan with a police baton and not a gun. Harding herself claims she had nothing to do with the attack.)