fread + journaling = slow?
fread + journaling = slow?
- Subject: fread + journaling = slow?
- From: Paul Carnine <email@hidden>
- Date: Mon, 04 Oct 2004 09:38:34 +0200
Folk:
To make a *very* long story as short as I can, I am running into a
performance issue that has me scratching my head a little bit (and might
save somebody else some time in the future when list searching reappears).
The issue: when journaling is on, I see poor fread() performance.
Shark: all time is spent in semaphores in the kernel.
poor == 10x slower.
The code in question (see below) creates the following output:
***
Moe:~/proj/journal pdc$ time ./tj /{pathcut}/test.data
file size: 1984 kb (1.9375 meg)
total reads: 2031616
real 0m4.880s
user 0m0.120s
sys 0m1.130s
***
Do nothing else but this, using Disk Utility:
Turn Journaling Off on data file volume.
Unmount Volume.
Mount Volume.
***
Moe:~/proj/journal pdc$ time ./tj /{pathcut}test.data
file size: 1984 kb (1.9375 meg)
total reads: 2031616
real 0m0.413s
user 0m0.070s
sys 0m0.240s
***
4.9s vs 0.4s
And this extra 4.4s is not a constant time -- it's at least linear.
So, what gives? Is this normal behaviour? Any Ideas?
Yes, I have re-implemented my app to use mmap(), but issues I've run into
with that are forcing me to re-evaluate the original issue: slow fread()
when Journaling is on.
Thanks for any ideas and sorry so verbose,
-pdc
--- snip ---
/* compiled with "cc -o jt jt.c" */
#include <stdio.h>
static void scan(const char *fname);
int main(int argc, char *argv[])
{
if (argc != 2) {
printf("Usage: %s file\n", argv[0]);
exit(1);
}
scan(argv[1]);
return 0;
}
#define READ_SIZE 4096
void scan(const char *fname)
{
FILE *fptr = fopen(fname, "rb");
long size = 0;
char buff[READ_SIZE];
long idx;
if (!fptr) {
printf("can't open '%s'\n", fname);
exit(1);
}
fseek(fptr, 0, SEEK_END);
size = ftell(fptr);
fseek(fptr, 0, SEEK_SET);
printf("file size:\t%ld kb (%g meg)\n", size/1024,
(float)size/(1024.0*1024.0));
for (idx = 0; idx < size/128 ; idx++) {
long pos = rand() % (size - READ_SIZE);
pos &= 0xFFFF1000; // benefit of the doubt...
fseek(fptr, pos, SEEK_SET);
if (fread(buff, READ_SIZE, 1, fptr) != 1) {
printf("cant read at #%ld (pos: %ld)\n", idx, pos);
exit(1);
}
}
printf("total reads:\t%ld\n", size);
fclose(fptr);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden