Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Aug 2011 11:38:33 +0400
From:      Lev Serebryakov <lev@serebryakov.spb.ru>
To:        Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: Very inconsistent (read) speed on UFS2
Message-ID:  <485583919.20110831113833@serebryakov.spb.ru>
In-Reply-To: <alpine.GSO.2.01.1108301735030.3028@freddy.simplesystems.org>
References:  <317753422.20110830231815@serebryakov.spb.ru> <201108302009.p7UK9CBQ085481@chez.mckusick.com> <103666698.20110831021404@serebryakov.spb.ru> <1693072185.20110831022933@serebryakov.spb.ru> <alpine.GSO.2.01.1108301735030.3028@freddy.simplesystems.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello, Bob.
You wrote 31 =E0=E2=E3=F3=F1=F2=E0 2011 =E3., 2:40:07:

>>>   I'll try this experiment with mmap() and touching every 4096-th byte =
of
>>> mapped memory instead of read(2).
>>  Strange enough, it gives only 40-50MiB/s and results are very
>> consistent.
>>
>>  It really surprise me. I didn't think, that there will be so much
>> difference, I was sure, that it will be almost equivalent speed.
> FreeBSD does not seem to default to sequential read-ahead when memory
> mapping is used with sequential page access.  Try using madvise()=20
> with the MADV_SEQUENTIAL option and see if it helps.
  It were results with MADV_SEQUENTIAL. Code looks like this: (error
checking is skipped here, but not in real code, of course):

fd =3D open(fileName, O_RDONLY | O_DIRECT);
buf =3D mmap(NULL, fileSize, PROT_READ, 0, fd, 0);
madvise(buf, fileSize, MADV_SEQUENTIAL);
gettimeofday(&start, NULL);
for (rd =3D 0; rd < fileSize; rd +=3D 4096)
    c =3D buf[rd];
gettimeofday(&end, NULL);
munmap(buf, fileSize);
close(fd);

> There are also MADV_WILLNEED, MADV_DONTNEED, and MADV_FREE.  Careful
> use of these options can help performance quite a lot when data is=20
> large compared to memory.
  It is too complex for simple linear read test :)

--=20
// Black Lion AKA Lev Serebryakov <lev@serebryakov.spb.ru>




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?485583919.20110831113833>