HINTS for the DouBle device driver          26 Feb 1994
----------------------------------

Default Values
--------------
These are the default values used by mkdble:
compression factor: 2.0
clusters: 10240 bytes
blocks: 512 bytes
compression: predictor (code 10)

Default block and cluster size represent the best speed/compression
compromise. Speed can be increased by using block size = 1024. The cluster
size should have little effect on speed and thus the bigger, the better.
10240 is currently the maximum.
Note: the cluster size has no influence on filesystem block size. I know
it might be confusing, but you should not be tempted to reduce its size
for a filesystem containing small files.


Data security issues
--------------------
The most important thing with a compressed device is to never, never,
let it run out of space. In that purpose:
- Do not overfill it.
- Do not store compressed files on it.
- Choose an appropriate compression factor and algorithm when creating
the device.
The driver recovers very poorly from errors resulting from running out
of space. Do not store data on a compressed device unless you fully
understand that it might be lost. BTW the driver is still ALPHA code.
run dbck (df is easier if you are using mount -t dble ...) frequently,
to make sure that the compressed device is not full.


The default compression factor of 2.0 is, in most cases, too high
-----------------------------------------------------------------
It is recommended to use a value SMALLER than the average compression
factor expected from the data and from the compression method used.
There is currently no other mean to measure the compression factor than
trial and error. This is what I recommend:
- Make a device with a compression factor of 1.6.
- Start using it and after some time, use dbck to see what compression
was achieved. If it is less than 1.6, make it again. If it is more than
1.7, you can make it again as well, but it is safe to work with 1.6.


The default algorithm is not the best compressor
------------------------------------------------
The predictor algorithm (default) is in the public domain. It is used in PPP.
As it is not the case of other algorithms included, I will try in future
release to make it work better. According to benchmarks I have done, this
is how the algorithms included compare (as far as compression goes):
best - LZW >= LZRW3A > LZRW2 > PREDICTOR - worst
Note: Before choosing the algorithm you want to use, have a look at the
speed comparison. It is easy to make a DouBle device use a different algorithm
(see mkdble arguments) and the default value can also be changed in mkdble.c
(search for predictor and change code 10 with 212 or 312).


DBLE_FS option
--------------
With the DBLE_FS option set, DouBle devices can be put in /etc/fstab.
As an example this is an excerpt of my fstab file:

/dev/hdb1	/		ext2	defaults,remount 0 1
/dev/hdb2	/dev/cdble2	dble	defaults
/dev/dble2	/home		ext2	defaults

The "dble" entry MUST preceed the filesystem entry that uses it.

This is an excerpt of my /etc/rc file:

#!/bin/sh
# check fs before mounting
# dbmount /dev/hdb2, so that the filesystem on it be checked
dbmount /dev/hdb2 /dev/dble2
fsck -A -av
# dbumount /dev/dble2, so that it can be mounted with mount
dbumount /dev/dble2

# (re)mount filesystems including root
mount -nav
# root is now r/w
# remove /etc/mtab* so mount creates the /etc/mtab file
/bin/rm -f /etc/mtab* 
# write /etc/mtab (fake mount to update /etc/mtab)
/etc/mount -fa

As the dbck utility is not to fsck standards yet, it is recommended to
link /bin/true to /etc/fs/fsck.dble.


Speed considerations
--------------------
Access to a compressed device is slower than to a normal block device.
The purpose of this driver is to transparently make more disk space
available. However, there are ways to increase speed.

Because the default block size under Linux is 1024 bytes, compressed
devices with a block size of 1024 are faster. The default value of 512
bytes emphasizes compression.

Buffer caches within the driver will compensate for speed differences due
to block size. For better performance, the number of internal buffers
(iparticularly DB_NR_BH in linux/include/linux/double.h) can be increased.
Unfortunately, the driver buffers are independent from kernel buffers
and need to be permanently allocated.

Block devices are faster than regular files used as compressed devices.
The reason is that any read/write operation on a regular file goes through
additional layers.

Finally, speed is also dependent on the compression algorithm used. According
to benchmark I have done:
fastest - LZRW2 > PREDICTOR > LZRW3A >> LZW - slowest
LZW is particulary slow in reading.


FINAL REMARKS
-------------
I'll try to create a mailing list that I'll call 'COMPRESSION', on
niksula.hut.fi . See if it works. I think of course, that other compression
issues than the DouBle driver could be discussed there as well.

If you have suggestions or problems, feel free to get in touch with me. Please
report possible bugs as soon as possible. In case of data loss with a given
compression algorithm, I suggest you try another one and then tell me if you
had the problem with both, or only one of them.

Thank you for using the DouBle device driver; compress safely !
Good Luck,

Jean-Marc Verbavatz <jmv@receptor.MGH.harvard.edu>

BTW, my email address is going to change at the end of March. I don't know
my new address yet.
