summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_map.c
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2012-05-10 15:16:42 +0000
committeralc <alc@FreeBSD.org>2012-05-10 15:16:42 +0000
commit323d529ebe7c330677f5e4d24d72dec572424b4c (patch)
tree4bfd10bde8759957bf2dfba4b3364b5885e4e7d0 /sys/vm/vm_map.c
parent40edf7c8405482dfd501bafe1197a1b555305f7e (diff)
downloadFreeBSD-src-323d529ebe7c330677f5e4d24d72dec572424b4c.zip
FreeBSD-src-323d529ebe7c330677f5e4d24d72dec572424b4c.tar.gz
Give vm_fault()'s sequential access optimization a makeover.
There are two aspects to the sequential access optimization: (1) read ahead of pages that are expected to be accessed in the near future and (2) unmap and cache behind of pages that are not expected to be accessed again. This revision changes both aspects. The read ahead optimization is now more effective. It starts with the same initial read window as before, but arithmetically grows the window on sequential page faults. This can yield increased read bandwidth. For example, on one of my machines, a program using mmap() to read a file that is several times larger than the machine's physical memory takes about 17% less time to complete. The unmap and cache behind optimization is now more selectively applied. The read ahead window must grow to its maximum size before unmap and cache behind is performed. This significantly reduces the number of times that pages are unmapped and cached only to be reactivated a short time later. The unmap and cache behind optimization now clears each page's referenced flag. Previously, in the case of dirty pages, if the containing file was still mapped at the time that the page daemon examined the dirty pages, they would be reactivated. From a stylistic standpoint, this revision also cleanly separates the implementation of the read ahead and unmap/cache behind optimizations. Glanced at: kib MFC after: 2 weeks
Diffstat (limited to 'sys/vm/vm_map.c')
-rw-r--r--sys/vm/vm_map.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index 6198629..b74cec1 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -1300,6 +1300,8 @@ charged:
new_entry->protection = prot;
new_entry->max_protection = max;
new_entry->wired_count = 0;
+ new_entry->read_ahead = VM_FAULT_READ_AHEAD_INIT;
+ new_entry->next_read = OFF_TO_IDX(offset);
KASSERT(cred == NULL || !ENTRY_CHARGED(new_entry),
("OVERCOMMIT: vm_map_insert leaks vm_map %p", new_entry));
OpenPOWER on IntegriCloud