On Linux (VM, WSL or cloud instance), measure virtual-memory behaviour. Record commands and outputs.
- Write a small Java or C program that allocates an array of 1 GB and (a) touches one byte every 4,096 bytes, (b) touches every byte sequentially, (c) touches pages in random order. Run each with
/usr/bin/time -vand record minor/major faults, time and maximum resident set size. Explain the numbers (how many faults for 1 GB with 4 KiB pages?). - Read a large file twice with
cat bigfile > /dev/nulland measure both runs with/usr/bin/time -v. Explain the difference using the page cache. - Run
vmstat 1while starting several memory-hungry programs until the system is under pressure (in a VM!). Identify the columns that show swapping and I/O wait. If available, read/proc/pressure/memory. - Check
cat /proc/sys/vm/swappiness,swapon --showand whether zram is used (zramctl). What would you configure on an 8 GB edge device running inference services, and why?