Linux uses the readahead technique to pre-fetch data into the page cache, speeding up file access in buffer I/O mode. The context readahead algorithm extends this by detecting interleaved sequential streams. In workloads with heavy random access, context readahead often misreads access patterns and prefetches more pages than needed, which degrades performance. Alibaba Cloud Linux 2 and 3 expose the vm.enable_context_readahead parameter so you can tune this behavior to match your workload.
Supported operating systems
The vm.enable_context_readahead parameter is supported on:
Alibaba Cloud Linux 2 with kernel version
4.19.91-18or laterAlibaba Cloud Linux 3
Check the current status
Run either of the following commands. The output is 1 (enabled) or 0 (disabled).
cat /proc/sys/vm/enable_context_readaheadsysctl -n vm.enable_context_readaheadConfigure context readahead
Use the /proc/sys/vm/enable_context_readahead parameter file or the sysctl interface to enable or disable context readahead.
Disable context readahead (recommended for random access workloads):
# Using the parameter file
sudo sh -c 'echo 0 > /proc/sys/vm/enable_context_readahead'
# Using sysctl
sudo sysctl -w vm.enable_context_readahead=0Enable context readahead (default state):
# Using the parameter file
sudo sh -c 'echo 1 > /proc/sys/vm/enable_context_readahead'
# Using sysctl
sudo sysctl -w vm.enable_context_readahead=1