DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 16th June 2010
sharris sharris is offline
Package Pilot
 
Join Date: Jun 2010
Posts: 146
Default Why is FreeBSD dd so slow?

Hello daemon forum,

May 8, 2010 I pass my Linux+ on-line course and I jump ship for FreeBSD the first chance I got. I been searching google for an answer for many months off and on, and today, all day and night all because I decided to give FreeBSD another try at dd'ng. I finally found a few threads with the same possible problem.

I notice while searching, many times there is a solution but no comparison which would makes the solution only a work around and truth is never gain in some cases. Here's an example and out of all of the hints I typed in google search box I only came up with these two thread from the entire world of BSD.

daemonforums.org/showthread.php?t=2077

and another one else where ...

Below should give you a general idea of the problem. I retested with clean partitions, reformatted exactly the same, complete shutdown and re-boot so there would be no side effects... I even done complete reinstall of all 21 partitions and 4 OS's many times and all FreeBSD's is always slow and get slower for no reason at all when you reverse steps, no matter what you do or how you do it. I use to say to myself, "LINUX is skipping something and FreeBSD is taking its time to do things right", but I never had a problem out any of my Arch-Linux dd style backups so today I concluded it's foolish of me to keep making excuses for FreeBSD. I'm at the point I don't beleive what I been seeing and I need some real life answers from experienced people.

Could someone please tell me what's going one here and how could this possibly affect a production system. It got to be something even if dd is not used directly, because if other functions use some of what dd (same line of code or two) does for other things in the systems and if so, there got to be some kind of unnoticeable effect. FreeBSD seems to be chewing on the wrong bits and pieces.

WIPE A PARTITION - FINAL:
dd if=/dev/zero of=/dev/ad4s2 (arch) 10,742,215,680 - 11.0GB - 114s = 2.0m - 94.0MB/s
dd if=/dev/zero of=/dev/ad4s2 (arch) 10,742,215,680 - 11.0GB - 793s = 13.0m - 17.0MB/s
dd if=/dev/zero of=/dev/ad4s2 (freebsd)10,742,215,680 - 11.0GB - 1418s = 23.0m - 7572536b/s


As you see it takes FreeBSD twice the time as it does Arch-Linux, even when Arch jump to 793sec but never over. FreeBSD will jump to over an hours at times which makes no since on a 10GB partition.

Also at this very minute it finishing:

CLONE A PARTITION - FINAL:
dd if=/dev/ad4s1 of=/dev/ad4s11 (arch) 10,742,183,424 - 11.0GB - 305s = 5.0m - 32.2MB/s
dd if=/dev/ad4s2 of=/dev/ad4s12 (arch) 10,742,183,424 - 11.0GB - 305s = 5.0m - 32.2MB/s
dd if=/dev/ad4s3 of=/dev/ad4s13 (arch) 42,952,379,904 - 43.0GB - 1231s = 21.0m - 34.9MB/s


As you see above, "CLONE A PARTITION" Arch-Linux has always did a good job and it is consistence 95% of the time no matter how many back to back repeats I do, 5 min for 10GB and 21 min for 40GB is the working average I always get.

But at this moment while writing this thread, cloning with FreeBSD has taken over three hour. Here are the final results and I am burn-out. The average is usually only ½ hour or a hour and 5 minutes even for FreeBSD, depending on how freebsd feel at the moment, I guest

20980827+0 record in
20980827+0 record out
10742183424 bytes transferred in 12376.074103 secs (867980 bytes/sec)


That's 3 hours and 26 min and it strange that record in and out are even??? That not the correct way I been getting. Should be (last three digits) 827-826 or vice-versa. Things change so much I can't remember anymore. I was suppose to be learning pf and ALTQ options today but you seen what I get ... 3-hours per 10GB


I have no programs installed so far except bash.

Partition 1: FreeBSD AMD - 10GB
Partition 2: FreeBSD i386 - 10GB
Partition 3: pcbsd AMD - 40GB
Partition 4: Arch-Linux and three happy back-up partiion
of same size 10GB - 10GB - 40GB and the rest for stoarge

As you may have figure, I am a real noob but my plan is, when I make a major changes, I may save one optimized for pf and another as a databbase and so on so. I rather dd to make a backup of the entire partition so there will be no possible flaws and moving from one machine to another is more easy for me to keep up with. Sorry for the long thread but I did'nt want to leave out any important detail.

Thanks in advance
Reply With Quote
  #2   (View Single Post)  
Old 16th June 2010
sharris sharris is offline
Package Pilot
 
Join Date: Jun 2010
Posts: 146
Default

I retried to be sure once again and it's official. This is a problem and not my imagination. I use difference downloads of FreeBSD running on virtually new modern hardware. So, just minutes ago, I just retried everything using Arch-Linux and these are some decent numbers for operation on two 10GB partitions of the exact same size:

dd if=/dev/sda1 of=/dev/sda11 ;;; it copied in 306.114 seconds
dd if=/dev/zero of=/dev/sda1 ;;; it zero-out 108.486 seconds
dd if=/dev/sda11 of=/dev/sda1 ;;; it restore in 308.414 seconds

Also, I understand that record in and record out are always the same size when you (dd) copy and restore.

In the end I will be dumping to do backups just like most other people but I think it's weak when you notice something wrong with one (known be perfect)standard but move on to something else that works, leaving behind a problem that may come back to bite an entire project or all of your work in the end just because no one paid attention or even knew it existed. If the creators of FreeBSD don't know already, maybe someone of experience will test and send in a bug-report so we can get some answers. I really like Arch-Linux, but not as a work-around for FreeBSD unless there is no hope.
Reply With Quote
  #3   (View Single Post)  
Old 16th June 2010
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

Hello and welcome!

I use dd with FreeBSD (7 and 8) quite often to erase disks with customer data. Depending on the disk this will usually go at about 100 / 120 MB/s. Which is not slow at all.

By default, dd uses a blocksize of 512 bytes (i.e. one sector). Try setting a larger blocksize such as 512 kilobytes: # dd if=/dev/zero of=/dev/ad0 bs=512k

For copying this should also result in better speeds: # dd if=/dev/ad4s1 of=/dev/ad5s1 bs=512k

Using a blocksize of 512 bytes is like moving a truck full of little packages from Amsterdam to Berlin one package at a time, instead of moving them in one big haul
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #4   (View Single Post)  
Old 16th June 2010
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

I don't know if it's the case with FreeBSD, but on OpenBSD, using the raw character device node instead of the block device is better, as it bypasses the kernel buffer cache, and this can even improve speeds (..using a larger block size as stated by Carpetsmoker).
Reply With Quote
  #5   (View Single Post)  
Old 16th June 2010
Oko's Avatar
Oko Oko is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 1,102
Default

Quote:
Originally Posted by BSDfan666 View Post
I don't know if it's the case with FreeBSD, but on OpenBSD, using the raw character device node instead of the block device is better, as it bypasses the kernel buffer cache, and this can even improve speeds (..using a larger block size as stated by Carpetsmoker).
What is your experience with softupdates? Is it going to improve or negatively affect the speed?
Reply With Quote
  #6   (View Single Post)  
Old 16th June 2010
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

I can't comment on that Oko, but, generally it's recommended to use the character device for most everything.. except mounting.

I'd assume is a good idea to unmount a partition before accessing it from either the block or character devices, so the contents don't change.
Reply With Quote
  #7   (View Single Post)  
Old 16th June 2010
sharris sharris is offline
Package Pilot
 
Join Date: Jun 2010
Posts: 146
Default

Thank you very much Carpetsmoker. I'm happy to have join your forum and I hope I will become as helpful for others as I see most of you guys are everyday. I got so much to learn before I can be sure of anything. After 16 week of being crammed with Fedora, you really don't remember things. Too much at one time, week after week, you want to try what you study (like Tripwire), but now, you got to do a 10,000000 word report about standards.

softupdates? Thanks Oko. The second thing that came up was Tuning Disks on a google search. It's now included for deeper review.

BSDfan666, could you please show me a few examples of what raw character device code looks like. I like the idea of bypassing the kernel buffer cache. Now I got a reason to recheck my Linux+ textbook, I remember reading about character and block device. School is especially good for terminology. I can build anything but never know the name of most items that I'm using. I hope to completely pin-point my problem by morning and post the results because I still see no excuse for this right now. Raw code with no flags should work nearly same for both OS I used. For now I think it's my set-up. It could be flaky by having 3-bsd's working on one another for one another and somehow detected it and got confuse. Completly dead files on another partition brought back to life somehow. I'll know by morning.
Reply With Quote
  #8   (View Single Post)  
Old 16th June 2010
phoenix's Avatar
phoenix phoenix is offline
Risen from the ashes
 
Join Date: May 2008
Posts: 696
Default

Quote:
Originally Posted by BSDfan666 View Post
I don't know if it's the case with FreeBSD, but on OpenBSD, using the raw character device node instead of the block device is better, as it bypasses the kernel buffer cache, and this can even improve speeds (..using a larger block size as stated by Carpetsmoker).
FreeBSD doesn't differentiate between "character" devices and "block" devices. There's only 1 device node.

@OP: You'll want to play around with the bs= setting, to find the value that works best for your disk setup. Generally, bs=1M works nicelyl. On some SSDs and fast disks, bs=16M is better. On other SSDs and disks, bs=128K or bs=512K works better. Only by testing your setup can you determine the best bs= to use.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
  #9   (View Single Post)  
Old 17th June 2010
sharris sharris is offline
Package Pilot
 
Join Date: Jun 2010
Posts: 146
Default

All the time I wasted, it's going to be a thrill speed testing. I always wanted to try difference setting but was not sure what to start with, plus the danger of trying when my disk was loaded. The only thing I can hurt now is the MBR. No real work is on the disk. Perfect for testing what Carpetsmoker laid-out, and Thank you phoenix for making everything all so clear. Now I got something real to work with instead of pointing fingers at the OS.
Reply With Quote
Old 17th June 2010
sharris sharris is offline
Package Pilot
 
Join Date: Jun 2010
Posts: 146
Default

That wasn’t so hard after all. Now I get it.
dd under Arch-Linux with-out a value given seem to default to 512k
dd under FreeBSD with-out a value given seem to default to 1b.

Using FreeBSD 8.0 - i386:
dd if=/dev/zero of=/dev/ad4s2 0000000 # 10,742,215,680 - 1367.571268s
dd if=/dev/zero of=/dev/ad4s2 bs=512k # 10,742,215,680 - 90.408628s

dd if=/dev/ad4s12 of=/dev/ad4s2 00000 # 10,742,215,680 - 3-hours PLUS
dd if=/dev/ad4s12 of=/dev/ad4s2 bs=1M # 10,742,215,680 - 239 seconds

The missing keyword everywhere I been: "You must give dd under FreeBSD a value unless you have plenty of time to spare"

Thanks again DaemonForums, I would have not tried this for another 6 month.

PS:
But one thing to beware of. If you are copying a FreeBSD version of a difference kind (i386 / AMD-64) to your extended DOS partitions and you try to copy it back some day like I just did using FreeBSD-i386 (on Par-1)... don't do it ... USE Arch-Linux, because when I just did it with FreeBSD it stripped or included the GEOM DOS label and FreeBSD on Par-2 did not work.

I did the exact same thing with Arch-Linux after re-booting and it worked. It all depends on what you're trying and this does prove that these OS use the dd program differently which in my case Arch-Linux does fine. FreeBSD need more code to fix the disk in this situation. So this way is easy and safer for what I just seen.
...............................
...............................

Partition 1: FreeBSD i386 - 10GB
Partition 2: FreeBSD AMD - 10GB
Partition 3: pcbsd AMD - 40GB
Partition 4: Arch-Linux and three happy back-up partiion
of same size 10GB - 10GB - 40GB and the rest for stoarge
Reply With Quote
Old 18th June 2010
sharris sharris is offline
Package Pilot
 
Join Date: Jun 2010
Posts: 146
Default

The last one is a good one because I want everyone to understand what happen in the end with Arch and FreeBSD. FreeBSD require some additional coding in this case. bye...
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
slow io from hdd knasbas OpenBSD General 3 25th July 2009 02:51 AM
Skype on FreeBSD 7.1 - works very slow.. DNAeon FreeBSD General 2 27th January 2009 11:48 AM
RtGUI load very slow mfaridi FreeBSD Ports and Packages 0 25th November 2008 01:47 PM
Why does BSD loads web pages slow? bigb89 General software and network 10 27th October 2008 06:38 AM
cupsd and sshd slow mururoa FreeBSD General 3 27th August 2008 08:36 PM


All times are GMT. The time now is 08:02 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick