Faster Playback: How Upgraded Language Gives Moab Wings

I listen to a lot of audio books on my smartphone. One of my favorite options in the app lets me adjust playback speed; I often rip through novels or non-fiction books at twice normal speed.


The science that makes this possible is more sophisticated than you might guess. A naive “fast playback” feature would suffer from a “chipmunk effect,” since compressed sound waves have higher frequency and thus distorted pitch. If you’ve ever spoken after inhaling helium, you know what I’m talking about. To preserve both comprehension and the “artistic feel” of the audio book, the code in the app has to analyze wave forms and crossfade (overlap) neighboring peaks and valleys that are congruent. Done right, this turns a slow narrator into a speed demon without any loss of comprehension, and without other unpleasant distortions. It’s a nifty trick.

Faster Software

Wouldn’t it be great if software had a “faster playback” option? :-)

Well, now it does, sort of. We’ve written a lot, recently, about the first round of optimizations produced by our Ascent initiative. After plenty of measurement and experimentation, and some ambitious design changes, we’ve moved the needle on the scale and performance of our stack in important ways. In fact, at ISC this week, Adaptive Computing is offering the whitepaper, “Operation Radical Ascent” that details the approach and its outcomes. Stop by booth #710 to learn more. You can run Moab at 2x-3x the old familiar speed, and it works great.

One Ascent improvement that we haven’t mentioned so far is a bit more esoteric:

We upgraded our programming language.

Specifically, we moved our C/C++ codebases to a refined version of the syntax called “C++ 11.” This change required updated compilers as well as alterations to source code itself. It has already paid dividends, and it will continue to do so for years to come.

Why Language Matters

If you know much about software engineers, you know that the pros and cons of various programming languages can be a touchy subject. Each language has its promoters and detractors, and the factors that make a language the “right choice” in certain circumstances are complicated. I am a pragmatist at heart, so when I recommended this language change, I wanted to be sure it was a slam-dunk.

Here is what the updated language gave us:

Richer mechanisms for modeling parallelism

Since a major emphasis in Ascent was making Moab more parallel, so it would scale with hardware, it was important that our language provide read-write locks, atomics, specialized mutexes, thread-local storage, and other enabling techniques. The old version of the codebases let you build these facilities yourself; C++11 gives you well-tested, thoroughly optimized versions out of the box.

Primitives to eliminate copies and run-time computation

Computer programs often spend lots of time copying data from one memory location to another, re-initializing objects, and remembering more than what is strictly necessary. The reasons for this are partly driven by abstract architectural concerns such as encapsulation, and partly by the nature of the Von Neumann computing model itself. C++ 11 introduces R-value references, std::unique_ptr, std::shared_ptr, std::call_once, and constexpr–constructs that help make programs lean and mean. The speedups from constexpr cannot be matched even in assembly.

Protection from data races, deadlocks, and resource leaks

Besides smart pointer classes, C++11 provides guarantees about the atomicity of static object initialization, correcting a long-standing flaw in older versions of the language.

A community of programmers comfortable with the complexities listed above

Perhaps most importantly, developers who use C++11 are excited about the ways it enhances our tool repertoire, and are eager to answer questions and support one another. This is a positive change from the C/old C++ environment, where parallelism and optimization were often viewed as “yucky” problems to be avoided where possible.

One interesting proof-point for the value of C++11 is the impressive speed and stability of Nitro (Moab Task Manager). This codebase was built in C++ 11 from the ground up, and is mind-bogglingly parallel. At any given moment, it may be doing dozens or hundreds of different computations—yet it passes our most demanding “leak check” tests with flying colors, and never seems to break a sweat under crushing workloads.

We have just begun to take advantage of C++ 11 goodness. I expect it to play an important role in future rounds of Ascent optimizations.

Facebook Twitter Email

Speak Your Mind