* Sparse files take up more space when copied
@ 1994-11-15 15:11 Peter Lister
1994-11-15 16:08 ` Peter da Silva
1994-11-15 19:52 ` Torbj|rn Lindgren
0 siblings, 2 replies; 7+ messages in thread
From: Peter Lister @ 1994-11-15 15:11 UTC (permalink / raw)
Sorry if this is a newbie question, but the FAQ doesn't seem to touch it.
I moved a user from one file system to another (both ufs, not advfs or afs). This guy has several large files in his home dir generated by SDRC I-DEAS, a big CAD/CAM package. The amount of space occupied by the copied directory hierarchy occupied something like 50% more space as reported by du. On further inspection, individual I-DEAS data files all took up about 50-100% more space in the copy than the original. I tried test copies with cp, tar and dd. All took up the same increased amount of space according to du. The copies were the identical length according to ls -l and had identical checksums according to sum.
I tarred the directory and gzip managed 94% compression on the tar file (yes, that's right, reduced the size by 94%), so these files are obviously pretty sparse. It would seem that I-DEAS can take advantage of some pretty good file compression in the OSF1 filesystem when it writes it's files, but tar,cp,etc don't manage this. My guess is that I-DEAS uses mmap(3) and that that virtual memory paging writes the file blocks more efficiently than stream I/O as used by cp, tar, etc.
Anyone care to comment? The obvious next question is to ask whether there is a way to get the copies to "compress" empty/sparse blocks like this.
--
Peter Lister Email: p.lister@cranfield.ac.uk
Computer Centre, Cranfield University Voice: +44 1234 754200 ext 2828
Cranfield, Bedfordshire MK43 0AL UK Fax: +44 1234 751814
--- First law of troubleshooting.... never overlook the obvious. ---
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Sparse files take up more space when copied
1994-11-15 15:11 Sparse files take up more space when copied Peter Lister
@ 1994-11-15 16:08 ` Peter da Silva
1994-11-15 16:30 ` Peter da Silva
1994-11-16 0:08 ` John Hascall
1994-11-15 19:52 ` Torbj|rn Lindgren
1 sibling, 2 replies; 7+ messages in thread
From: Peter da Silva @ 1994-11-15 16:08 UTC (permalink / raw)
In article <3aaj2f$qql@xdm084.ccc.cranfield.ac.uk>,
Peter Lister <p.lister@cranfield.ac.uk> wrote:
> I tarred the directory and gzip managed 94% compression on the tar
> file (yes, that's right, reduced the size by 94%), so these files are
> obviously pretty sparse. It would seem that I-DEAS can take advantage
> of some pretty good file compression in the OSF1 filesystem when it
> writes it's files, but tar,cp,etc don't manage this. My guess is that
> I-DEAS uses mmap(3) and that that virtual memory paging writes the file
> blocks more efficiently than stream I/O as used by cp, tar, etc.
To be precise... if you seek to a point beyond the end of a file then write,
blocks between the end of the file and the new seek point will not be
allocated until they are written to, and will read as blocks of zeros.
A database program will tend to do this, producting what's called a "sparse
file".
If you write a block of zeros, it will be allocated, so tar and cp and so on
will populate a sparse file.
The fix is to have a program that seeks (on output) over blocks of zeroes (on
input) as it writes. It's not a complex program... I wrote one that does this
and also retries reads (I wrote it to recover data from a flakey Xenix disk,
originally) but I don't know if I can post it (work stuff). In any case, as
I said, it's not a complex program.
while(read block)
if (block is empty)
seek end of file + blocksize
else
write block
--
Peter da Silva `-_-'
Network Management Technology Incorporated 'U`
1601 Industrial Blvd. Sugar Land, TX 77478 USA
+1 713 274 5180 "Hast Du heute schon Deinen Wolf umarmt?"
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Sparse files take up more space when copied
1994-11-15 16:08 ` Peter da Silva
@ 1994-11-15 16:30 ` Peter da Silva
1994-11-16 0:56 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
1994-11-16 0:08 ` John Hascall
1 sibling, 1 reply; 7+ messages in thread
From: Peter da Silva @ 1994-11-15 16:30 UTC (permalink / raw)
Oops, let's change that a little:
set end of file = beginning of file
> while there's another block
do
> if block is empty
increment end of file by blocksize
> else
if not at end of file
seek to end of file
fi
> write block
increment end of file by blocksize
fi
od
--
Peter da Silva `-_-'
Network Management Technology Incorporated 'U`
1601 Industrial Blvd. Sugar Land, TX 77478 USA
+1 713 274 5180 "Hast Du heute schon Deinen Wolf umarmt?"
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Sparse files take up more space when copied
1994-11-15 16:30 ` Peter da Silva
@ 1994-11-16 0:56 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
0 siblings, 0 replies; 7+ messages in thread
From: Alan Rollow - Dr. File System's Home for Wayward Inodes. @ 1994-11-16 0:56 UTC (permalink / raw)
In article <id.RCRE1.EQ8@nmti.com>, peter@nmti.com (Peter da Silva) writes:
>
>Oops, let's change that a little:
>
> set end of file = beginning of file
>> while there's another block
> do
> [ remainder of an Peter's update algorithm deleted. ]
On DEC OSF/1 and ULTRIX you can use:
dd if=input-file of=output-file conv=sparse
and dd(1) will do it for you.
>--
>Peter da Silva `-_-'
>
--
Alan Rollow alan@nabeth.cxo.dec.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Sparse files take up more space when copied
1994-11-15 16:08 ` Peter da Silva
1994-11-15 16:30 ` Peter da Silva
@ 1994-11-16 0:08 ` John Hascall
1994-11-17 20:35 ` Peter da Silva
1 sibling, 1 reply; 7+ messages in thread
From: John Hascall @ 1994-11-16 0:08 UTC (permalink / raw)
Peter da Silva <peter@nmti.com> wrote:
}Peter Lister <p.lister@cranfield.ac.uk> wrote:
}> I tarred the directory and gzip managed 94% compression on the tar
}> file (yes, that's right, reduced the size by 94%), so these files are
}> obviously pretty sparse. It would seem that I-DEAS can take advantage
}> of some pretty good file compression in the OSF1 filesystem when it
}> writes it's files, but tar,cp,etc don't manage this.
}To be precise... if you seek to a point beyond the end of a file then write,
}blocks between the end of the file and the new seek point will not be
}allocated until they are written to, and will read as blocks of zeros.
}
}A database program will tend to do this, producting what's called a "sparse
}file".
}
}If you write a block of zeros, it will be allocated, so tar and cp and so on
}will populate a sparse file.
}
}The fix is to have a program that seeks (on output) over blocks of zeroes (on
}input) as it writes. It's not a complex program...
Or, just use "dd conv=sparse ..."
John
--
John Hascall ``An ill-chosen word is the fool's messenger.''
Systems Software Engineer, ISU Comp Center + Ames, IA 50011 + 515/294-9551
& Hascall Systems - Unix/C/Internet Consulting, Training, Custom Programming
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Sparse files take up more space when copied
1994-11-16 0:08 ` John Hascall
@ 1994-11-17 20:35 ` Peter da Silva
0 siblings, 0 replies; 7+ messages in thread
From: Peter da Silva @ 1994-11-17 20:35 UTC (permalink / raw)
John Hascall <john@iastate.edu> wrote:
> Or, just use "dd conv=sparse ..."
Must be a DEC special.
My, whatever will they think of next?
--
Peter da Silva `-_-'
Network Management Technology Incorporated 'U`
1601 Industrial Blvd. Sugar Land, TX 77478 USA
+1 713 274 5180 "Hast Du heute schon Deinen Wolf umarmt?"
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Sparse files take up more space when copied
1994-11-15 15:11 Sparse files take up more space when copied Peter Lister
1994-11-15 16:08 ` Peter da Silva
@ 1994-11-15 19:52 ` Torbj|rn Lindgren
1 sibling, 0 replies; 7+ messages in thread
From: Torbj|rn Lindgren @ 1994-11-15 19:52 UTC (permalink / raw)
In article <3aaj2f$qql@xdm084.ccc.cranfield.ac.uk>,
Peter Lister <p.lister@cranfield.ac.uk> wrote:
>I tarred the directory and gzip managed 94% compression on the tar
>file (yes, that's right, reduced the size by 94%), so these files are
>obviously pretty sparse. It would seem that I-DEAS can take advantage
>of some pretty good file compression in the OSF1 filesystem when it
>writes it's files, but tar,cp,etc don't manage this. My guess is that
>I-DEAS uses mmap(3) and that that virtual memory paging writes the
>file blocks more efficiently than stream I/O as used by cp, tar, etc.
It uses sparse allocated files (often created by seeking or by
mmaping).
GNU cp (I think it's included in fileutils, that would be the logical
place for it) creates this kind of file when you tell it to copy a
file (if there are any blocks of zeros of course), which means that
sometimes files are smaller after you have copied them :)
The real size of a file is easy to check by using the -s parameter to
'ls'.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1994-11-17 20:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-11-15 15:11 Sparse files take up more space when copied Peter Lister
1994-11-15 16:08 ` Peter da Silva
1994-11-15 16:30 ` Peter da Silva
1994-11-16 0:56 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
1994-11-16 0:08 ` John Hascall
1994-11-17 20:35 ` Peter da Silva
1994-11-15 19:52 ` Torbj|rn Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox