Skip to content

Commit

Permalink
Remove debugging code (use "cachestats" for that)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feh committed Feb 6, 2012
1 parent 0aa836c commit b88272e
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions nocache.c
Expand Up @@ -106,29 +106,9 @@ static void store_pageinfo(int fd)
goto cleanup; goto cleanup;
if(mincore(file, st.st_size, pageinfo) == -1) if(mincore(file, st.st_size, pageinfo) == -1)
goto cleanup; goto cleanup;

fds[i].info = pageinfo; fds[i].info = pageinfo;


#if DEBUG
fprintf(stderr, "cache stats: ");
int j;
for(j=0; i<pages; i++) {
fprintf(stderr, "%c", (pageinfo[j] & 1) ? 'Y' : 'N');
}
fprintf(stderr, "\n");

int j;
for(j=0; j<pages; j++)
if(!(pageinfo[j] & 1))
break;
if(j == pages)
fprintf(stderr, "was fully in cache: %d: %d/%d\n", fd, j, pages);
else
fprintf(stderr, "was not fully in cache: %d: %d/%d\n", fd, j, pages);
#endif

munmap(file, st.st_size); munmap(file, st.st_size);

return; return;


cleanup: cleanup:
Expand All @@ -142,6 +122,7 @@ static void store_pageinfo(int fd)
static void free_unclaimed_pages(int fd) static void free_unclaimed_pages(int fd)
{ {
int i, j; int i, j;
int start;


if(fd == -1) if(fd == -1)
return; return;
Expand All @@ -154,7 +135,6 @@ static void free_unclaimed_pages(int fd)


sync_if_writable(fd); sync_if_writable(fd);


int start;
start = j = 0; start = j = 0;
while(j < fds[i].nr_pages) { while(j < fds[i].nr_pages) {
if(fds[i].info[j] & 1) { if(fds[i].info[j] & 1) {
Expand All @@ -168,7 +148,6 @@ static void free_unclaimed_pages(int fd)
/* forget written contents that go beyond previous file size */ /* forget written contents that go beyond previous file size */
fadv_dontneed(fd, start < j ? start*PAGESIZE : fds[i].size, 0); fadv_dontneed(fd, start < j ? start*PAGESIZE : fds[i].size, 0);


if(fds[i].info) free(fds[i].info);
free(fds[i].info);
fds[i].fd = -1; fds[i].fd = -1;
} }

0 comments on commit b88272e

Please sign in to comment.