Force maximum performance for the NVIDIA driver in Ubuntu Oneiric

The NVIDIA X Server Settings app for Linux lets us tune the performance of our NVIDIA display adapter. On a laptop this is especially important as it lets you enable the power-saving features of the adapter to extend battery life. The adapter (and the settings app) default to “Adaptive” mode, which is a balanced mode that can scale up for performance but scale down for battery-savings.

The problem with Adaptive mode is that it doesn’t kick in as quickly as you might like. You’ll notice choppy behavior when scaling windows in Unity, etc. So if you customarily employ your laptop “like a desktop” or just want to force full-time maximum performance mode, the settings app will let you do so.

But wait, there’s a catch: the performance settings don’t seem to persist across reboots or even across logout/logins. The adapter will revert to Adaptive mode every time. This necessitates the annoyance of remembering to run the X Server Settings app each time you log in in order to re-set the power mode.

I have good news. There’s a straightforward hack to force maximum performance while on A/C power and fall back to the adaptive strategy while on battery. And the beauty of the hack is, you don’t need to touch the NVIDIA X Server Settings app at all for this. All you have to do is add a few configuration items to your Xorg configuration.

In Ubuntu Oneiric 11.10, you no longer edit the xorg.conf file like you did in previous distributions. You simply place configuration files in /usr/share/X11/xorg.conf.d/ and they will be loaded at X startup. For this hack, make a file /usr/share/X11/xorg.conf.d/05-nvidia.conf and put in it:

Section "Device"
Identifier "MyNvidiaDevice"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "NVS 140M"
Option "RegistryDwords" "PowerMizerEnable=0x1; PerfLevelSrc=0x3322; PowerMizerDefaultAC=0x1"
EndSection

Note that Identifier, BoardName etc. are indicative of my Lenovo Thinkpad T61 and may not match your own hardware. However, these lines are largely irrelevant to the way X runs. The key is the Option line. These configuration items direct the NVIDIA adapter how to handle performance scaling.

You can see exactly what these hex values mean and learn some other possibilities for the values by consulting this reference.

Hey, is that kitchen timer TSO’d?

I saw this picture of the space shuttle Atlantis this morning, and it made me smile.

Chris Ferguson, STS-135 commander, is pictured on the flight deck, surrounded by sophisticated, highly techn… hey wait! That’s a kitchen timer!  Not just any kitchen timer, but the very one that we have in our own kitchen:

My personal jury’s still out on whether this is one small step for Atlantis, or one giant leap for CDN Kitchen Timer.

Easy Doxygen code snippets for Xcode 4

Fred McCann has two great blog posts describing how to document  your Objective-C code with Doxygen, a popular and standardized documentation system for C, Java and other languages. His posts are extremely well-written and definitely worth a read; he takes you all the way from a basic introduction to Doxygen to generating the Doxyfile output.

But in Xcode 4 you don’t need to use a complicated scripting system to produce commonly-used Doxygen-compatible documentation. Xcode has a “snippets” facility that comes pre-populated with a variety of Objective-C snippets; let me show you how to leverage them.

Simple Doxygen documentation for a method might look something like this:

/**
Compute the distance to another waypoint in nm.
@param other the other Waypoint
@returns the distance in nm
*/

Why type all that over and over again? (And this is only a small subset of what Doxygen can do. In truth, the Doxygen system is very rich and, frankly, as complicated as you want to make it. Note that in this post I’m not covering Doxygen itself, just creating the code snippets.)

In Xcode 4 I use “dox <TAB>” to insert my custom method-documentation snippet. Here’s how you can do the same:

 Read the rest of this story...

  1. Activate the right-hand Utilities drawer and in the bottom of it, click on the curly braces {} to activate the Code Snippet Library.
  2. In the code editor, type or paste the code that you want to turn into a snippet; highlight it all.
  3. Drag the highlighted code to the Snippet library. (It can be stubborn and not want to drag. Holding the mouse button down for a moment before dragging seems to help.)
  4. Your snippet has been added to the Library; click once on the snippet and a callout window will show you the snippet and permit you to edit it.
  5. Add your own descripton, completion shortcut, etc. Any text you surround with <# #> marks will be highlighted with a blue bubble for quick tabbing and substitution.

Here’s the full snippet that I employ. It’s fast and it encourages proper code documentation.

/**
 <#description#>
 @param <#parameter#>
 @returns <#retval#>
 @exception <#throws#>
 */

CNN covers HealthWeaver, my team’s software for cancer patients

At the University of Washington I am a Software Architect in the Department of Medical Education and Biomedical Informatics (say that three times fast!) where I am embedded with a cancer research team.  We are working on ways to use software and the Internet to improve the lives and well-being of breast cancer patients.

On April 16 CNN profiled our HealthWeaver software and interviewed my professor and team leader, Dr. Wanda Pratt.  From the UW Information School News:

Dr. Pratt’s work with cancer patients profiled by CNN

CNN.com features a story about the work of UW iSchool Associate Professor Wanda Pratt and her team. The team has developed an online system called HealthWeaver. HealthWeaver includes a social networking tool, and aims to help cancer patients manage information about their care, get their questions answered and interact with others who can aid them in their treatment.

CNN reporter Elizabeth Landau interviewed Dr. Pratt and Biomedical and Health Informatics Ph. D. student Meredith Skeels after their research presentations at the ACM Conference on Human Factors in Computing Systems in Atlanta this week. Other members of Pratt’s team include Kent Unruh, who was instrumental in formulating the idea; Chris Powell, who programmed the system; and many breast cancer patients and survivors who contributed to the design. The HealthWeaver core research team includes Andrea Civan Hartzler, Pedja Klasnja, and Marlee Mukai.

The full CNN article: Social networking makes it easier for patients to ask for help

Perceptual blindness and the TSA

As any traveler knows, flying on commercial airlines involves a large number of inconveniences in the name of anti-terrorism security. Any critically-minded traveler recognizes that these mainly comprise a variety of theatrical measures that bear little resemblance to effective security. As a result, the TSA is criticized fairly and often for ineptitude.

Let’s just take as granted that the TSA’s personnel act in 100% good faith, for the moment. Stepping back from the plethora of highly relevant and appropriate criticisms above, I have a more philosophical question: is the TSA engaging in perceptual blindness?

Also known as inattentional blindness, this is the phenomenon of not perceiving things that are in plain sight. It most easily manifests when a person engages in extreme mental focus — the mere act of focusing on task or stimulus A causes the person to completely miss stimulus B.

Need an example? In this short video, you’ll see two groups of people passing basketballs around in a circle. Your task is to count the number of times the WHITE t-shirts pass the ball while ignoring the BLACK t-shirts.  (I’ve linked directly to the researchers’ video instead of embedding it.)

Don’t read further until you’ve watched the video!

Were you able to keep the balls mentally separated? How many passes did you count? 14? 17?

And by the way, did you see the person in the gorilla suit stroll through the scene? If you didn’t you’d better watch it again.

This video comes from a well known study conducted by researchers at the University of Illinois and Harvard University. The researchers found that half of test subjects failed to see the gorilla. This and other studies have confirmed that when people concentrate too heavily on one specific target or task, they often miss obvious — yet unexpected — stimuli.

If the TSA’s security theater has them over-focused on “shoe bombs” and “three ounces or less,” will they be ready to spot the obvious, yet unexpected, REAL threat?

Election Theory

In the USA we customarily use “plurality voting” to choose elected officials. This methodology’s chief advantage is its simplicity: each voter casts a single vote for a single candidate, and after the numbers are totaled the candidate with the most votes wins. It’s a system that is easy to administer and for the voters to grasp: “designed by geniuses to be run by idiots” as the saying goes.

But the 2000 presidential election exposed a rather severe problem with this simple system. Mr. Nader’s “stolen” votes are commonly believed to have been behind Mr. Gore’s loss, in that those voters would likely have preferred Mr. Gore over Mr. Bush. This splitting of the vote is known as the “spoiler effect” and is often cited as plurality’s chief flaw.

A common fallacy is to think that plurality voting is the only — or even best — election methodology. Voting theory emerged as a legitimate field of academics before the French Revolution, so after over two hundred years of study the science can be regarded as mature.
Continue reading

Don’t get cleaned out by an Evil Maid!

As a proponent of encryption and security, I advocate the use of full-disk encryption (FDE) on any and every laptop computer. Used properly, your data thoroughly protected against nearly any belligerent third party. The problem is, full-disk encryption is no panacea: unless you understand associated risks, FDE may alter your behavior and leave you vulnerable to other attacks like “the Evil Maid.”

Vulnerabilities? What vulnerabilities?

This is purely a user-behavior problem in that the user, having employed full disk encryption, feels invulnerable. In the user’s mind, he has done everything right:
Continue reading

Permutations, Combinations: How to Calculate Arrangements

The words “permutation” and “combination” may not seem different in the general lexicon, but in mathematics they mean two very different things.

The terms relate to how many ways you can arrange elements of a set. These kinds of problems range from the trivial to having real-world applicability and utility; examples include:

  • In a committee of 5 people, how many ways are there to reach a majority vote?
  • Given 5 ice cream flavors, how many two-scoop choices are there?
  • How many 4-letter arrangements can be made from a 10-letter word?
  • How many different lock combinations are there on an old locker padlock?
  • An ATM machine has 10 numeric keys; how many 4-digit PINs are possible?

(By the way, the first two describe combinations; the remaining three describe permutations…continue reading to learn why, and to see the solutions.)
Continue reading

Ineffectiveness vs. effectiveness: the math behind the difference!

Let’s say you are shopping for a new home air filter. Comparing two models, you note that model A boasts that it blocks 99.9% of particulates; model B claims to block 99.8%.

That seems like a pretty minor difference. Would it surprise you to learn that model B is actually admitting twice as many particles as model A?

The reason lies in the terminology. When these machines claim to block N percent of particulates they are boasting about effectiveness. However, you don’t care about how effective the devices are — the true metric is how ineffective they are, because that is the part that impacts you. In the air-filter paradigm, the number of particulates that make it into your atmosphere is what matters.
Continue reading

Diagram? No, it’s a work of art.

Organizational Chart of the House Democrats' Health Plan

This is not a political post, despite appearances. My feelings verge more toward frank admiration — this chart flirts with genius. If there’s a Mona Lisa of presentational diagrams, this is it. It deserves the highest praise.

Remember, diagrams, charts and presentations can serve one of two purposes. They can be used to persuade or to inform, but rarely both simultaneously. The most insidious, of course, are those which masquerade as information but really intend to persuade.

This diagram is a premier example of the latter. Here we see an “Organizational Chart of the House Democrats’ Health Plan.” Yawn. Let’s watch some golf or water the plants or something, because those would be more stimulating, right? Wrong! To neglect this diagram is to bypass a shining example of communicative art.

Continue reading