use madvise MADV_PREFETCH to implement iob_prefetch

master
leitner 21 years ago
parent 8873a442f2
commit e95599085a

@ -1,5 +1,6 @@
0.21: 0.21:
errno cleanup and man page updates (Rolf Eike Beer) errno cleanup and man page updates (Rolf Eike Beer)
implement iob_prefetch with madvise MADV_WILLNEED if it's defined
0.20: 0.20:
add errmsg API add errmsg API

@ -12,6 +12,12 @@ void iob_prefetch(io_batch* b,uint64 bytes) {
if (!e) return; if (!e) return;
for (; e<last; ++e) { for (; e<last; ++e) {
if (e->type==FROMFILE || e->type==FROMFILE_CLOSE) { if (e->type==FROMFILE || e->type==FROMFILE_CLOSE) {
#ifdef MADV_WILLNEED
char* c;
c=mmap(0,bytes,PROT_READ,MAP_SHARED,e->fd,(e->offset|4095)+1);
madvise(c,bytes,MADV_WILLNEED);
munmap(c,bytes);
#else
char* c,* d; char* c,* d;
uint64 before=bytes; uint64 before=bytes;
if (e->n<bytes) bytes=e->n; if (e->n<bytes) bytes=e->n;
@ -28,6 +34,7 @@ void iob_prefetch(io_batch* b,uint64 bytes) {
} }
munmap(c,before); munmap(c,before);
} }
#endif
return; return;
} }
} }

Loading…
Cancel
Save