Hacker News new | ask | show | jobs
by hahnchen 1461 days ago
> Learn how to convince the CPU, memory, disk, and network to give you all the performance they're capable of.

How and where do you learn this? Can you link some resources?

1 comments

Unfortunately I don't have any -- I'm self-taught on the job. But as an example -- pick some project that involves high-bandwidth or low-latency I/O to multiple devices. Say, line-rate network packet capture to disk. Hold yourself to the standard of not dropping any packet. Try first 100 Mbps capture, then 1 Gbps, then 10 Gbps. Try first capture to SSD, then to HDD (higher latency). Progressively restrain the number of CPU cores and amount of memory you allow yourself to use -- try to get down to 2 or even 1 core, and under a GiB of memory. Add a requirement to minimize the latency to disk -- 1 second, 100 ms, 10 ms, 1 ms. Spec the problem to push disk and/or memory bandwidth requirements to their limits for your system -- if your code can't perform at the level the hardware should allow it to -- figure out why and address it.

You'll be forced to learn how to multiplex I/O streams. How to minimize memory copies. How to efficiently allocate and reuse memory. How to minimize system call overhead. What the more esoteric I/O system calls are. How to minimize pipeline stalls, cache and TLB misses. Which tools to use to measure all this stuff. If you're not finding these techniques necessary -- make the problem harder by raising the specs, limiting the resources more, or making the problem more involved (say -- build an flow index online for efficient seeking within the recorded data).

(This was basically my first major software project that forced me to learn performance optimization up and down the stack.)