Files
org-notes/performance-aware-programming/notes.org
Adam Mohammed 61a7438251 doit
2023-08-15 17:31:19 -04:00

1016 B

Performance-Aware Programming

Definition

Just knowing what you're doing can affect performance Not doing actual low level performance optimization for specific hardware

"If you understand CSS you should understand this"

Thinking about the CPU

If you think of a processor as a box which takes instructions as inputs and then they do some work before producing the output, you have two levers to pull for performance.

  1. Reduce the # of instructions Simplify the program or generally reduce the work that the CPU needs
  2. Speed of the Instruction Change the set of instructions you're passing through the CPU based on how much time it might take to process.

Prologue

In a simple python program below: We achieve ~0.006 adds/cycle

  def add(a, b):
      a + b

  c = 1234 + 5678

In the naive C version we're looking at ~0.8 adds/cycle

If we get smarter and do some optimization with SIMD we can achive up to 16 adds/cycle.