summaryrefslogtreecommitdiff
path: root/klm/util/file_piece.cc
diff options
context:
space:
mode:
authorKenneth Heafield <kheafiel@cluster12.lti.ece.cmu.local>2011-05-20 16:19:04 -0400
committerKenneth Heafield <kheafiel@cluster12.lti.ece.cmu.local>2011-05-20 16:19:04 -0400
commitbc95fedbaa083d557840db6ac2cbf14e2a3eccce (patch)
tree00717d119814232577f7345ddbf2f224d58911e8 /klm/util/file_piece.cc
parent066dcbd87b6a59d4ef032001763eebf620fe4702 (diff)
kenlm update including being nicer to NFS
Diffstat (limited to 'klm/util/file_piece.cc')
-rw-r--r--klm/util/file_piece.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/klm/util/file_piece.cc b/klm/util/file_piece.cc
index 67681f7e..f447a70c 100644
--- a/klm/util/file_piece.cc
+++ b/klm/util/file_piece.cc
@@ -237,7 +237,12 @@ void FilePiece::MMapShift(off_t desired_begin) throw() {
// Forcibly clear the existing mmap first.
data_.reset();
- data_.reset(mmap(NULL, mapped_size, PROT_READ, MAP_PRIVATE, *file_, mapped_offset), mapped_size, scoped_memory::MMAP_ALLOCATED);
+ data_.reset(mmap(NULL, mapped_size, PROT_READ, MAP_SHARED
+ // Populate where available on linux
+#ifdef MAP_POPULATE
+ | MAP_POPULATE
+#endif
+ , *file_, mapped_offset), mapped_size, scoped_memory::MMAP_ALLOCATED);
if (data_.get() == MAP_FAILED) {
if (desired_begin) {
if (((off_t)-1) == lseek(*file_, desired_begin, SEEK_SET)) UTIL_THROW(ErrnoException, "mmap failed even though it worked before. lseek failed too, so using read isn't an option either.");