Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jan 2017 13:04:48 +0100
From:      Hans Petter Selasky <hps@selasky.org>
To:        Aijaz Baig <aijazbaig1@gmail.com>, FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: Fwd: Understanding the rationale behind dropping of "block devices"
Message-ID:  <e8b83878-9e97-4aad-36f4-eba3ed5ef90e@selasky.org>
In-Reply-To: <CAHB2L%2BdHi34z3vzY3Fp3UHiZX-vDXB2tkPz7FOU_5Yx75VwQZw@mail.gmail.com>
References:  <CAHB2L%2BdRbX=E9NxGLd_eHsEeD0ZVYDYAx2k9h17BR0Lc=xu5HA@mail.gmail.com> <20170116071105.GB4560@eureka.lemis.com> <CAHB2L%2Bd9=rBBo48qR%2BPXgy%2BJDa=VRk5cM%2B9hAKDCPW%2BrqFgZAQ@mail.gmail.com> <a86ad6f5-954d-62f0-fdb3-9480a13dc1c3@freebsd.org> <29469.1484559072@critter.freebsd.dk> <3a76c14b-d3a1-755b-e894-2869cd42aeb6@rlwinm.de> <CAHB2L%2Bd1XG096SumiAk3VS7AE4cFLPfSCnCEjcWNXAeOxp2QCg@mail.gmail.com> <CAHB2L%2BdHi34z3vzY3Fp3UHiZX-vDXB2tkPz7FOU_5Yx75VwQZw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 01/16/17 11:56, Aijaz Baig wrote:
> Nevertheless, as had been mentioned by Julian, it appears that there is no
> "buffer cache" so to speak (is that correct Julian??)

Hi,

When you open the raw disk block device, like /dev/da0 for a USB disk, 
there is no buffering involved. Every read() and write() request which 
you make is transformed into a SCSI command and directly passed to the 
underlying device driver. I know Linux implements a cache for its 
"/dev/da0" and FreeBSD not.

However, if you do "mount -t xxx /dev/da0 /mnt" the filesystem layer 
might implement a cache for accessing files inside the mounted 
directory. Some filesystems like ZFS requires more memory for caching 
data to be efficient than UFS, for example. In FreeBSD you can use a 
tool called "dd" to measure basic disk performance. Compare it with 
Linux if you like:

Read test (block device):
dd if=/dev/da0 of=/dev/null bs=65536 count=10000

Write test (WARNING: This will destroy your disk contents)
dd if=/dev/zero of=/dev/da0 bs=65536 count=10000

Write test (filesystem):
dd if=/dev/zero of=/mnt/myfile.bin bs=65536 count=10000

Read test (filesystem):
dd if=/mnt/myfile.bin of=/dev/null bs=65536 count=10000

You can try running:

umount /mnt
mount -t XXX /dev/daX /mnt

Between the tests and see what happens.

Also see the "sync" command.

For more serious benchmarking you'll find some utilities in FreeBSD 
ports, /usr/ports/benchmarks .

--HPS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e8b83878-9e97-4aad-36f4-eba3ed5ef90e>