Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Jul 2006 12:54:36 -0500
From:      "Rick C. Petty" <rick-freebsd@kiwi-computer.com>
To:        Dag-Erling Sm?rgrav <des@des.no>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: Advice for hacking on ufs/ffs
Message-ID:  <20060727175436.GA48057@megan.kiwi-computer.com>
In-Reply-To: <86lkqf1pum.fsf@xps.des.no>
References:  <44C6430D.1050506@centtech.com> <20060725175331.78302.qmail@web31806.mail.mud.yahoo.com> <20060725183410.GA32063@megan.kiwi-computer.com> <86lkqf1pum.fsf@xps.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jul 27, 2006 at 09:14:41AM +0200, Dag-Erling Sm?rgrav wrote:
> "Rick C. Petty" <rick-freebsd@kiwi-computer.com> writes:
> > On Tue, Jul 25, 2006 at 10:53:31AM -0700, Shane Adams wrote:
> > > I used dd to create 1G file.
> > A faster way is:
> >     touch filename
> >     truncate -s 1g filename
> 
> no, this will result in a fragmented image, which will hurt run-time
> performance.

Not necessarily.  If you install a variant of windoze, the installer will
format the disk first, writing zeros (and metadata) sequentially, and
thus the allocation will not be fragmented.  In the case of UFS newfs
only the metadata will be written for each cylinder group and thus the
logical blocks for all metadata will be contiguous.

I wouldn't say this type of fragmenting absolutely *will* hurt
performance but that it "may" hurt-- certainly tools like fsck would see
a performance improvement.  There are some performance advantages to 
reducing the seek time (in the underlying storage mechanism) for metadata
operations, especially with larger disk caches.  Without benchmarks, it's
hard to say in general whether performance would be degraded due to the
"random" allocation, if you also include FreeBSD's caching mechanisms.
And UFS block allocation is quite predictable.

But you are correct-- truncate(1) just changes the size of the file and
doesn't allocate the underlying blocks.  So there is a tendancy for it to
become fragmented as blocks get allocated out of order.

Also, I discovered that in my example, touch(1) isn't necessary...
truncate(1) works on non-existent files.

-- Rick C. Petty



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