Rylik

Contents

How the machine works, from bits to data-oriented design, in twelve sections. Topics are written in any order; each names what it builds on.

3 of 108 topics written

1. Numbers in the machine

1.1

Bits and bytes

Not written yet

1.2

Binary and hexadecimal

Not written yet

1.3

Unsigned integers

Not written yet

1.4

Signed integers: two's complement

Not written yet

1.5

Bitwise operations

Not written yet

1.6

Integer conversions in C

Not written yet

1.7

Floating point

Not written yet

1.8

Endianness

Not written yet

1.9

Characters and text

Not written yet

2. The machine model

2.1

Instructions are bytes

Not written yet

2.2

Registers

Not written yet

2.3

A first NASM program

Not written yet

2.4

Memory and addresses

Not written yet

2.10

Looking inside with a debugger

Not written yet

2.5

Arithmetic and the flags

Not written yet

2.6

Bit instructions

Not written yet

2.7

Jumps

Not written yet

2.8

Talking to the OS

Not written yet

2.9

Project: a hex dump tool

Not written yet

3. C on the machine

3.1

C's types on x86-64

Not written yet

3.2

Reading what the compiler made

Not written yet

3.3

Variables live in memory

Not written yet

3.4

Pointers

Not written yet

3.5

Arrays

5 min
3.6

Pointer arithmetic

3 min
3.7

Arguments are copies

Not written yet

3.8

Casts and reading memory as another type

Not written yet

3.9

Structs

Not written yet

3.11

Strings are bytes with a length

Not written yet

3.10

Undefined behaviour, briefly

Not written yet

4. Data layout

4.1

Alignment, data and memory

5 min
4.2

Why the CPU wants alignment

Not written yet

4.3

Padding you can see

Not written yet

4.4

Aligning memory yourself

Not written yet

4.5

Arrays of structs

Not written yet

4.6

Struct of arrays

Not written yet

4.7

Bit fields and packing

Not written yet

4.8

Data that leaves the program

Not written yet

4.9

Project: an ELF/PE header viewer

Not written yet

5. Functions and the calling conventions

5.1

The stack

Not written yet

5.2

call and ret

Not written yet

5.3

The System V calling convention

Not written yet

5.4

The Windows x64 calling convention

Not written yet

5.5

C and NASM calling each other

Not written yet

5.6

Stack frames and locals

Not written yet

5.7

Structs in and out of functions

Not written yet

5.8

The stack's limits

Not written yet

5.9

Project: no recursion, a stack of your own

Not written yet

6. Memory from the OS

6.1

Virtual memory

Not written yet

6.2

Pages

Not written yet

6.3

Asking the OS for memory

Not written yet

6.4

Reserve and commit

Not written yet

6.5

Protection

Not written yet

6.6

Giving memory back

Not written yet

6.7

What malloc hides

Not written yet

6.8

Mapping files

Not written yet

7. Allocators

7.1

Why write your own

Not written yet

7.2

The stack allocator

Not written yet

7.3

Scratch memory

Not written yet

7.4

Caller-provided buffers

Not written yet

7.5

Pools

Not written yet

7.6

Arrays that grow without moving

Not written yet

7.7

Allocating everything up front

Not written yet

7.8

Catching overruns

Not written yet

7.9

Project: a word-frequency counter

Not written yet

8. Inside the CPU

8.1

The pipeline

Not written yet

8.2

Out-of-order execution

Not written yet

8.3

Branch prediction

Not written yet

8.4

Branchless code

Not written yet

8.5

Caches

Not written yet

8.6

Cache lines and layout

Not written yet

8.7

Prefetching

Not written yet

8.8

The TLB

Not written yet

9. Measuring

9.1

What a measurement tells you

Not written yet

9.2

Clocks

Not written yet

9.3

rdtsc and rdtscp

Not written yet

9.4

A micro-benchmark

Not written yet

9.5

Performance counters

Not written yet

9.6

Reading the tables

Not written yet

9.7

Project: a memory latency prober

Not written yet

10. SIMD

10.1

One instruction, many lanes

Not written yet

10.2

SIMD in NASM

Not written yet

10.3

Intrinsics in C

Not written yet

10.4

Padding arrays to the SIMD width

Not written yet

10.5

Compares and masks

Not written yet

10.6

Shuffles and horizontal work

Not written yet

10.7

Integer SIMD on bytes

Not written yet

10.8

Which CPU has what

Not written yet

10.9

What the compiler vectorises on its own

Not written yet

11. Lanes and threads

11.1

Cores and hardware threads

Not written yet

11.2

Starting threads

Not written yet

11.3

Atomics

Not written yet

11.4

Memory ordering

Not written yet

11.5

False sharing

Not written yet

11.6

Lanes and SPMD

Not written yet

11.7

Barriers

Not written yet

11.8

Splitting work

Not written yet

11.9

Work stealing

Not written yet

11.10

Project: a parallel SIMD CSV parser

Not written yet

12. Data-oriented design

12.1

Data and its transformations

Not written yet

12.2

Tables by type

Not written yet

12.3

One source of truth

Not written yet

12.4

Index tables, or reorder the table

Not written yet

12.5

Queues of deferred work

Not written yet

12.6

Hash tables over flat arrays

Not written yet

12.7

Handles instead of pointers

Not written yet

12.8

Tables in files

Not written yet

12.9

Project: a column store for CSV

Not written yet