• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: disk vs rdisk, was: How to obtain the FAT serial number form a volume
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: disk vs rdisk, was: How to obtain the FAT serial number form a volume


  • Subject: Re: disk vs rdisk, was: How to obtain the FAT serial number form a volume
  • From: Mark Day <email@hidden>
  • Date: Thu, 01 Mar 2012 10:35:04 -0800

On Feb 29, 2012, at 6:16 PM, Chris Murphy <email@hidden> wrote:

> On Feb 29, 2012, at 6:43 PM, Chris Suter wrote:
>> Try
>> increasing the block size that dd uses and see what happens. It
>> defaults to 512 bytes which will be too low.
>
> mingisapsycho:~ chris$ sudo dd if=/dev/rdisk0s4 of=/dev/null bs=1m count=500
> 524288000 bytes transferred in 6.813068 secs (76953289 bytes/sec)
>
> mingisapsycho:~ chris$ sudo dd if=/dev/disk0s4 of=/dev/null bs=1m count=500
> 524288000 bytes transferred in 18.793040 secs (27897988 bytes/sec)
>
> It's nearly a 3x performance difference.

If you run "sudo fs_usage -f filesys -w | grep disk0s4" in another window while you run the dd command (for /dev/disk0s4), you'll see something like:

10:14:48.995922    RdMeta          D=0x00000000  B=0x1000     /dev/disk0s4                                                                                                                                                    0.015779 W dd.2156416
10:14:48.996579    RdMeta          D=0x00000008  B=0x1000     /dev/disk0s4                                                                                                                                                    0.000551 W dd.2156416
10:14:48.996588    RdMeta[async]   D=0x00000010  B=0x1000     /dev/disk0s4                                                                                                                                                    0.000525 W dd.2156416
10:14:48.996884    RdMeta[async]   D=0x00000018  B=0x1000     /dev/disk0s4                                                                                                                                                    0.000208 W dd.2156416

See that "B=0x1000"?  That means the buffer cache actually issued reads of 4KB (0x1000), even though dd was doing 1MB reads.

When I use dd to read 4KB at a time from /dev/rdisk, for the same total size (count=128000), I get a time approximately the same as 1MB reads from /dev/disk, as I'd expect.  Chris Suter is basically correct; the problem is because the read sizes are too small to be efficient.  But it's not due to the size of the read being issued by dd; it's due to the size of the read generated inside /dev/disk's read() code as it goes through the buffer cache.

On my system, reading 1MB at a time from /dev/rdisk takes a little over 6 seconds.  Reading 1MB at a time from /dev/disk, or reading 4KB at a time from /dev/rdisk takes about 11 seconds.  Reading 512 bytes at a time from /dev/rdisk takes a whopping 73 seconds.  Reading 512 bytes at a time from /dev/disk takes just under 14 seconds (again, because it is actually issuing 4KB reads to the device driver, so 7 out of every 8 reads are actually cache hits in the buffer cache).

So let that be a lesson.  ;-)  Large I/Os are good for performance.

-Mark


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Next by Date: Re: disk vs rdisk, was: How to obtain the FAT serial number form a volume
  • Next by thread: Re: disk vs rdisk, was: How to obtain the FAT serial number form a volume
  • Index(es):
    • Date
    • Thread