c - mmap vs fgetc to avoid cache misses -



c - mmap vs fgetc to avoid cache misses -

i have programme read file fgetc() , 1 question asked "does using mmap() , unmap() can cut down amount of cache misses?"

to test wrote dirty piece of code given argument on command line, utilize mmap , address returned mmap or fgetc read file character character , used valgrind --tool=cachegrind on programme measure number of cache misses , mmap not cut down number of cache misses increment it

i have searched net day find useful resources help me understand why this. while can see loading our file memory because loaded in contiguous memory zone , read first character last, why increment cache misses?.

i looking particular resources or explanation might help me understand what's going on.

thanks in advance.

there several caches. guess talking kernel file scheme cache (or page cache), not cpu cache.

you utilize madvise(2) syscall give hints (after mmap, or pass map_populate mmap(2)) memory mapping, or utilize posix_fadvise(2) give hints (before read) file i/o.

if using stdio(3) want larger buffer (e.g. 64kbytes or more), see setvbuf(3). notice gnu glibc fopen(3) may able mmap m extension in mode.

see readahead(2). , linuxatemyram.

don't hope miracles, bottleneck hardware disk io.

c unix io

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -