By dom on Apr 12, 2008
"Solaris Application Programming" by Darryl Gove is an important new book which has just hit the shelves. It is aimed (In my opinion which cost me $60 to formulate) at the programmer coming from another operating system such as Linux or Windows where (s)he had a level of familiarity with the compiler and observability tools that enabled the writing of extremely fast code, fast. If you are at home with all the GCC options but need a high speed introduction to Sun Studio or just want to program closer to the hardware, but don't relish the prospect of attacking the CPU vendor's manuals, then this is for you.
What's in it
Before you can understand the compiler and how to get the best out of it, you have to understand the CPU and memory and this area is dealt with both for SPARC and x64 straight away. This is followed by the obligatory chapter on the observability tools provided with Solaris - essential reading if you are new around here but not so if you have the POD Book to hand.
Then comes the meat of the book - using the Sun Studio compiler to make computationally intensive code run fast. The target language is C, with forays into C++ and Fortran where necessarily. There is good coverage of floating point, fun with cache lines and the SIMD (on x64) and VIS (on SPARC) instruction sets. The CPU performance counter metrics for both those chips and how to utilise them are thoroughly examined - they provide the data but you have to turn that into information and the material here jumpstarts that process of understanding. There's a section on manually optimising code, caveated that much of what the books in this area teach you has also been taught to the compiler too and in many cases it can do that stuff better than you.
The final section of the book peels off from traditional sequential programming to the parallel model covering multiprocessor machines and multicore processors (CMT). In discussing this, the libraries to take advantage of the hardware capabilities are taken one by one - System V IPC, MPI, Pthreads and OpenMP.
What's not in it
As the title says, its about Solaris application programmming. Its about making code run fast. So it is not a lesson on the APIs available to the programmer - for that you have to go and read Rich Teer or Rich Stevens. Its not about the operating system (that's already covered off in McDougall and Mauro) or system performance, observability and debugging, which they (with Brendan Gregg) have also amply illuminated.
When you read the code samples in the book, you'll notice they perform almost no I/O - indeed use almost no system calls other than to get timings and output them to you the reader. By concentrating on a core subject in this way and keeping the code entirely focused Darryl enables the reader to become amazingly proficient in an area traditionally labelled "guru" (how I hate that word) in 446 pages - that is a huge achievment. If I have nits they are that there is no bibliography (There is a single footnote referenceing a single manpage) and the code is not provided for the all the examples that are run but this is minor chaff. I'd also note that you have to be able to read, or be prepared to learn to read, assembly language for the x64 and SPARC. But you know that anyway.
Where to find out more
I can't commend this book highly enough. Every topic that Darryl addresses, he does so with enough detail to get you up, running and proficient, but not so much detail that the going gets bogged down. Its a fine line and the call has been made right every time. If you know what you are doing in a programming environment, just not this one - then this book really is for you. Similarly if you have been playing the Solaris game for a while and are anxious to proceed to the next level, go buy!