Kevin De Baerdemaeker

Performance-Aware Programming

Modified 2023-03-04

02 Waste

05:00

curious how javascript add function would look like disassembled

03 Instructions Per Clock

08:31

unrolling the loop does the extra ADD within the same CMP, effectively "skipping" the need to compare once

15:05

the cpu can only do all the ADD's sequentially, because of the serial dependency chain of the variable

04 SIMD - Single Instruction, Multiple Data

10:56

in essence SIMD packs multiple ADD's into what feels like a vector

26:26

combining SIMD and getting rid of the dependency change increases the speed 10x at least

05 Cache

06:06

register file produce values at maximum speeds

10:45

focus the "hot" data into the L1 cache for maximum data loading speeds, as the CPU can only process as fast as the data loads

06 Multithreading

21:03

the benefits for high workloads can surprise, because multithreading also splits up the cache

23:00

not all CPU's have enough memory bandwidth for the other cores, if it needs to load from RAM, or L3 (or any shared memory).

29:10

performance benefit can be in the same order as waste

07 Python Revisited

18:00

using the performance aware techniques you can think of how to optimize Javascript

22:30

there's ways to write optimized C code from within Python, not sure about Javascript, WebAssembly perhaps?

  • Fast Pixel Manipulation with Typed Arrays
  • Typed arrays - Binary data in the browser
  • C++ addons | Node.js v19.7.0 Documentation
  • node-ffi/node-ffi: Node.js Foreign Function Interface
  • Yet another attempt at FFI for Node.js
  • 08 Haversine Distance Problem

    16:17

    tackles the haversine problem, input with JSON and calculating an average, not as trivial as counting numbers, but not too complex either

    09 "Clean Code", Horrible Performance

    2:41

    list of clean code rules, that people often follow

    20:21

    no problem with DRY when it makes sense, the other clean code aspects give a 20x decrease in speed, which basically removes 15y of hardware improvements

    TODO 10 Instruction Decoding on the 8086

    Metadata

    Creator(s)

    Casey Muratori

  • Source
  • Recommended By

    Handmade Network

    Reason

    I'd like to figure if there's a way to write fast Javascript