advise#

Tell the kernel how the mapped region will be accessed.

Σύνοψη#

advise $map, 'sequential';
advise $map, 'willneed';

Ορίσματα#

  • $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.

Παραδείγματα#

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) { ... }

Οριακές περιπτώσεις#

  • Advising an unmapped scalar raises an exception.

  • Advising an empty mapping is a no-op.

  • advise is a hint to the kernel; it may do nothing on some systems.

Διαφορές από το upstream#

Fully compatible with upstream File::Map 0.71.

Δείτε επίσης#

  • protect - change read/write permissions rather than access hints.

  • sync - control flush timing explicitly.