| Pt 1, ch 5 |
Address translation: 4 KB pages, four levels of page tables, the TLB |
The page walk above, and the root-to-leaf B+ tree in Roll Rush |
Every memory access walks a tree of 4 KB pages, the same way SQL Server walks its index pages. The TLB is the cache that makes it fast. |
| Pt 1, ch 5 |
Allocation granularity: VirtualAlloc reserves in 64 KB steps |
SQL Server extent = 8 pages x 8 KB = 64 KB; one 8 KB SQL page = two 4 KB OS pages |
SQL Server's page and extent sizes line up with how Windows hands out memory. |
| Pt 1, ch 5 + ch 7 |
Working sets and trimming; the SeLockMemoryPrivilege privilege |
warehouse-sql's buffer pool |
On a Windows SQL Server I know what 'Lock Pages in Memory' does: it grants SeLockMemoryPrivilege so Windows cannot page the buffer pool out. |
| Pt 1, ch 5 |
Look-aside lists, built on interlocked singly linked lists (SLIST) |
Forklift Undo: ConcurrentStack in Warehouse.Api |
My undo stack is a lock-free compare-and-swap LIFO, the same idea Windows uses for its look-aside lists. |
| Pt 2, ch 8 |
Synchronization: spinlocks, dispatcher objects, SRW locks |
The B+ tree engine's lock, and SQL Server's row lock in /api/orders/reserve |
Two orders can't take the last roll, because the check and the reservation happen under one lock. |
| Pt 1, ch 6 |
I/O completion ports |
strayer-server: one boss thread, 4 workers, a bounded queue of 8 |
An IOCP caps running threads at the CPU count and wakes the most recent waiter first: Windows' built-in answer to the thundering herd my C server handles by hand. |
| Pt 1, ch 3 |
Job objects: limits on processes, memory and CPU |
Docker limits on php-fpm, apache and strayer (Linux cgroups; Windows containers use job objects) |
Without a job object or a cgroup, one runaway process can take the whole machine down. |
| Pt 1, ch 7 |
Access tokens, SIDs, privileges |
Warehouse API signs in to SQL Server as sa |
Least privilege: each service gets its own login with only the rights it needs. sa is the database's SYSTEM. |
| Pt 1, ch 7 |
Integrity levels and AppContainers |
Internal Docker networks: b2r, strayer and rtos have no route out |
Sandbox the risky thing, so even if it's compromised it can't reach anything. |
| Pt 2, ch 11 |
NTFS keeps each directory as a B-tree index of file names |
Roll Rush's page-split visualizer |
A small folder lives inside its MFT record; a big one spills into 4 KB index buffers, the same page split shown in Roll Rush. |