usage of os.posix_fadvise

W

Wolfgang Maier

Dear all,
I was just experimenting for the first time with os.posix_fadvise(), which
is new in Python3.3 . I'm reading from a really huge file (several GB) and I
want to use the data only once, so I don't want OS-level page caching. I
tried os.posix_fadvise with the os.POSIX_FADV_NOREUSE and with the
os.POSIX_FADV_DONTNEED flags, but neither seemed to have any effect on the
caching behaviour of Ubuntu (still uses all available memory to page cache
my I/O).
Specifically, I was trying this:

import os
fd = os.open('myfile', os.O_RDONLY)
# wasn't sure about the len parameter in fadvise,
# so thought I just use it on the first 4GB
os.posix_fadvise(fd, 0, 4000000000, os.POSIX_FADV_NOREUSE) # or DONTNEED

then reading from the file with os.read() .

By its very nature, I suppose posix_fadvise's effects will be OS-dependent,
so my question is whether the lack of effect I'm observing is something
Ubuntu-specific, or if I'm just using it in a wrong way.

Any help is greatly appreciated!
Best,
Wolfgang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top