Graphics Programming Black Book (1997)
github.com
github.com
https://github.com/jagregory/abrash-black-book/blob/4028269f...
However, there's an interesting story behind this story. David Stafford, who came in first, posted that he thought he had the fastest solution and bet $100 that nobody could beat it. I posted my code which was significantly faster, and David tweaked it further to eventually win the challenge. Like a true person of honor, he did pay the $100 and I cashed his check.
I have my own little footnote in that book, somewhere, and know/have hung out with most of those guys. The old saying goes, "If you ever find that you're the smartest person in the room, you need to find another room," but it doesn't say what to do if you're pretty sure you're the dumbest guy in the room. It's good that the book is still in circulation despite its age, as there's a lot of wisdom left in it.
You should post your code when you get a chance.
You already forgot what Chapter 3 was all about :)
There's a lot in the book that's dated, being very VGA-specific, or specific to the x86 CPUs of that day. Even so, there are lots of ideas in the book that transcend that. His advice about optimization, and about how to approach problems, is timeless.
The specific parts probably can’t apply these days because systems are so complex (multi-core, multi-threaded, multi-processing) that you can never assume your assembly timing will be any way accurate.
I convinced my parents to buy this book for me as a gift when I was in high school. It taught me enough about x86 assembly language to reverse engineer the Windows driver for an HDTV tuner card to start writing a Linux driver, and the book still influences my views on performance and profiling.
2019 https://news.ycombinator.com/item?id=20883860
2017 https://news.ycombinator.com/item?id=14897512
2014 (a bit) https://news.ycombinator.com/item?id=8803883
2014 (a bit more) https://news.ycombinator.com/item?id=7149973
2013 (with michael_abrash) https://news.ycombinator.com/item?id=6659279
https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm
What's your thought on this?
Programmers that work on applications that work properly spend the correct amount of time optimizing.
Programmers that work on applications that don't work or don't get finished may or may not spend enough time optimizing.
Without profiling you're guessing where the most impactful work can be done. You don't want to spend a week shaving 150ms when you could have spent a day to make your program 10s faster.
Fortunately the linked book provides a simple way to decide when something needs to be optimized under "Understanding High Performance" [0]
--
Before we can create high-performance code, we must understand what high performance is. The objective (not always attained) in creating high-performance software is to make the software able to carry out its appointed tasks so rapidly that it responds instantaneously, as far as the user is concerned. In other words, high-performance code should ideally run so fast that any further improvement in the code would be pointless.
Notice that the above definition most emphatically does not say anything about making the software as fast as possible. It also does not say anything about using assembly language, or an optimizing compiler, or, for that matter, a compiler at all. It also doesn’t say anything about how the code was designed and written. What it does say is that high-performance code shouldn’t get in the user’s way—and that’s all.
--
(emphasis mine)
[0] https://www.jagregory.com/abrash-black-book/#understanding-h...
Rather think about the problem in abstract level, meaning data structures and algorithms for the problem being done.
For example if it is already obvious that the code section is going to work is large amount of data, doing linear search isn't going to scale.
Then also think about memory consumption, like maybe allocating all the time in a loop isn't the right approach, or if in a GC language that also supports value types, stack and global memory allocation, and off heap, consider where to place the data structures.
However don't over do it, and validate the assumptions with a profiler and the expectations of the end user.
An application doing batch processing overnight, no one is going to notice if it takes 5 seconds less with the algorithm that one has spent one week optimising for, other than the wasted developer budget.
On the other hand trying to do real time rendering at 120 FPS, every ms counts.
Sometimes it's not even possible to get any polynomial time solution, let alone quadratic.
I didn't realize that the physical black book was so expensive these days. I sure hope I kept my copy.
GPU Gems, ShaderX, GPU Pro, GPU Zen... there's so much optimization to be learned from them.
I have it on my shelf (w/ cd!). I bought it out of a bargain book bin from a computer store I worked at.
It helped me write a 3d engine.
Submitters: please don't editorialize in titles like that. This is in the site guidelines: https://news.ycombinator.com/newsguidelines.html.
http://www.jagregory.com/abrash-black-book/#chapter-16-there...