Re: dvd+rw-tools update [6.0, DVD-R DL]
Joerg Schilling wrote:
Bill Davidsen <davidsen@tmr.com> wrote:
My belief is that if O_DIRECT is in the kernel headers it works. I would
love to have time to test timing of O_DIRECT on (a) disk, (b) partition,
(c) file on disk, and alignment on minimal vs. page size boundaries.
Doing O_DIRECT writes of anything avoids buffer pool collisions. To test
either hack mkisofs to write with O_DIRECT or pipe into Dwriter or
similar and see the difference in create time of a DVD image. I may
actually do the hack and enable it when -o is used (and on Linux). If I
do I'll put up the patch and post a link here. Then Joerg can reject it
because it makes mkisofs run faster on Linux.
Statements like this one from self called "Linux specialists" are an important
reason why "Linux specialists" constantly disqualify themself :-(
If you take the time you needed to write this for running a test, you would
know that O_DIRECT makes file I/O slower than by using the standard method.
Star needs only 40% of the system CPU time when using O_DIRECT, but slows
down by 30%.
And BTW: You cannot use O_DIRECT on Linux without defining __USE_GNU
but doing this uncovers broken prototypes that prevent compilation.
I'm attaching a tiny program to show that isn't the case. It's for
zeroing out large files. If you have a disk intensive application you
might run this to zero out say 50GB or so, and compare the impact on the
application with dd of /dev/zero using 1024k buffer size. The program
has compiled on rh7.2 thru FC4, SuSE, ubuntu, etc, no kernel headers or
GNU needed, you want the POSIX behaviour, or at least I do.
I used 040000 instead of O_DIRECT for my tests.
Needed only on really old installs, since any distribution which shipped
a kernel with the feature also should ship the user headers to compile.
My source has a check, I am running a 2.6.15 kernel on a RH7.3 hacked
base, so after the includes are read it will do the define if needed.
Jörg
--
E. Robert Bogusta
It seemed like a good idea at the time
// O_DIRECT test - measure speed of direct write
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
/* this allows compilation on a OLD test machine (RG 7.3) */
#ifndef O_LARGEFILE
#define O_LARGEFILE 0100000
#endif /* old includes */
#ifndef O_DIRECT
#define O_DIRECT 040000
#endif /* old includes */
#ifdef DIRECT
#define Attribs (O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE|O_DIRECT)
#else /* not direct */
#define Attribs (O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE)
#endif
#define MB (1024*1024)
int
main(int argc, char *argv[])
{
char *buffer, *temp;
int i, j, NumMB, stat, fd;
char *filename;
// sanity check
if (argc < 3) {
fprintf(stderr,
"Minimum two args!\n\n"
"Usage: zerofile len_MB file1 [ file2 [... fileN ] ]\n"
);
exit(1);
}
NumMB = atoi(argv[1]);
// allocate the buffer aligned in every case
stat = posix_memalign(&buffer, getpagesize(), MB);
if (stat) {
fprintf(stderr,
"Aligned buffer allocation of %d MB failed\n",
NumMB
);
exit(2);
}
// create and write the files
for (i = 2; i < argc; ++i) {
filename = argv[i];
fd = open(filename, Attribs, 0644);
if (fd < 0) {
fprintf(stderr,
"Unable to create file %s, skipping and continuing\n",
filename
);
continue;
}
// write the data to the file
for (j = 0; j < NumMB; ++j) {
stat = write(fd, buffer, MB);
if (stat < MB) {
fprintf(stderr,
"Write error on %s, short file\n"
"1 MB write only sent %d bytes after %d MB written\n",
filename, stat, j
);
break;
}
}
// close the file
fsync(fd);
close(fd);
}
exit(0);
}
Reply to: