advise#
Tell the kernel how the mapped region will be accessed.
Synopsis#
advise $map, 'sequential';
advise $map, 'willneed';
Arguments#
$lvalue— a currently mapped scalar.$advice— a string naming an access pattern.
The portable values are:
'normal'— no particular pattern (the default).'random'— access order is unpredictable.'sequential'— read start to end once.'willneed'— prefault pages that will be needed soon.'dontneed'— release pages that will not be needed soon.
On Linux additional values are accepted: 'remove', 'dontfork',
'dofork', 'mergeable', 'unmergeable', 'free'. Unknown
values are silently ignored.
Examples#
Hint that a large log file will be scanned top to bottom:
map_file my $log, 'huge.log';
advise $log, 'sequential';
while ($log =~ /^(ERROR:.*)/mg) { ... }
Edge cases#
Advising an unmapped scalar raises an exception.
Advising an empty mapping is a no-op.
adviseis a hint to the kernel; it may do nothing on some systems.
Differences from upstream#
Fully compatible with upstream File::Map 0.71.
See also#
protect— change read/write permissions rather than access hints.sync— control flush timing explicitly.