lseek/write
- From: golden <iang@xxxxxxxxxxxxx>
- Date: Sun, 18 Nov 2007 17:19:48 -0800 (PST)
Greetings.
I have a question regarding disk IO performance. I would like to
understand why exactly writes to a disk are faster when I use lseek as
opposed to not using lseek. The snippet of code that I am using is as
follows:
I would imagine that the write keeps track of the pointer after each
write, but my test does not bear that out.
Ultimately, I am trying to determine why writes are faster to my local
disk than to my SAN storage (EMC w/ cache). When I use the fsync,
writes are slower to san. When I do not use the fsync, writes are
faster.
I would appreciate any information regarding t his topic.
Thanks in advance.
for(int i = 0; i < 10; i++)
{
if (write(fd, buf, bytes) != bytes)
{
printf("write: \n");
exit (1);
}
if ( dosync ) {
if (fsync(fd) != 0)
{
printf("fsync: \n");
exit (1);
}
}
if ( doSeek )
{
if (lseek(fd, (off_t)0, SEEK_SET) == -1)
{
printf("lseek: %s\n",
strerror(errno));
exit (1);
}
}
}
.
- Follow-Ups:
- Re: lseek/write
- From: David Schwartz
- Re: lseek/write
- From:
- Re: lseek/write
- Prev by Date: Re: How to rename a partition
- Next by Date: Re: How to rename a partition
- Previous by thread: How to rename a partition
- Next by thread: Re: lseek/write
- Index(es):
Relevant Pages
|