linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re:  Re:  Swap Compression
@ 2003-04-25 22:48 rmoser
  2003-04-26  9:17 ` Jörn Engel
  0 siblings, 1 reply; 36+ messages in thread
From: rmoser @ 2003-04-25 22:48 UTC (permalink / raw)
  To: linux-kernel

Yeah, I had to mail it 3 times.  Lst time I figured it out.

As for the performance hit, the original idea of that very tiny format was
to pack 6502 programs into 4k of code.  The expansion phase is very
tight and very efficient, and on a ... anything... it will provide no problem.
The swap-on-ram as long as it's not like 200 MB uncompressed SOR and
1 MB RAM will I think work great in the decompression phase.

Compression will take a little overhead.  I think if you use a boyer-moore
fast string search algo for binary strings (yes you can do this), you can
quickly compress the data.  It may be like.. just a guess... 10-30 times
more overhead than the decompression phase.  So use it on at least a
10-30 mhz processor.  If I ever write the code, it won't be kernel; just the
compression/decompression program (userspace).  Take the code and
stuff it into the kernel if I do.  I'll at the point of the algo coming in to
existence make another estimate.

The real power in this is Swap on RAM, but setting that as having precidence
over swap on disk (normal swaps) would decrease disk swap usage by
supplying more RAM in RAM.  And of course swapping RAM to RAM is
a lot faster.  I'm looking at this for PDA's but yes I will be running this on
my desktop the day we see it.

Well, I could work on the compression code, mebbe I can put the tarball up
here.  If I do I'd expect someone to add the code to swap to work with it--in
kernel 2.4 at the very least (port it to dev kernel later!).  As a separate module.
We don't want code that could be mean in the real swap driver. :)

--Bluefox Icy

---- ORIGINAL MESSAGE ----

List:     linux-kernel
Subject:  Re: Swap Compression
From:     =?iso-8859-1?Q?J=F6rn?= Engel <joern () wohnheim ! fh-wedel ! de>
Date:     2003-04-25 21:14:05
[Download message RAW]

On Fri, 25 April 2003 16:48:15 -0400, rmoser wrote:
> 
> Sorry if this is HTML mailed.  I don't know how to control those settings

It is not, but if you could limit lines to <80 characters, that would
be nice.

> COMPRESSED SWAP
> 
> This is mainly for things like linux on iPaq (handhelds.org) and
> people who like to play (me :), but how about compressed swap and
> RAM as swap?  To be plausable, we need a very fast compression
> algorithm.  I'd say use the following back pointer algorithm (this
> is headerless and I coded a decompressor in 6502 assembly in about
> 315 bytes) and 100k block sizes (compress streams of data until they
> are 100k in size, then stop.  Include the cap at the end in the
> 100k).
> 
> [...]
> 
> CONCLUSION
> 
> I think compressed swap and swap-on-ram with compression would be a
> great idea, especially for embedded systems.  High-performance
> systems that can handle the compression/decompression without
> blinking would especially benefit, as the swap-on-ram feature would
> give an almost seamless RAM increase.  Low-performance systems would
> take a performance hit, but embedded devices would still benefit
> from the swap-on-ram with compression RAM boost, considering they
> can probably handle the algorithm.  I am looking forward to seeing
> this implimented in 2.4 and 2.5/2.6 if it is adopted.

Nice idea. This might even benefit normal pc style boxes, if the
performance loss through compression is overcompensated by io gains
(less data transferred).

The tiny problem I see is that most people here have tons of whacky
ideas themselves but lack the time to actually implement them. If you
really want to get it done, do it yourself. It doesn't have to be
perfect, if it works in principle and appears to be promising, you
will likely receive enough help to finish it. But you have to get
there first.

At least, that is how it usually works. Feel free to prove me wrong.

Jörn

-- 
When in doubt, use brute force.
-- Ken Thompson
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression
  2003-04-25 22:48 Re: Swap Compression rmoser
@ 2003-04-26  9:17 ` Jörn Engel
       [not found]   ` <200304261148590300.00CE9372@smtp.comcast.net>
  0 siblings, 1 reply; 36+ messages in thread
From: Jörn Engel @ 2003-04-26  9:17 UTC (permalink / raw)
  To: rmoser; +Cc: linux-kernel

On Fri, 25 April 2003 18:48:41 -0400, rmoser wrote:
> 
> Yeah, I had to mail it 3 times.  Lst time I figured it out.

<more formal junk>
- Your mailer doesn't generate In-Reply-To: or References: Headers.
This breaks threading.
- It is usually more readable if you reply below the quoted text you
refer to.
- Most people prefer, if you reply to all. Not everyone here is
actually subscribed to the list.
- Feel free to ignore any of this, as long as the mail contains
interesting information. :)
</more formal junk>

> As for the performance hit, the original idea of that very tiny format was
> to pack 6502 programs into 4k of code.  The expansion phase is very
> tight and very efficient, and on a ... anything... it will provide no problem.
> The swap-on-ram as long as it's not like 200 MB uncompressed SOR and
> 1 MB RAM will I think work great in the decompression phase.
> 
> Compression will take a little overhead.  I think if you use a boyer-moore
> fast string search algo for binary strings (yes you can do this), you can
> quickly compress the data.  It may be like.. just a guess... 10-30 times
> more overhead than the decompression phase.  So use it on at least a
> 10-30 mhz processor.  If I ever write the code, it won't be kernel; just the
> compression/decompression program (userspace).  Take the code and
> stuff it into the kernel if I do.  I'll at the point of the algo coming in to
> existence make another estimate.

A userspace program would be just fine. Send it to me and I'll convert
it to the kernel, putting it somewhere under lib/.
Do you have any problems with a GPL license to your code (necessary
for kernel port)?

> The real power in this is Swap on RAM, but setting that as having precidence
> over swap on disk (normal swaps) would decrease disk swap usage by
> supplying more RAM in RAM.  And of course swapping RAM to RAM is
> a lot faster.  I'm looking at this for PDA's but yes I will be running this on
> my desktop the day we see it.

Swapping RAM to RAM sounds interesting, but also quite complicated. As
a first step, I would try to compress the swap data before going to
disk, that should be relatively simple to do.

("I would" means, I will if I find the time for it.)

> Well, I could work on the compression code, mebbe I can put the tarball up
> here.  If I do I'd expect someone to add the code to swap to work with it--in
> kernel 2.4 at the very least (port it to dev kernel later!).  As a separate module.
> We don't want code that could be mean in the real swap driver. :)

Right. But for 2.4, there is no swap driver, that you can simply
enable or disable. I hacked up a patch, but so far, disabling swap
eats ~100k of memory every second, so that clearly needs more work.

Jörn

-- 
Do not stop an army on its way home.
-- Sun Tzu

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Some code for Swap Compression
       [not found]     ` <20030426160920.GC21015@wohnheim.fh-wedel.de>
@ 2003-04-26 23:41       ` rmoser
  2003-04-27  2:24       ` rmoser
  1 sibling, 0 replies; 36+ messages in thread
From: rmoser @ 2003-04-26 23:41 UTC (permalink / raw)
  To: =?UNKNOWN?Q?J=F6rn?= Engel; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 928 bytes --]

Alright, I'm done with everything except fdecomp_push() and
fcomp_push().  For the decompression function fdecomp_push(),
it fully supports the fcomp-standard streams (the ones I outlined
originally), so the fcomp-extended stuff has to be supported
(simple enough modification.  I'm lazy).  A very large portion (most
of it) of fcomp_push() needs to be coded; the entire compression
phase is uncoded.  The logic is in that function, in comments.
Someone has to read it, look at the format, and write it.  After
those two things, this can finally be shoved into a userspace
program and rewritten for the kernel, and also can be preoptimized
(i.e. don't resize the stream so many times in decompression when
it's just copying data).

tar.bz2 attatched.  Please please PLEASE make a userspace
program for this as well so that we can get a general idea about
compression ratio.  No better way than using it on files.

--Bluefox Icy

[-- Attachment #2: fcomp.tar.bz2 --]
[-- Type: application/octet-stream, Size: 9424 bytes --]

begin 755 fcomp.tar.bz2
M0EIH.3%!62936=QEER@`':G_A/ZX(B!________>^O____\`!``(8"&/)I(U
M]OF+KHL>]ZO<WM5$]5I*#HT1Q+L[N[J]SWMVZZ>O>JTK/=V[3D;M2"ZO:.SC
MW=RUUI&V7KUQY9V;<SE-G;&[%VS6H/(U+*V.A+(7PDB!"9-,FC00F(T-",D>
MIZ,@3]03$-/4,U-,FC-0T-!D"`(FA!I/29,J>I[4AZFAIA!H```,(``#'#$:
M::#0!H````:#(--`T`&C0!B&@$FDDB--!-!3TTC---3]1J#TC)F2>HTT--`&
M@````(DIHF4R>DD>U1IYJIZ;*>F4T]$GJ-D,1/4'J:'J?JGDFRAY1Y1ZCU/2
M9!$D(1H!1@F@C:FB>30IZGZ*>H\GJ9)H::#0`T:``'K#\[/M]/U]'2N]2H*G
M:M`+KEW>O<@ZU%'6$I-UM(VW`8NF*Z8`2`P@L2"@R"Q=I2(6(@,((DLG3"*F
M]UZZWJ\Y[?6'KG_O16CMV;\ONA%V^Z["^\@8U/JE`:#GV:XQ]VIXKI^U5$?6
MQ@,@@##N.,=[W8K5$U-.]LFSR*ZXLEA3*BK=#/-\H3]Z,MR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&#9$Q\%X`;!E8MB[9WVET,!I=T+.J/?-R2PJ98ZL)9'3D
MQ1T:CD#(W61JJ:0H)NC<0.J"G7`",%9%`^YB!FYT-<(4!E$+NVJBQ-4UW(S=
M+V8=)@H^&^5GCNJ^Q%@P0))$PFPJ4AR*#G(19%!<%]==8.,5CA1EM=45UT>1
MF(;WG<^+Q*9N?-*0_$Y$5.O`3'258L0==C1P\HGYNPA=GLU/X&]F.^&6)J3I
M-A:G8(5KS#21WT5L/G<EN#+?PO*(?_!BY`.G$M86UK2U`<AZYW,W=R%@;G7@
MNF6T1L2>!4USEF$\&'8:-1$@B@L8"&<T^$I#BFY.M-PPF,4J`2`0,P@&OUT%
M+Y\?J$,L"V%]=D$Y>2)XMZ5S"'*6[V#790T94\+/=I;2^"TLV"K54?)+6=LM
M&&_I^6GDQOXVE"&G#0>"`[^P5<P?4_*]R6B%B%$HE%%2JH^IAHT_'88FAV)&
68!L&L"9#0Z*&$R3^+N2*<*$AN,LN4`
`
end

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression
       [not found]     ` <20030426160920.GC21015@wohnheim.fh-wedel.de>
  2003-04-26 23:41       ` Some code for " rmoser
@ 2003-04-27  2:24       ` rmoser
  2003-04-27  9:04         ` Jörn Engel
       [not found]         ` <3EADAA5D.1090408@techsource.com>
  1 sibling, 2 replies; 36+ messages in thread
From: rmoser @ 2003-04-27  2:24 UTC (permalink / raw)
  To: =?UNKNOWN?Q?J=F6rn?= Engel; +Cc: linux-kernel

So what's the best way to do this?  I was originally thinking like this:

Grab some swap data
Stuff it into fcomp_push()
When you have 100k of data, seal it up
Write that 100k block

But does swap compress in 64k blocks?  80x86 has 64k segments.
The calculation for compression performance loss, 256/size_of_input,
gives a loss of 0.003906 (0.3906%) for a dataset 65536 bytes long.
So would it be better to just compress segments, whatever size they
may be, and index those?  This would, of course, be much more efficient
in terms of finding the data to uncompress.  (And system dependant)

The algo is flexible; it doesn't care about the size of the input.  If you
pass full segments at once, you could gain a little more speed.  Best
part, if you rewrite my decompression code to do the forward calculations
for straight data copy (I'll likely do this before the night is up myself),
you will evade a lot of realloc()'s in the data copy between pointers.  This
could also optimize out the decriments of the distance-to-next-pointer
counter, and total this all together gives a lot of speed increase over my
original code.  Since this is a logic change, the compiler can't do this
optimization for you.

Another thing, I did state the additional overhead (which now is going to be
64K + code + 256 byte analysis section + 64k uncompressed data)
before, but you can pull in less than the full block, decompress it, put it
where it goes, and pull in more.  So on REALLY small systems, you
can still do pagefile buffering and not blow out RAM with the extra 128k
you may need.  (heck, all the work could be done in one 64k segment if
you're that determined.  Then you could compress the swap on little 6 MB
boxen).

--Bluefox Icy


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression
  2003-04-27  2:24       ` rmoser
@ 2003-04-27  9:04         ` Jörn Engel
  2003-04-27 17:24           ` rmoser
       [not found]         ` <3EADAA5D.1090408@techsource.com>
  1 sibling, 1 reply; 36+ messages in thread
From: Jörn Engel @ 2003-04-27  9:04 UTC (permalink / raw)
  To: rmoser; +Cc: linux-kernel

On Sat, 26 April 2003 22:24:04 -0400, rmoser wrote:
> 
> So what's the best way to do this?  I was originally thinking like this:
> 
> Grab some swap data
> Stuff it into fcomp_push()
> When you have 100k of data, seal it up
> Write that 100k block

I would like something like this:

/*	fox_compress
 *	@input: Pointer to uncompressed data
 *	@output: Pointer to buffer
 *	@inlen: Size of uncompressed data
 *	@outlen: Size of the buffer
 *
 *	Return:
 *	0 on successful compression
 *	-Esomething on error
 *
 *	Side effects:
 *	Output buffer is filled with random data after an error
 *	condition or the compressed input data on success.
 *	outlen remains unchanged on error and holds the compressed
 *	data size on success
 *
 *	If the output buffer is too small, this is an error.
 */
int fox_compress(unsigned char *input, unsigned char *output,
		uint32_t inlen, uint32_t *outlen);

/*	fox_decompress
 *	see above, basically
 */
int fox_decompress(unsigned char *input, unsigned char *output,
		uint32_t inlen, uint32_t *outlen);

Then the mm code can pick any useful size for compression.

Jörn

-- 
My second remark is that our intellectual powers are rather geared to
master static relations and that our powers to visualize processes
evolving in time are relatively poorly developed.
-- Edsger W. Dijkstra

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression
  2003-04-27  9:04         ` Jörn Engel
@ 2003-04-27 17:24           ` rmoser
  2003-04-27 17:51             ` Jörn Engel
  0 siblings, 1 reply; 36+ messages in thread
From: rmoser @ 2003-04-27 17:24 UTC (permalink / raw)
  To: =?UNKNOWN?Q?J=F6rn?= Engel; +Cc: linux-kernel



*********** REPLY SEPARATOR  ***********

On 4/27/2003 at 11:04 AM Jörn Engel wrote:

>On Sat, 26 April 2003 22:24:04 -0400, rmoser wrote:
>> 
>> So what's the best way to do this?  I was originally thinking like this:
>> 
>> Grab some swap data
>> Stuff it into fcomp_push()
>> When you have 100k of data, seal it up
>> Write that 100k block
>
>I would like something like this:
>
>/*	fox_compress
> *	@input: Pointer to uncompressed data
> *	@output: Pointer to buffer
> *	@inlen: Size of uncompressed data
> *	@outlen: Size of the buffer
> *
> *	Return:
> *	0 on successful compression
> *	-Esomething on error
> *
> *	Side effects:
> *	Output buffer is filled with random data after an error
> *	condition or the compressed input data on success.
> *	outlen remains unchanged on error and holds the compressed
> *	data size on success
> *
> *	If the output buffer is too small, this is an error.
> */
>int fox_compress(unsigned char *input, unsigned char *output,
>		uint32_t inlen, uint32_t *outlen);
>
>/*	fox_decompress
> *	see above, basically
> */
>int fox_decompress(unsigned char *input, unsigned char *output,
>		uint32_t inlen, uint32_t *outlen);
>

Ey? uint32_t*?  I assume that's a mistake....  Anyhow, this wasn't what
I was asking.  What I was asking was about how to determine how much
data to send to compress it.  Read the message again, the whole thing
this time.

>Then the mm code can pick any useful size for compression.
>
>Jörn

Eh?  I rather the code alloc space itself and do all its own handling.  That
way you don't have to second-guess the buffer size for decompressed
data if you don't do all-at-once decompression (i.e. decompressing x86
segments, all-at-once would be to decompress the whole compressed
block of N size to 64k, where partial would be to pull in N/n at a time and
decompress in n sets of N/n, which would give varying sized output).

Another thing is that the code isn't made to strictly stick to compressing
or decompressing a whole input all at once; you may break down the
input into smaller pieces.  Therefore it does need to think about how much
it's gonna actually tell you to pull off when you inquire about the size to
remove from the stream (for compression at least), because you might
break it if you pull too much data off midway through compression.  The
advantage of this method is in when you're A) Compressing files, and
B) trying to do this kind of thing on EXTREMELY low RAM systems,
where you can't afford to pass whole buffers back and forth.  (Think 4 meg)

You do actually understand the code, right?  I have this weird habit of
making code and doing such obfuscating comments that people go
"WTF is this?" when they see it.  Then again, you're probably about
12 classes past me in C programming, so maybe it's just my logic that's
flawed. :)

--Bluefox Icy
(John Moser in case something winds up with my name on it)

>
>-- 
>My second remark is that our intellectual powers are rather geared to
>master static relations and that our powers to visualize processes
>evolving in time are relatively poorly developed.
>-- Edsger W. Dijkstra
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression
  2003-04-27 17:24           ` rmoser
@ 2003-04-27 17:51             ` Jörn Engel
  2003-04-27 18:22               ` William Lee Irwin III
  2003-04-27 18:31               ` rmoser
  0 siblings, 2 replies; 36+ messages in thread
From: Jörn Engel @ 2003-04-27 17:51 UTC (permalink / raw)
  To: rmoser; +Cc: linux-kernel

On Sun, 27 April 2003 13:24:37 -0400, rmoser wrote:
> >int fox_compress(unsigned char *input, unsigned char *output,
> >		uint32_t inlen, uint32_t *outlen);
> >
> >int fox_decompress(unsigned char *input, unsigned char *output,
> >		uint32_t inlen, uint32_t *outlen);
> 
> Ey? uint32_t*?  I assume that's a mistake....

Nope. outlen is changed, you need a pointer here.

> Anyhow, this wasn't what
> I was asking.  What I was asking was about how to determine how much
> data to send to compress it.  Read the message again, the whole thing
> this time.

I did. But modularity is the key here. The whole idea may be great or
plain bullshit, depending on the benchmarks. Which one it is depends
on the compression algorithm used, among other things. Maybe your
compression algo is better for some machines, zlib for others, etc.

Why should someone decide on an algorithm before measuring?

> >Then the mm code can pick any useful size for compression.
> 
> Eh?  I rather the code alloc space itself and do all its own handling.  That
> way you don't have to second-guess the buffer size for decompressed
> data if you don't do all-at-once decompression (i.e. decompressing x86
> segments, all-at-once would be to decompress the whole compressed
> block of N size to 64k, where partial would be to pull in N/n at a time and
> decompress in n sets of N/n, which would give varying sized output).

Segments are old, stupid and x86 only. What you want is a number of
pages, maybe just one at a time. Always compress chunks of the same
size and you don't have to guess the decompressed size.

> Another thing is that the code isn't made to strictly stick to compressing
> or decompressing a whole input all at once; you may break down the
> input into smaller pieces.  Therefore it does need to think about how much
> it's gonna actually tell you to pull off when you inquire about the size to
> remove from the stream (for compression at least), because you might
> break it if you pull too much data off midway through compression.  The
> advantage of this method is in when you're A) Compressing files, and
> B) trying to do this kind of thing on EXTREMELY low RAM systems,
> where you can't afford to pass whole buffers back and forth.  (Think 4 meg)

a) Even with 4M, two pages of 4k each don't hurt that much. If they
do, the whole compression trick doesn't pay off at all.
b) Compression ratios usually suck with small buffers.

> You do actually understand the code, right?  I have this weird habit of
> making code and doing such obfuscating comments that people go
> "WTF is this?" when they see it.  Then again, you're probably about
> 12 classes past me in C programming, so maybe it's just my logic that's
> flawed. :)

I didn't look that far yet. What you could do, is read through
/usr/src/linux/Documentation/CodingStyle. It is just so much nicer
(and faster) to read and sticking to it usually produces better code.

Jörn

-- 
Beware of bugs in the above code; I have only proved it correct, but
not tried it.
-- Donald Knuth

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression
  2003-04-27 17:51             ` Jörn Engel
@ 2003-04-27 18:22               ` William Lee Irwin III
  2003-04-27 18:31               ` rmoser
  1 sibling, 0 replies; 36+ messages in thread
From: William Lee Irwin III @ 2003-04-27 18:22 UTC (permalink / raw)
  To: J?rn Engel; +Cc: rmoser, linux-kernel

On Sun, Apr 27, 2003 at 07:51:47PM +0200, J?rn Engel wrote:
> Segments are old, stupid and x86 only. What you want is a number of
> pages, maybe just one at a time. Always compress chunks of the same
> size and you don't have to guess the decompressed size.

Well, not really, but x86's notion of segments differs substantially
from that held by other cpus.


-- wli

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression
  2003-04-27 17:51             ` Jörn Engel
  2003-04-27 18:22               ` William Lee Irwin III
@ 2003-04-27 18:31               ` rmoser
  2003-04-27 19:04                 ` Jörn Engel
       [not found]                 ` <3EAE8899.2010208@techsource.com>
  1 sibling, 2 replies; 36+ messages in thread
From: rmoser @ 2003-04-27 18:31 UTC (permalink / raw)
  To: =?UNKNOWN?Q?J=F6rn?= Engel; +Cc: linux-kernel



*********** REPLY SEPARATOR  ***********

On 4/27/2003 at 7:51 PM Jörn Engel wrote:

>On Sun, 27 April 2003 13:24:37 -0400, rmoser wrote:
>> >int fox_compress(unsigned char *input, unsigned char *output,
>> >		uint32_t inlen, uint32_t *outlen);
>> >
>> >int fox_decompress(unsigned char *input, unsigned char *output,
>> >		uint32_t inlen, uint32_t *outlen);
>> 
>> Ey? uint32_t*?  I assume that's a mistake....
>
>Nope. outlen is changed, you need a pointer here.
>

ahh okay, gotcha

>> Anyhow, this wasn't what
>> I was asking.  What I was asking was about how to determine how much
>> data to send to compress it.  Read the message again, the whole thing
>> this time.
>
>I did. But modularity is the key here. The whole idea may be great or
>plain bullshit, depending on the benchmarks. Which one it is depends
>on the compression algorithm used, among other things. Maybe your
>compression algo is better for some machines, zlib for others, etc.
>

Yeah I know.  I really need to get a working user-space version of this
thing so I can bench it against source tarballs and extractions from
/dev/random a bunch of times.


>Why should someone decide on an algorithm before measuring?
>

Erm.  You can use any one of the other algos you want, there's a lot
out there.  Go ahead and try zlib/gzip/bzip2/7zip/compress if you
want.  I just figured, the simplest algo would hopefully be the fastest.
But really we need some finished code to make this work :-)

The real reason I'm working on this is because I favor speed completely
over size in this application.  It's all modular; make the interface for the
kernel module flexible enough to push in gzip/bzip2 modules or whatever
else you want:

<M> Swap partition support
____<M> Compressed Swap
________<M> fcomp
____________<M> fcomp-extended support
________<M> zlib
________<M> gzip
________<M> bzip2
________<M> compress
____<M> Swap on RAM

As far as I know, zlib, gzip, and compress use Huffman trees.  I am pretty
sure about zlib, not sure about the others.  gzip I believe uses 16 bit
backpointers as well, which means you need a 64k processing window
for [de]compression, not to mention that it takes more work.  bzip2 we
all know is CPU-intensive, or at least it was last time I checked.

>> >Then the mm code can pick any useful size for compression.
>> 
>> Eh?  I rather the code alloc space itself and do all its own handling. 
>That
>> way you don't have to second-guess the buffer size for decompressed
>> data if you don't do all-at-once decompression (i.e. decompressing x86
>> segments, all-at-once would be to decompress the whole compressed
>> block of N size to 64k, where partial would be to pull in N/n at a time
>and
>> decompress in n sets of N/n, which would give varying sized output).
>
>Segments are old, stupid and x86 only. What you want is a number of
>pages, maybe just one at a time. Always compress chunks of the same
>size and you don't have to guess the decompressed size.
>

Yeah true.  But for guessing the decompressed size I meant like when
you don't want to load the WHOLE block into RAM at once.  Ahh, so you
swap in pages?  Well whatever unit you swap in, that's how you should
compress things.  Look I'm confusing myself here, just ignore anything
that sounds retarded--I'm just a kid after all :-p

>> Another thing is that the code isn't made to strictly stick to
>compressing
>> or decompressing a whole input all at once; you may break down the
>> input into smaller pieces.  Therefore it does need to think about how
>much
>> it's gonna actually tell you to pull off when you inquire about the size
>to
>> remove from the stream (for compression at least), because you might
>> break it if you pull too much data off midway through compression.  The
>> advantage of this method is in when you're A) Compressing files, and
>> B) trying to do this kind of thing on EXTREMELY low RAM systems,
>> where you can't afford to pass whole buffers back and forth.  (Think 4
>meg)
>
>a) Even with 4M, two pages of 4k each don't hurt that much. If they
>do, the whole compression trick doesn't pay off at all.
>b) Compression ratios usually suck with small buffers.
>
a)
True, two chunks of 4k don't hurt.  But how big are swap pages?  Assuming
the page can't be compressed at all, it's [page size / 256] * 3 + [page size]
for the maximum compressed data size.  (4144 bytes for 4k of absolutely
non-redundant data within 256 bytes).

b)
Yeah they do.  But to find the compression performance (ratio) loss, you
do [max pointer distance]/[block size], meaning like for this one
256/[page size].  If you do a 4k page size, you lose 6.25% of the compression
performance (so if we average 2:1, we'll average 1.875:1).  What IS the page
size the kernel uses?

>> You do actually understand the code, right?  I have this weird habit of
>> making code and doing such obfuscating comments that people go
>> "WTF is this?" when they see it.  Then again, you're probably about
>> 12 classes past me in C programming, so maybe it's just my logic that's
>> flawed. :)
>
>I didn't look that far yet. What you could do, is read through
>/usr/src/linux/Documentation/CodingStyle. It is just so much nicer
>(and faster) to read and sticking to it usually produces better code.
>

Eh, I should just crack open the kernel source and immitate it.  But I have
that file on my hard disk, so mebbe I should look.  Mebbe I should take a
whack at getting the compression algo to work too, instead of pushing it
on someone else.


>Jörn
>
>-- 
>Beware of bugs in the above code; I have only proved it correct, but
>not tried it.
>-- Donald Knuth




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression
  2003-04-27 18:31               ` rmoser
@ 2003-04-27 19:04                 ` Jörn Engel
  2003-04-27 19:57                   ` Livio Baldini Soares
                                     ` (3 more replies)
       [not found]                 ` <3EAE8899.2010208@techsource.com>
  1 sibling, 4 replies; 36+ messages in thread
From: Jörn Engel @ 2003-04-27 19:04 UTC (permalink / raw)
  To: rmoser; +Cc: linux-kernel

On Sun, 27 April 2003 14:31:25 -0400, rmoser wrote:
> 
> Yeah I know.  I really need to get a working user-space version of this
> thing so I can bench it against source tarballs and extractions from
> /dev/random a bunch of times.

Your compression won't be too good on /dev/random. ;)
But /dev/kmem might be useful test data.

> >Why should someone decide on an algorithm before measuring?
> 
> Erm.  You can use any one of the other algos you want, there's a lot
> out there.  Go ahead and try zlib/gzip/bzip2/7zip/compress if you
> want.  I just figured, the simplest algo would hopefully be the fastest.

Hopefully, yes. Also, the one that doesn't trash the L[12] caches too
much will be "fast" in that it doesn't slow down the rest of the
system. This aspect really favors current uncompressing code, as it is
very easy on the CPU.

> But really we need some finished code to make this work :-)

Yes!

> The real reason I'm working on this is because I favor speed completely
> over size in this application.  It's all modular; make the interface for the
> kernel module flexible enough to push in gzip/bzip2 modules or whatever
> else you want:
> 
> <M> Swap partition support
> ____<M> Compressed Swap
> ________<M> fcomp
> ____________<M> fcomp-extended support
> ________<M> zlib
> ________<M> gzip
> ________<M> bzip2
> ________<M> compress
> ____<M> Swap on RAM

Exactly. It might also be possible to choose the algorithm at bootup
or during runtime.

> As far as I know, zlib, gzip, and compress use Huffman trees.  I am pretty
> sure about zlib, not sure about the others.  gzip I believe uses 16 bit
> backpointers as well, which means you need a 64k processing window
> for [de]compression, not to mention that it takes more work.  bzip2 we
> all know is CPU-intensive, or at least it was last time I checked.

Yes, zlib eats up several 100k of memory. You really notice this when
you add it to a bootloader that was (once) supposed to be small. :)

> Yeah true.  But for guessing the decompressed size I meant like when
> you don't want to load the WHOLE block into RAM at once.  Ahh, so you
> swap in pages?  Well whatever unit you swap in, that's how you should
> compress things.  Look I'm confusing myself here, just ignore anything
> that sounds retarded--I'm just a kid after all :-p

Will do. :)
It should be fine to load a page (maybe several pages) at once. There
is read-ahead code all over the kernel and this is nothing else. Plus
it simplifies things.

> >a) Even with 4M, two pages of 4k each don't hurt that much. If they
> >do, the whole compression trick doesn't pay off at all.
> >b) Compression ratios usually suck with small buffers.
> >
> a)
> True, two chunks of 4k don't hurt.  But how big are swap pages?  Assuming
> the page can't be compressed at all, it's [page size / 256] * 3 + [page size]
> for the maximum compressed data size.  (4144 bytes for 4k of absolutely
> non-redundant data within 256 bytes).

4k + sizeof(header). If the compression doesn't manage to shrink the
code, it should return an error. The calling code will then put an
uncompressed flag in the header and we're done.
The header may be as small as one byte.

> b)
> Yeah they do.  But to find the compression performance (ratio) loss, you
> do [max pointer distance]/[block size], meaning like for this one
> 256/[page size].  If you do a 4k page size, you lose 6.25% of the compression
> performance (so if we average 2:1, we'll average 1.875:1).  What IS the page
> size the kernel uses?

4k on most architectures, 8k on alpha.

> >I didn't look that far yet. What you could do, is read through
> >/usr/src/linux/Documentation/CodingStyle. It is just so much nicer
> >(and faster) to read and sticking to it usually produces better code.
> >
> 
> Eh, I should just crack open the kernel source and immitate it.  But I have
> that file on my hard disk, so mebbe I should look.  Mebbe I should take a
> whack at getting the compression algo to work too, instead of pushing it
> on someone else.

:)

Imitating the kernel source may or may not be a good idea, btw. It is
very diverse in style and quality. Some drivers are absolutely
horrible, but they are just drivers, so noone without that hardware
cares.

Another thing: Did you look at the links John Bradford gave yet? It
doesn't hurt to try something alone first, but once you have a good
idea about what the problem is and how you would solve it, look for
existing code.

Most times, someone else already had the same idea and the same
general solution. Good, less work. Sometimes you were stupid and the
existing solution is much better. Good to know. And on very rare
occasions, your solution is better, at least in some details.

Well, in this case, the sourceforge project appears to be silent since
half a year or so, whatever that means.

Jörn

-- 
Data dominates. If you've chosen the right data structures and organized
things well, the algorithms will almost always be self-evident. Data
structures, not algorithms, are central to programming.
-- Rob Pike

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression
  2003-04-27 19:04                 ` Jörn Engel
@ 2003-04-27 19:57                   ` Livio Baldini Soares
  2003-04-27 20:24                     ` rmoser
       [not found]                   ` <200304271609460030.01FC8C2B@smtp.comcast.net>
                                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 36+ messages in thread
From: Livio Baldini Soares @ 2003-04-27 19:57 UTC (permalink / raw)
  To: Jörn Engel; +Cc: rmoser, linux-kernel

  Hello,

  Unfortunately, I've missed the  beginning of this discussion, but it
seems you're trying  to do almost exactly what  the "Compressed Cache"
project set out to do:

http://linuxcompressed.sourceforge.net/

  _Please_ take a  look at it. Rodrigo de Castro  (the author) spent a
_lot_ of time working out the issues and corner details which a system
like this entail. I've been also  involved in the project, even if not
actively  coding, but  giving suggestions  and helping  out  when time
permitted.   This   project  has  been   the  core  of   his  Master's
dissertation, which  he has just finished writting  recently, and will
soon defend.

  It would be foolish (IMHO) to start from scratch. Take a look at the
web site. There is a nice sketch of the degin he has chosen here:

http://linuxcompressed.sourceforge.net/design/

  Scott Kaplan, a researcher  interested in compression of memory, has
also helped a bit. This article is something definitely worth reading,
and was one of Rodrigo's "starting point":

http://www.cs.amherst.edu/~sfkaplan/papers/compressed-caching.ps.gz

  (There are other relevant sources available on the web page).

  Rodrigo has also written a  paper about his compressed caching which
has much  more up-to-date information  than the web page.   His newest
benchmarks  of  the  newest  compressed  cache  version  shows  better
improvements then the numbers on the web page too. I'll ask him to put
it somewhere public, if he's willing.

Jörn Engel writes:
> On Sun, 27 April 2003 14:31:25 -0400, rmoser wrote:

[...]

> Another thing: Did you look at the links John Bradford gave yet? It
> doesn't hurt to try something alone first, but once you have a good
> idea about what the problem is and how you would solve it, look for
> existing code.

  I think the compressed cache project is the one John mentioned.

> Most times, someone else already had the same idea and the same
> general solution. Good, less work. Sometimes you were stupid and the
> existing solution is much better. Good to know. And on very rare
> occasions, your solution is better, at least in some details.
> 
> Well, in this case, the sourceforge project appears to be silent since
> half a year or so, whatever that means.

  It means Rodrigo has been  busy writting his dissertation, and, most
recently, looking  for a job :-)  I've talked to him  recently, and he
intends to continue on with the project, as he might have some time to
devote to it.

  On a side  note, though, one thing that has  still not been explored
is compressed  _swap_. Since the project's focus  has been performance
gains, and it  was not clear from the  beginning that compressing swap
actually  results  in  performance   gains,  it  still  has  not  been
implemented. That said, this *is* on the project's to-study list. 


  Hope this helps,

--  
  Livio B. Soares

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression
       [not found]                   ` <200304271609460030.01FC8C2B@smtp.comcast.net>
@ 2003-04-27 20:10                     ` rmoser
  0 siblings, 0 replies; 36+ messages in thread
From: rmoser @ 2003-04-27 20:10 UTC (permalink / raw)
  To: linux-kernel



*********** REPLY SEPARATOR  ***********

On 4/27/2003 at 9:04 PM Jörn Engel wrote:

>On Sun, 27 April 2003 14:31:25 -0400, rmoser wrote:
>> 
>> Yeah I know.  I really need to get a working user-space version of this
>> thing so I can bench it against source tarballs and extractions from
>> /dev/random a bunch of times.
>
>Your compression won't be too good on /dev/random. ;)
>But /dev/kmem might be useful test data.
>

Ahh okay.

>> >Why should someone decide on an algorithm before measuring?
>> 
>> Erm.  You can use any one of the other algos you want, there's a lot
>> out there.  Go ahead and try zlib/gzip/bzip2/7zip/compress if you
>> want.  I just figured, the simplest algo would hopefully be the fastest.
>
>Hopefully, yes. Also, the one that doesn't trash the L[12] caches too
>much will be "fast" in that it doesn't slow down the rest of the
>system. This aspect really favors current uncompressing code, as it is
>very easy on the CPU.
>

Mine doesn't do anything :)  It's the lazy-boy of compression!  I don't know
enough to trash anything

>> But really we need some finished code to make this work :-)
>
>Yes!
>
>> The real reason I'm working on this is because I favor speed completely
>> over size in this application.  It's all modular; make the interface for
>the
>> kernel module flexible enough to push in gzip/bzip2 modules or whatever
>> else you want:
>> 
>> <M> Swap partition support
>> ____<M> Compressed Swap
>> ________<M> fcomp
>> ____________<M> fcomp-extended support
>> ________<M> zlib
>> ________<M> gzip
>> ________<M> bzip2
>> ________<M> compress
>> ____<M> Swap on RAM
>
>Exactly. It might also be possible to choose the algorithm at bootup
>or during runtime.
>

(note:  Using swaponram as an example instead of a regular swap to
show how to avoid making the user actually give a swap device name
for that particular feature; this works the same if you replace
 " -o swaponram=24MB" with a device like /dev/hda4)

Okay, again, swapon -o foo[=bar] should pass whatever foo and bar are
to the kernel, and let the kernel evaluate it.  This way you never update
swapon again ;-) Except of the usual (bugs, security fixes, etc)

swapon -o compressed=fcomp-extended -o algoflags=fcomp-mdist=1024 \
  -o swaponram=24MB

That should be completely evaluated by the kernel to mean (as long as
fcomp-extended support is enabled and loaded) to swapon compressed
with fcomp-extended with a max backpointer distance of 1024 bytes (which
is 16 bit pointers; always use the minimum), and do a swaponram of 24MB.
The kernel will look at it, as long as all modules needed are loaded it goes
"Okay", tells swapon what the name (swaponram0 ?) of the swaponram
is, and then that gets handled in userspace as a normal

swapon swaponram0

would (assuming that device exists; think shmfs), meaning

swapoff swaponram0

would turn that swaponram off.

>> As far as I know, zlib, gzip, and compress use Huffman trees.  I am
>pretty
>> sure about zlib, not sure about the others.  gzip I believe uses 16 bit
>> backpointers as well, which means you need a 64k processing window
>> for [de]compression, not to mention that it takes more work.  bzip2 we
>> all know is CPU-intensive, or at least it was last time I checked.
>
>Yes, zlib eats up several 100k of memory. You really notice this when
>you add it to a bootloader that was (once) supposed to be small. :)
>

Bick.


>> Yeah true.  But for guessing the decompressed size I meant like when
>> you don't want to load the WHOLE block into RAM at once.  Ahh, so you
>> swap in pages?  Well whatever unit you swap in, that's how you should
>> compress things.  Look I'm confusing myself here, just ignore anything
>> that sounds retarded--I'm just a kid after all :-p
>
>Will do. :)
>It should be fine to load a page (maybe several pages) at once. There
>is read-ahead code all over the kernel and this is nothing else. Plus
>it simplifies things.
>

Heh, cool.  Compressing groups of pages I think is a bad idea; you have
to waste time RECOMPRESSING when you pull a page off the disk (or
flag it free)

>> >a) Even with 4M, two pages of 4k each don't hurt that much. If they
>> >do, the whole compression trick doesn't pay off at all.
>> >b) Compression ratios usually suck with small buffers.
>> >
>> a)
>> True, two chunks of 4k don't hurt.  But how big are swap pages?  Assuming
>> the page can't be compressed at all, it's [page size / 256] * 3 + [page
>size]
>> for the maximum compressed data size.  (4144 bytes for 4k of absolutely
>> non-redundant data within 256 bytes).
>
>4k + sizeof(header). If the compression doesn't manage to shrink the
>code, it should return an error. The calling code will then put an
>uncompressed flag in the header and we're done.
>The header may be as small as one byte.
>


>> b)
>> Yeah they do.  But to find the compression performance (ratio) loss, you
>> do [max pointer distance]/[block size], meaning like for this one
>> 256/[page size].  If you do a 4k page size, you lose 6.25% of the
>compression
>> performance (so if we average 2:1, we'll average 1.875:1).  What IS the
>page
>> size the kernel uses?
>
>4k on most architectures, 8k on alpha.
>

Let's make this a swapon option at some point, i.e.

swapon -o page_size=16K /dev/hda5


>> >I didn't look that far yet. What you could do, is read through
>> >/usr/src/linux/Documentation/CodingStyle. It is just so much nicer
>> >(and faster) to read and sticking to it usually produces better code.
>> >
>> 
>> Eh, I should just crack open the kernel source and immitate it.  But I
>have
>> that file on my hard disk, so mebbe I should look.  Mebbe I should take a
>> whack at getting the compression algo to work too, instead of pushing it
>> on someone else.
>
>:)
>
>Imitating the kernel source may or may not be a good idea, btw. It is
>very diverse in style and quality. Some drivers are absolutely
>horrible, but they are just drivers, so noone without that hardware
>cares.
>

LOL!  True.

>Another thing: Did you look at the links John Bradford gave yet? It
>doesn't hurt to try something alone first, but once you have a good
>idea about what the problem is and how you would solve it, look for
>existing code.
>

Saw it.

>Most times, someone else already had the same idea and the same
>general solution. Good, less work. Sometimes you were stupid and the
>existing solution is much better. Good to know. And on very rare
>occasions, your solution is better, at least in some details.
>

It happens.

>Well, in this case, the sourceforge project appears to be silent since
>half a year or so, whatever that means.
>

It's dead I'd guess, unless someone can prove me wrong.

>Jörn
>
>-- 
>Data dominates. If you've chosen the right data structures and organized
>things well, the algorithms will almost always be self-evident. Data
>structures, not algorithms, are central to programming.
>-- Rob Pike
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/

--Bluefox Icy


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression
  2003-04-27 19:57                   ` Livio Baldini Soares
@ 2003-04-27 20:24                     ` rmoser
  0 siblings, 0 replies; 36+ messages in thread
From: rmoser @ 2003-04-27 20:24 UTC (permalink / raw)
  To: Livio Baldini Soares; +Cc: linux-kernel

First I'd like to note that I'd not seen anything on this topic up until I
actually had said something in #C++.  I got the linuxcompressed
sourceforge site but already had my algorithm and I don't intend to
defame anyone, nor have I attempted to steal anyone's ideas.
I'm not rivaling anyone either.

... But I am starting from scratch.

*********** REPLY SEPARATOR  ***********

On 4/27/2003 at 4:57 PM Livio Baldini Soares wrote:

>Hello,
>
>  Unfortunately, I've missed the  beginning of this discussion, but it
>seems you're trying  to do almost exactly what  the "Compressed Cache"
>project set out to do:
>

Archives.. archives....

http://marc.theaimsgroup.com/?l=linux-kernel&m=105130405702475&w=2

>http://linuxcompressed.sourceforge.net/
>

Saw that.  I'm going for plain swap-on-ram tying right in to the normal
swap code.  This means that all of these extensions (compression) will
go right to the swap-on-ram driver too.  Of course, the kernel should be
smart enough to make a swap-on-ram the first choice by default, meaning
that it goes to SoR before going to disk swaps.

It's a lot less thought-out I'll grant you that, but I'm not the type to start
with someone else's code (I can never understand it).  Besides that, I'm
just working on the compression algo.

Both ways can go into the kernel, you know.  But I've got time to do this
and I'm gonna funnel whatever I can into it.

>  _Please_ take a  look at it. Rodrigo de Castro  (the author) spent a
>_lot_ of time working out the issues and corner details which a system
>like this entail. I've been also  involved in the project, even if not
>actively  coding, but  giving suggestions  and helping  out  when time
>permitted.   This   project  has  been   the  core  of   his  Master's
>dissertation, which  he has just finished writting  recently, and will
>soon defend.
>

>  It would be foolish (IMHO) to start from scratch. Take a look at the
>web site. There is a nice sketch of the degin he has chosen here:
>
>http://linuxcompressed.sourceforge.net/design/
>

Cool I know, but:

<QUOTE>
Bottom line in swap issue: (increasing) space isn't a issue,
 only performance

Discussing these issues we've come to the conclusion that
we should not aim for making swap bigger (keeping compressed
pages in it), that doesn't seem to be an issue for anyone...
Specially because disks nowadays are so low-cost compared
to RAM and CPU. We should design our cache to be tuned for
speed. 
</QUOTE>

I'm working on this for handheld devices mainly, but my aim IS size.
Speed is important, though.  I hope my algo is fast enough to give
no footprint in that sense :)

>  Scott Kaplan, a researcher  interested in compression of memory, has
>also helped a bit. This article is something definitely worth reading,
>and was one of Rodrigo's "starting point":
>
>http://www.cs.amherst.edu/~sfkaplan/papers/compressed-caching.ps.gz
>
>  (There are other relevant sources available on the web page).
>
>  Rodrigo has also written a  paper about his compressed caching which
>has much  more up-to-date information  than the web page.   His newest
>benchmarks  of  the  newest  compressed  cache  version  shows  better
>improvements then the numbers on the web page too. I'll ask him to put
>it somewhere public, if he's willing.
>
>Jörn Engel writes:
>> On Sun, 27 April 2003 14:31:25 -0400, rmoser wrote:
>
>[...]
>
>> Another thing: Did you look at the links John Bradford gave yet? It
>> doesn't hurt to try something alone first, but once you have a good
>> idea about what the problem is and how you would solve it, look for
>> existing code.
>
>  I think the compressed cache project is the one John mentioned.
>
>> Most times, someone else already had the same idea and the same
>> general solution. Good, less work. Sometimes you were stupid and the
>> existing solution is much better. Good to know. And on very rare
>> occasions, your solution is better, at least in some details.
>> 
>> Well, in this case, the sourceforge project appears to be silent since
>> half a year or so, whatever that means.
>
>  It means Rodrigo has been  busy writting his dissertation, and, most
>recently, looking  for a job :-)  I've talked to him  recently, and he
>intends to continue on with the project, as he might have some time to
>devote to it.
>
>  On a side  note, though, one thing that has  still not been explored
>is compressed  _swap_. Since the project's focus  has been performance
>gains, and it  was not clear from the  beginning that compressing swap
>actually  results  in  performance   gains,  it  still  has  not  been
>implemented. That said, this *is* on the project's to-study list. 
>

I'm going for size gains.  Performance is something I hope to not hurt,
but an increase there is alright.

>
>  Hope this helps,
>
>--  
>  Livio B. Soares
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression
  2003-04-27 19:04                 ` Jörn Engel
  2003-04-27 19:57                   ` Livio Baldini Soares
       [not found]                   ` <200304271609460030.01FC8C2B@smtp.comcast.net>
@ 2003-04-27 21:52                   ` rmoser
  2003-04-27 21:55                     ` Re: Swap Compression -- Try 2 rmoser
  2003-04-28  8:52                   ` Swap Compression Eric W. Biederman
  3 siblings, 1 reply; 36+ messages in thread
From: rmoser @ 2003-04-27 21:52 UTC (permalink / raw)
  To: =?UNKNOWN?Q?J=F6rn?= Engel; +Cc: linux-kernel

Well here's some new code.  I'll get to work on a userspace app
to compress files.  This code ONLY works on fcomp-standard
and does only one BruteForce (bmbinary is disabled) search for
redundancy.  This means three things:

1 - There's no support for messing with the pointer size and mdist/
analysis buffer size (max pointer distance)
2 - The compression ratios will not be the best.  The first match,
no matter how short, will be taken.  If it's less than 4 bytes, it will
return "no match" to the fcomp_push function.
3 - It will be slow.  BruteForce() works.  Period.  The code is too
simple for even a first-day introductory C student to screw up, and
there are NO bugs unless I truly AM a moron.  bmbinary() should
work, and the function it was coded from works in test, but neither
have been written out and proven to work by logic diagram.  It's
fast (infinitely faster than BruteForce()), but I'll try it when I feel that
the rest of the code is working right.

This should be complete for fcomp-standard.  A little alteration will
allow the fcomp-extended to work.  *Wags tail* this past two days
has been fun ^_^;

--Bluefox Icy


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Re:  Swap Compression -- Try 2
  2003-04-27 21:52                   ` rmoser
@ 2003-04-27 21:55                     ` rmoser
  0 siblings, 0 replies; 36+ messages in thread
From: rmoser @ 2003-04-27 21:55 UTC (permalink / raw)
  To: =?UNKNOWN?Q?J=F6rn?= Engel; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1253 bytes --]

ERRRRRHHHHM!!!!!!!!!!....
...*blush*  I should attatch files when I try to upload them.  Let's
try this again!

Well here's some new code.  I'll get to work on a userspace app
to compress files.  This code ONLY works on fcomp-standard
and does only one BruteForce (bmbinary is disabled) search for
redundancy.  This means three things:

1 - There's no support for messing with the pointer size and mdist/
analysis buffer size (max pointer distance)
2 - The compression ratios will not be the best.  The first match,
no matter how short, will be taken.  If it's less than 4 bytes, it will
return "no match" to the fcomp_push function.
3 - It will be slow.  BruteForce() works.  Period.  The code is too
simple for even a first-day introductory C student to screw up, and
there are NO bugs unless I truly AM a moron.  bmbinary() should
work, and the function it was coded from works in test, but neither
have been written out and proven to work by logic diagram.  It's
fast (infinitely faster than BruteForce()), but I'll try it when I feel that
the rest of the code is working right.

This should be complete for fcomp-standard.  A little alteration will
allow the fcomp-extended to work.  *Wags tail* this past two days
has been fun ^_^;

--Bluefox Icy

[-- Attachment #2: fcomp.tar.bz2 --]
[-- Type: application/octet-stream, Size: 11115 bytes --]

begin 755 fcomp.tar.bz2
M0EIH.3%!62936?80L;4`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%N%2F
ML7D@THR&+#UQ0"!PJ8LQLA8TDP8,KNRV>%J8``8@QNFS.]@*Q`H6!G%)!7!:
M#!`,$QF!@-Q%7U+0!H4KF"Y=2MV)648#*);AIC#?:KE@M%'U2HI(KJ9[LY<'
M?NS8BZ\QJ\*'(]9IL(QQ#`@YI-A0[$J=F0(P0)!$]WP*`=`Z=;(6ZH7C8'2"
M&'?34`B;EW\!87.BL7V0HY3.I'E?.SU;ZOL`"#%4DD`PNPHA?2Z'(N/OD(L@
M`N<`,ZQ;=NTQNIQ&\RX46RVAN579H&XY$'4F^[[&I34G*1#_1WE4?!`3+.U<
MN:#N.DA1&XZS),_#OL@GM0[%+.SGUO_3=M'6&S0-R?(W`*GRD#5L<.@+$<N:
MJX/5%CGNJJRHI7\-5L54?\",;,#`>U2-LJI(HW`.(]KUVRVK2&<OX;K8C:BB
M$IEH^$)(0PL7LW`X7X=XP,&$$C(,B1"!?0'F2@=\<H'+*B$4+.A2-B*0@GY=
M:;!20#?[Z"E]71E_TH7,\@2Y[@(ONET!Y'>@Z._1J33G`".Z5G)2`<Z<HB1F
MZSX[.C;(L]60Y@B@0'*;5<BDK6HJ1LX>QO5MI5C2M\LHT9]F<=B@Z^8`#(.Y
C>GA)`"1)"1B[@0!^&3Q4;`NT$`3!H=(?_%W)%.%"0]A"QM0
`
end

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-27 19:04                 ` Jörn Engel
                                     ` (2 preceding siblings ...)
  2003-04-27 21:52                   ` rmoser
@ 2003-04-28  8:52                   ` Eric W. Biederman
  2003-04-28 10:26                     ` Jörn Engel
  3 siblings, 1 reply; 36+ messages in thread
From: Eric W. Biederman @ 2003-04-28  8:52 UTC (permalink / raw)
  To: JXrn Engel; +Cc: rmoser, linux-kernel

JXrn Engel <joern@wohnheim.fh-wedel.de> writes:

> Yes, zlib eats up several 100k of memory. You really notice this when
> you add it to a bootloader that was (once) supposed to be small. :)

I only measured about 32k for decompression.  But that was using
the variant from gzip via the kernel.

The really small algorithm I know about (at least for decompression)
is upx.  The compression is comparable with gzip with a decompressor
that can fit in a page or two of assembly code.

Probably irrelevant at this juncture but...

Eric


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-28  8:52                   ` Swap Compression Eric W. Biederman
@ 2003-04-28 10:26                     ` Jörn Engel
  0 siblings, 0 replies; 36+ messages in thread
From: Jörn Engel @ 2003-04-28 10:26 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: rmoser, linux-kernel

On Mon, 28 April 2003 02:52:15 -0600, Eric W. Biederman wrote:
> JXrn Engel <joern@wohnheim.fh-wedel.de> writes:
> 
> > Yes, zlib eats up several 100k of memory. You really notice this when
> > you add it to a bootloader that was (once) supposed to be small. :)
> 
> I only measured about 32k for decompression.  But that was using
> the variant from gzip via the kernel.

What were you measuring? Code size or runtime memory consumption? It
looks a bit large for code size, but _very_ small for runtime.

> The really small algorithm I know about (at least for decompression)
> is upx.  The compression is comparable with gzip with a decompressor
> that can fit in a page or two of assembly code.

Sounds interesting as well. Maybe we should add a central compression
library to the kernel. zlib is already central, but at least jffs2 and
ppp also have some other algorithms that could be moved and possibly
reused for other subsystems/drivers.

Jörn

-- 
Optimizations always bust things, because all optimizations are, in
the long haul, a form of cheating, and cheaters eventually get caught.
-- Larry Wall 

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
       [not found]           ` <200304282258310030.00DED562@smtp.comcast.net>
@ 2003-04-29  2:58             ` rmoser
  0 siblings, 0 replies; 36+ messages in thread
From: rmoser @ 2003-04-29  2:58 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1616 bytes --]



*********** REPLY SEPARATOR  ***********

On 4/28/2003 at 6:25 PM Timothy Miller wrote:

>rmoser wrote:
>
>>So what's the best way to do this?  I was originally thinking like this:
>>
>>Grab some swap data
>>Stuff it into fcomp_push()
>>When you have 100k of data, seal it up
>>Write that 100k block
>>
>>But does swap compress in 64k blocks?  80x86 has 64k segments.
>>The calculation for compression performance loss, 256/size_of_input,
>>gives a loss of 0.003906 (0.3906%) for a dataset 65536 bytes long.
>>So would it be better to just compress segments, whatever size they
>>may be, and index those?  This would, of course, be much more efficient
>>in terms of finding the data to uncompress.  (And system dependant)
>>
>>
>We're not using DOS here.  x86 has arbitrarily-sized segments.  It is
>the PAGES you want to swap, and they are typically 4k.
>
>
>BTW, I see swap compression as being more valuable for over-loaded
>servers than for PDA's.  Yes, I see the advantage for a PDA, but you
>only get any significant benefit out of this if you have the horsepower
>and RAM required for doing heavy-weight compression.  If you can't
>compress a page very much, you don't benefit much from swapping it to RAM.

Feh.  Selectable compression is the eventual goal.  If you want serious
heavy-weight compression, go with fcomp2.  Ahh heck I'll attatch the
.plan file for fcomp2; this is rediculously RAM and CPU intensive in good
implimentation, so don't even think for a second that you'll want to use
this on your cpu-overloaded boxen.

And no implimenting this right away, it's too much to code!

--Bluefox Icy

[-- Attachment #2: __fcomp2.plan --]
[-- Type: application/octet-stream, Size: 7901 bytes --]

fcomp
Fox Compression 2:  Size is everything

by Bluefox Icy

This algoritm is copyright Bluefox Icy under the LGPL as it exists on April
28, 2003.  LGPL v2.0

Definitions:
  Base 0:  A number that starts at 0.  So 1 byte base 0 counters are ranged
  from 0 to 255.

  Base 1:  A number that starts at 1.  So 1 byte base 1 counters are ranged
  from 1 to 256, with 0x00 being 1 and 0x01 being 2 and 0xFF being 256.

  Order of Redundancy:  A numeric count of how much a specific string is used
  to reference other data in a file's compressed output.

fcomp uses a compression algorithm that is focussed on speed only.  It uses
little RAM, and was intended for kernel-level RAM compression and for packing
executable files on 1 Mhz 6502 processors (its creation purpose).  fcomp2 is
quite different.

fcomp2 uses compression and decompression routines by Bluefox Icy.  It was
created literally with size in mind only.  fcomp2 compression should be sane,
but there's always the warning that I wrote the boyer-moore search myself, and
someone really needs to FSA-prove that it works.  Replace it with KMP,  brute
force, or your own equivalent BM if you want a 100% guarentee.

fcomp2 compressed data is a mixed backpointer/table data format.  Officially,
fcomp2 is a floating size backpointer format; backpointer size and max distance
is capable of switching along the way.  Most implimentations will want to use
a fixed size backpointer though, usually 24 bit (16 MB).

fcomp2 uses a pointer table and various pointer types.  The pointer types are
quite diverse.  A general pointer container looks like so:

TYPE    SIZE    DESC
Byte       1    Type of pointer
X          X    The pointer itself
3Byte      3    24 bit forward reference indicating the location of the next
                pointer.  It is base 0, and a 0 indicates EOS (just like in
		fcomp)

Literal pointers (1) point back into the stream and may be 8, 16, 24, or 32
bit. These pointers are standard go-back-and-copy-N pointers, like fcomp uses.
They provide a pointer within the window that the scan is using.

TYPE    SIZE    DESC
Byte       1    Size N in bytes of pointer data
NByte      N    Distance back to look, base 1 (0 == 1, range is 1..2^N)
NByte      N    Distance to copy, base 1 (0 == 1, range is 0..2^N)

Table pointers (2) are extra power.  Table pointers are pointers that reference
a table which holds the absolute locations in the stream (not including the
table) of data that each pointer points to.  In reality, all back pointers can
be replaced with table pointers.

Please note that by stream, we mean the actual pointer-and-data stream that is
processed in the compression and NOT the supplimentary header or table.

TYPE    SIZE    DESC
Byte       1    Size N in bytes of pointer data.  Increasing the size increases
                your range in the table, i.e. 1 byte can access entries 0..255,
		2 can access 0..65535, 3 0..16777383, and so on.
NByte      N    Index of the entry to copy
NByte      N    Number of bytes base 0 to skip from the beginning
NByte      N    Number of bytes base 1 to copy

The final type of pointer is a NULL (0) pointer.  If the pointer is null, it
simply is blank, i.e. X = 0 in the general pointer container definition.  A
null pointer is always 4 bytes long including the general pointer container
defined above, and 0 bytes long not including it.  It looks like this:

TYPE    SIZE    DESC

Yes, this is complete.

The stream format is:

fcomp2 stream:
TYPE   SIZE    DESC
3Byte     3    Length of X base 0 (for consistency)
stream    X    a bunch of bytes to take as pure stream
Pointer   Y    A pointer inside a general pointer container

The last 2 repeat until EOS, which is where the general pointer container has
its next pointer as a 0.  The stream should always end with a pointer with a
forward reference of 0, either Literal, Table, or NULL.

The fcomp2 table is pretty simple.  It points to offsets in the stream of data,
which is read by a decompressor and used to give further
compression/decompression performance.  This works when things are out of reach
of backpointers.  Also, a very good implimentation may take the time to
optimize the table and stream; that is, it may move all the most commonly used
table entries to the beginning and use the smallest pointer data size possible.

The fcomp2 table is in itself not built for size.  Data of multiple redundancy
is initially entered into the table as a 32 bit (4 byte) offset.  The length is
not stored; the compressor will find an offset from this within the reach of
the next table entry at compression time, while the decompressor reads entry,
skip, and copy.  To do this more easily, the compressor should keep the data
table in the order the data appears in the file until compression is finished,
and then sort the table based on order of redundancy (aka how many times each
entry is used) from greatest to least.  As the table is sorted, the stream and
table both may be adjusted so as to squeeze out more space (i.e. the most used
table entries are referenced as 8 bit pointers, changing the pointers to point
at these and use 8 bit storage changes the compressed stream).  Note that
altering the size of the compressed stream should not alter the table, as it is
in reference to the uncompressed stream.

fcomp2-table:
TYPE    SIZE    DESC
Dword      4    A 32 bit offset of the data in the uncompressed stream

An fcomp2 data file contains a few things.  First are 2 longs:  Table and
Stream offsets in the file.  Second is some data, the table, and the stream.
The "some data" can be anything (encryption flags, CRC's, etc).

fcomp2 data file:
TYPE   SIZE    DESC
DWord     4    32 bit offset base 0 (this is AT 0) of where the table is in the
               fire
DWord     4    32 bit base 0 offset of the fcomp2 stream
stream    X    Whatever you want until the table occurs
fcomp2-table Y  The table
fcomp2-stream Z The stream.  The beginning of this is exactly where a pointer to
               offset 0 in the table would point to

I would encourage the open source community to experiment with implimenting
this compression schema.  It is VERY RAM intensive, but a good implimentation
should be able to squeeze great compression ratios from this.  Here are the
requirements for the best implimentation:

1.  Intelligent Table Generation
  Table entries are each 4 bytes in size.  A table should not be generated at a
  point less than 4 bytes from the previous table.
2.  Optimized Table Sorting
  The entries most used in the table should be placed at the beginning; the
  table should be sorted in descending reference order.  Then the pointers must
  be adjusted (must as in this will break the stream if you don't do this) in
  the compressed stream to point to the new locations of the table entries.  In
  adjusting the pointers, the compressor should shrink them to the smallest
  possible size given the index number they must reference and the
  distance/vector they must skip and copy.  For the best optimization, this
  step should also take into account the distance/vector sizes in the pointers,
  to assess how many pointers would gain and lose size in each range of index
  size (1/2/3/4 bytes) and compute the total size gain (positive or negative)
  for each pointer given the positions, and adjust according to these final
  scores.
3.  Intelligent Table Discarding
  When table entries in the table are close enough together, the pointers which
  reference them may be capable of using only a small set from a larger set of
  table entries.  If this is the case, the compressor should remove those table
  entries and readjust all related pointers.

If a compressor is written, it does not have to follow any of the above to have
compatible output with fcomp2 binary files; however, the above guidelines give
the best compression ratios for fcomp2 compressed files.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
       [not found]                   ` <200304291521120230.0462A551@smtp.comcast.net>
@ 2003-04-29 19:21                     ` rmoser
  0 siblings, 0 replies; 36+ messages in thread
From: rmoser @ 2003-04-29 19:21 UTC (permalink / raw)
  To: linux-kernel

Why keep a fixed page size?  A 4k page can be represented by an
N bit offset in the swap partition (32 for 4 gig or less) and a 13 bit
length description.  Let's not go with the overhead of 13 bit; 16 bit
lengths.  Something divisible by two.  Sure, we gain what
4 + 2 == 6 bytes per page, but we compress out more than that in
most cases (in theory).

and as for RAM, I really prefer the user to control swap-on-ram, and
to have it implimented as such.  4 meg'ers might try SoR but it may
hurt.  The kernel should default to using the RAM swap as its primary
swap partition though.  Why make extra overhead chopping up and
reassembling pages?  We did that with compression.

--Bluefox Icy
(Well that's my opinion)

*********** REPLY SEPARATOR  ***********

On 4/29/2003 at 10:13 AM Timothy Miller wrote:

>Here's a way to keep the two-level swap complexity down, perhaps.
>
>The VM is aware of two kinds of memory space and therefore two kinds of 
>swap.  The first kind of memory is "normal" memory that is used by 
>applications.  When the VM has to swap that, it compresses to RAM.  The 
>second kind of memory is "compressed" memory.  When the VM has to swap 
>that, it swaps it to disk.
>

Swap-on-RAM with compression enabled.

>All swapping operations are done in page units.  Compressed pages will 
>use arbitrary amounts of memory, so when compressed pages are swapped, 
>the boundaries between one compressed page and another are not 
>considered.  Compressed pages will be broken up.  But that's okay, 
>because if there is a page fault in the compressed memory, the VM just 
>swaps in from disk.  Perhaps some intelligent memory management could be 
>employed which reorganizes compressed RAM so that a recently used 
>compressed page does not share a physical page with a compressed page 
>that has not been touched in a while.
>

Ouch.  That introduces extra managment between the compressed RAM
and the swapping procedure.  On the plus, it would save us the hassle
of fragmented swap but heck, idle-time and on-urgent page defragmentation
should take care of that (do I need to explain these concepts?).

>There has been talk of a "simpler" system which compresses to swap 
>without the intermediate level.  The thing is, that intermediate level 
>always exists to some extent.  And trying to manage compressed pages on 
>disk like that can get quite complex.  If we were to compress to a whole 
>number of sectors, just so we could keep things separate, then we would 
>limit the benefit from compressing.  The two level system could be 
>employed to compress to swap simply by keeping the compressed memory 
>fixed and very small.




^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: Swap Compression
@ 2003-05-09  3:21 Perez-Gonzalez, Inaky
  0 siblings, 0 replies; 36+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-05-09  3:21 UTC (permalink / raw)
  To: 'Jörn Engel', Perez-Gonzalez, Inaky
  Cc: 'jw schultz', 'linux-kernel@vger.kernel.org'

> From: Jörn Engel [mailto:joern@wohnheim.fh-wedel.de]
>
> On Wed, 7 May 2003 20:17:32 -0700, Perez-Gonzalez, Inaky wrote:
> > This reminds me of some howto I saw somewhere of someway to
> > use the MTD drivers to access the unused video RAM and turn
> > it into swap (maybe with blkmtd?) ... probably it can be done
> > with that too.
> 
> Jupp, if you know the physical address range of the RAM, it's a piece
> of cake. Except that the slram option parsing is not user-friendly,
> with me being an examplary user.

It should be ... I need to find some time to dig that howto and
try to do it ...

> For memory above 4GB, things are harder. Basically you'd have to write
> a new mtd driver that copies some of the highmem code. Maybe a day or
> two plus testing.

Ok, right to the stack of 'would be nice to work on' stuff. 

The "feeling" thing is going to be groovy to test - I guess some parallel
kernel compiles would do - hmmm ... will think about it.

Thanks,

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own
(and my fault)

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-05-08  3:17 Perez-Gonzalez, Inaky
@ 2003-05-08  8:07 ` Jörn Engel
  0 siblings, 0 replies; 36+ messages in thread
From: Jörn Engel @ 2003-05-08  8:07 UTC (permalink / raw)
  To: Perez-Gonzalez, Inaky
  Cc: 'jw schultz', 'linux-kernel@vger.kernel.org'

On Wed, 7 May 2003 20:17:32 -0700, Perez-Gonzalez, Inaky wrote:
> 
> This reminds me of some howto I saw somewhere of someway to
> use the MTD drivers to access the unused video RAM and turn
> it into swap (maybe with blkmtd?) ... probably it can be done
> with that too.

Jupp, if you know the physical address range of the RAM, it's a piece
of cake. Except that the slram option parsing is not user-friendly,
with me being an examplary user.

For memory above 4GB, things are harder. Basically you'd have to write
a new mtd driver that copies some of the highmem code. Maybe a day or
two plus testing.

> I'd really love it ... I don't know if I can blame it on highmem
> or not, but since I enabled it, my system 'feels' slower.

Go ahead and try it. If it 'feels' faster, it should be possible to
benchmark your feeling into some numbers.

Jörn

-- 
Victory in war is not repetitious.
-- Sun Tzu

^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: Swap Compression
@ 2003-05-08  3:17 Perez-Gonzalez, Inaky
  2003-05-08  8:07 ` Jörn Engel
  0 siblings, 1 reply; 36+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-05-08  3:17 UTC (permalink / raw)
  To: 'jw schultz', 'linux-kernel@vger.kernel.org'



> From: jw schultz [mailto:jw@pegasys.ws]
>
> While we're having thoughts, this thread keeps me thinking
> it would make sense to have a block device driver that would
> be assigned unused memory.
> 
> I don't mean memory on video cards etc.  I'm thinking of the
> 10% of RAM unused when 1GB systems are booted with MEM=900M
> because they run faster with HIGHMEM turned off.
> 
> The primary use for this "device" would be high priority swap.
> Even with whatever overhead it takes to access it should be
> orders of magnitude faster than any spinning media.

This reminds me of some howto I saw somewhere of someway to
use the MTD drivers to access the unused video RAM and turn
it into swap (maybe with blkmtd?) ... probably it can be done
with that too.

I'd really love it ... I don't know if I can blame it on highmem
or not, but since I enabled it, my system 'feels' slower.

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own
(and my fault)

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-05-01 22:07           ` rmoser
@ 2003-05-02  2:46             ` jw schultz
  0 siblings, 0 replies; 36+ messages in thread
From: jw schultz @ 2003-05-02  2:46 UTC (permalink / raw)
  To: linux-kernel

On Thu, May 01, 2003 at 06:07:59PM -0400, rmoser wrote:
> Had a thought.  Why wait for a compression algorithm?  Jorn, if you are going
> to work on putting the code into the kernel and making the stuff to allow the
> swap code to use it, why not start coding it before the compression code is
> finished?  i.e. get the stuff down for the swap filtering (filtering i.e. passing
> through a compression or encryption routine) and swap-on-ram stuff, and later
> take the compression algo code and place the module interface on it and make
> a kernel module.
> 
> At this point, I'd say to allow specified order filters, to allow for swap cyphering
> and compression.  Security, you know; swap files are a security hazard.  Just
> power-off, boot a root disk, pull up the swap partition, rip out the blocks, and
> look for what looks to be the root password.

While we're having thoughts, this thread keeps me thinking
it would make sense to have a block device driver that would
be assigned unused memory.

I don't mean memory on video cards etc.  I'm thinking of the
10% of RAM unused when 1GB systems are booted with MEM=900M
because they run faster with HIGHMEM turned off.

The primary use for this "device" would be high priority swap.
Even with whatever overhead it takes to access it should be
orders of magnitude faster than any spinning media.

-- 
________________________________________________________________
	J.W. Schultz            Pegasystems Technologies
	email address:		jw@pegasys.ws

		Remember Cernan and Schmitt

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-30 12:59         ` Jörn Engel
  2003-04-30 19:18           ` rmoser
@ 2003-05-01 22:07           ` rmoser
  2003-05-02  2:46             ` jw schultz
  1 sibling, 1 reply; 36+ messages in thread
From: rmoser @ 2003-05-01 22:07 UTC (permalink / raw)
  To: =?UNKNOWN?Q?J=F6rn?= Engel; +Cc: linux-kernel



>Actually, I'd like a central compression library with a large
>assortment of algorithms. That way the really common code is shared
>between both (or more) projects is shared.
>
>Also, yet another unused compression algorithm hurts about as bad, as
>yet another unused device driver. It just grows the kernel .tar.bz2.
>
>Jörn


Had a thought.  Why wait for a compression algorithm?  Jorn, if you are going
to work on putting the code into the kernel and making the stuff to allow the
swap code to use it, why not start coding it before the compression code is
finished?  i.e. get the stuff down for the swap filtering (filtering i.e. passing
through a compression or encryption routine) and swap-on-ram stuff, and later
take the compression algo code and place the module interface on it and make
a kernel module.

At this point, I'd say to allow specified order filters, to allow for swap cyphering
and compression.  Security, you know; swap files are a security hazard.  Just
power-off, boot a root disk, pull up the swap partition, rip out the blocks, and
look for what looks to be the root password.

--Bluefox Icy


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-30 12:59         ` Jörn Engel
@ 2003-04-30 19:18           ` rmoser
  2003-05-01 22:07           ` rmoser
  1 sibling, 0 replies; 36+ messages in thread
From: rmoser @ 2003-04-30 19:18 UTC (permalink / raw)
  To: =?UNKNOWN?Q?J=F6rn?= Engel; +Cc: linux-kernel



*********** REPLY SEPARATOR  ***********

On 4/30/2003 at 2:59 PM Jörn Engel wrote:

>On Wed, 30 April 2003 12:48:07 +1000, Con Kolivas wrote:
>> 
>> I don't think a parallel project is a bad idea either. I was just
>suggesting 
>> adding the minilzo algorithm from the linuxcompressed project as one of
>the 
>> compression algorithms available.
>
>Actually, I'd like a central compression library with a large
>assortment of algorithms. That way the really common code is shared
>between both (or more) projects is shared.
>

That's just great, heh.  It will in the future cut kernel code size and matinence
work.

>Also, yet another unused compression algorithm hurts about as bad, as
>yet another unused device driver. It just grows the kernel .tar.bz2.
>

Not to get side tracked, but there is an answer for this.....

Well then let's restructure the kernel's build system soon.  It's 15 seconds
since I read this, and already I'm working out in my head the high-level
workings of a modular build system (what it would look like).

For an example, future kernel releases could be in directories, which contain
the kernel .tar.bz2, then separate sets of drivers and such.  Simply unpacking
these drivers into your kernel source tree could place files that make would
read, i.e. the kernel build system would adapt.  For example:

linux/options/foo.lod <-- Linux Option Definition file.

This file would reference other LO's that it requires, and give configuration
options.  These options would have references to LO's that they require.
They would also reference which version ranges of themselves they are
compatible with.  Thus:

make menuconfig

<M>Foo
----<M>Foo with Bar support

<SELECT> <EXIT> <HELP> <MISSING>

Hit missing on an option, say Foo:

Dependencies for CONFIG_FOO
< >Foo
----< >Bar
----< >Baz [FAILED DEPENDS!]

Hit baz:

Dependencies for CONFIG_FOO_BAZ:

Foo with Baz support needs Baz compatible with Baz v1.32

So you get the Baz option tarball, or the tarball containing it:

linux/options/baz.lod

make menuconfig:

<M>Foo
----<M>Foo with Bar support
----<M>Foo with Baz support


Yes I know this is a hassle, but it's not like Microsoft drivers
where you spend 12 hours all over the net searching for stuff;
the main kernel source distribution tree would contain the
kernel, and the kernel.org mirrors would all have the Linux
Options.  There'd be a tarball for the "default must-have drivers"
separate from the kernel core.

It's just a suggestion for the future.

--Bluefox Icy
>Jörn
>
>-- 
>Time? What's that? Time is only worth what you do with it.
>-- Theo de Raadt
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-30  2:48       ` Con Kolivas
@ 2003-04-30 12:59         ` Jörn Engel
  2003-04-30 19:18           ` rmoser
  2003-05-01 22:07           ` rmoser
  0 siblings, 2 replies; 36+ messages in thread
From: Jörn Engel @ 2003-04-30 12:59 UTC (permalink / raw)
  To: Con Kolivas; +Cc: rmoser, John Bradford, linux-kernel

On Wed, 30 April 2003 12:48:07 +1000, Con Kolivas wrote:
> 
> I don't think a parallel project is a bad idea either. I was just suggesting 
> adding the minilzo algorithm from the linuxcompressed project as one of the 
> compression algorithms available.

Actually, I'd like a central compression library with a large
assortment of algorithms. That way the really common code is shared
between both (or more) projects is shared.

Also, yet another unused compression algorithm hurts about as bad, as
yet another unused device driver. It just grows the kernel .tar.bz2.

Jörn

-- 
Time? What's that? Time is only worth what you do with it.
-- Theo de Raadt

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-30  0:59     ` rmoser
@ 2003-04-30  2:48       ` Con Kolivas
  2003-04-30 12:59         ` Jörn Engel
  0 siblings, 1 reply; 36+ messages in thread
From: Con Kolivas @ 2003-04-30  2:48 UTC (permalink / raw)
  To: rmoser, John Bradford; +Cc: linux-kernel

On Wed, 30 Apr 2003 10:59, rmoser wrote:
> *********** REPLY SEPARATOR  ***********
>
> On 4/29/2003 at 10:14 PM John Bradford wrote:
> >> I want to start from scratch because I am trying a different angle,
> >> and I don't understand fully current projects on it.
> >
> >There is nothing wrong from having a separate, parallel project
> >running - it's a good idea, and generally helps to spark interest in
> >both projects.
>
> THANK YOU!
>
> You've saved me from having to defend meself.

I don't think a parallel project is a bad idea either. I was just suggesting 
adding the minilzo algorithm from the linuxcompressed project as one of the 
compression algorithms available.

Con

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-29 21:14   ` John Bradford
@ 2003-04-30  0:59     ` rmoser
  2003-04-30  2:48       ` Con Kolivas
  0 siblings, 1 reply; 36+ messages in thread
From: rmoser @ 2003-04-30  0:59 UTC (permalink / raw)
  To: John Bradford; +Cc: linux-kernel



*********** REPLY SEPARATOR  ***********

On 4/29/2003 at 10:14 PM John Bradford wrote:

>> I want to start from scratch because I am trying a different angle,
>> and I don't understand fully current projects on it.
>
>There is nothing wrong from having a separate, parallel project
>running - it's a good idea, and generally helps to spark interest in
>both projects.
>

THANK YOU!

You've saved me from having to defend meself.

--Bluefox Icy
>John.
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/




^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-29 20:40 ` rmoser
@ 2003-04-29 21:14   ` John Bradford
  2003-04-30  0:59     ` rmoser
  0 siblings, 1 reply; 36+ messages in thread
From: John Bradford @ 2003-04-29 21:14 UTC (permalink / raw)
  To: rmoser; +Cc: linux-kernel

> I want to start from scratch because I am trying a different angle,
> and I don't understand fully current projects on it.

There is nothing wrong from having a separate, parallel project
running - it's a good idea, and generally helps to spark interest in
both projects.

John.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-29 20:07 Timothy Miller
@ 2003-04-29 20:40 ` rmoser
  2003-04-29 21:14   ` John Bradford
  0 siblings, 1 reply; 36+ messages in thread
From: rmoser @ 2003-04-29 20:40 UTC (permalink / raw)
  To: linux-kernel

*********** REPLY SEPARATOR ***********

On 4/29/2003 at 3:39 PM Timothy Miller wrote:

>
>
>Con Kolivas wrote:
>
>On Tue, 29 Apr 2003 07:35, Timothy Miller wrote:
>
>The work that Rodrigo De Castro did on compressed caching
>(linuxcompressed.sf.net) included a minilzo algorithm which I used by
>default
>in the -ck patch addon as it performed the best for all the reasons you
>mention. Why not look at that lzo code for adoption.
>Some time before rmoser started HIS discussion on compressed swap, I
>started a discussion on the same topic.  Out of that discussion came
>mention of an existing project which did EXACTLY what I was proposing.
>That made me happy.  For some reason rmoser wants to start from scratch.
>He can do that if he wants.  I had only hoped that my earlier mention of
>it would spark interest in taking the existing implementation and adding
>it to the mainline kernel, after some incompatbilities were dealt with.
>Unfortunately, I don't have the time to engage directly in that particular
>aspect the kernel development
>

I want to start from scratch because I am trying a different angle, and I don't understand
fully current projects on it.  I am not trying to discredit anyone.  In fact, I would hope that
the existing implimentation (different as it is) would manage to get itself in as well.
Remember, modularity is all about options. Options aren't just "Do you want this or
that?", but also "How do you want this or that done?"  Plus, I am not compressing the
page cache, assuming I understand what this means.  AFAIK (from others' help), the
page cache is a cached copy of pages that have gone to the swap recently, or been
pulled off recently.  I am not touching that.

Other things (not brought up by me) include making a central compression library for the
kernel (modular, i.e. modprobe zlib and such) (Jorn's idea).  That is something that I think
would be essential for swap compression; why should one module horde all the compression
algo's?

--Bluefox



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
@ 2003-04-29 20:07 Timothy Miller
  2003-04-29 20:40 ` rmoser
  0 siblings, 1 reply; 36+ messages in thread
From: Timothy Miller @ 2003-04-29 20:07 UTC (permalink / raw)
  To: Linux Kernel Mailing List


Con Kolivas wrote:

>On Tue, 29 Apr 2003 07:35, Timothy Miller wrote:
>  
>
>>    
>>
>The work that Rodrigo De Castro did on compressed caching 
>(linuxcompressed.sf.net) included a minilzo algorithm which I used by default 
>in the -ck patch addon as it performed the best for all the reasons you 
>mention. Why not look at that lzo code for adoption.
>
>  
>
Some time before rmoser started HIS discussion on compressed swap, I 
started a discussion on the same topic.  Out of that discussion came 
mention of an existing project which did EXACTLY what I was proposing. 
 That made me happy.  For some reason rmoser wants to start from 
scratch.  He can do that if he wants.  I had only hoped that my earlier 
mention of it would spark interest in taking the existing implementation 
and adding it to the mainline kernel, after some incompatbilities were 
dealt with.  Unfortunately, I don't have the time to engage directly in 
that particular aspect the kernel development.

>  
>


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-28 21:35 ` Timothy Miller
@ 2003-04-29  0:43   ` Con Kolivas
  0 siblings, 0 replies; 36+ messages in thread
From: Con Kolivas @ 2003-04-29  0:43 UTC (permalink / raw)
  To: Timothy Miller, rmoser; +Cc: linux-kernel

On Tue, 29 Apr 2003 07:35, Timothy Miller wrote:
> rmoser wrote:
> >Yeah you did but I'm going into a bit more detail, and with a very tight
> > algorithm.  Heck the algo was originally designed based on another
> > compression algorithm, but for a 6502 packer.  I aimed at speed,
> > simplicity, and minimal RAM usage (hint:  it used 4k for the code AND the
> > compressed data on a 6502, 336 bytes for code, and if I turn it into just
> > a straight packer I can go under 200 bytes on the 6502).
> >
> >Honestly, I just never looked.  I look in my kernel.  But still, the stuff
> > I defined about swapon options, swap-on-ram, and how the compression
> > works (yes, compressed without headers) is all the detail you need about
> > it to go do it AFAIK.  Preplanning should be done there--done meaning
> > workable, not "the absolute best."
>
> I think we might be able to deal with a somewhat more heavy-weight
> compression.  Considering how much faster the compression is than the
> disk access, the better the compression, the better the performance.
>
> Usually, if you have too much swapping, the CPU usage will drop, because
> things aren't getting done.  That means we have plenty of head room to
> spend time compressing rather than waiting.  The speed over-all would go
> up.  Theoretically, we could run into a situation where the compression
> time dominates.  In that case, it would be beneficial to have a tuning
> options which uses a less CPU-intensive compression algorithm.

The work that Rodrigo De Castro did on compressed caching 
(linuxcompressed.sf.net) included a minilzo algorithm which I used by default 
in the -ck patch addon as it performed the best for all the reasons you 
mention. Why not look at that lzo code for adoption.

Con

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-25 22:32 rmoser
@ 2003-04-28 21:35 ` Timothy Miller
  2003-04-29  0:43   ` Con Kolivas
  0 siblings, 1 reply; 36+ messages in thread
From: Timothy Miller @ 2003-04-28 21:35 UTC (permalink / raw)
  To: rmoser; +Cc: linux-kernel



rmoser wrote:

>Yeah you did but I'm going into a bit more detail, and with a very tight algorithm.  Heck the algo was originally designed based on another compression algorithm, but for a 6502 packer.  I aimed at speed, simplicity, and minimal RAM usage (hint:  it used 4k for the code AND the compressed data on a 6502, 336 bytes for code, and if I turn it into just a straight packer I can go under 200 bytes on the 6502).
>
>Honestly, I just never looked.  I look in my kernel.  But still, the stuff I defined about swapon options, swap-on-ram, and how the compression works (yes, compressed without headers) is all the detail you need about it to go do it AFAIK.  Preplanning should be done there--done meaning workable, not "the absolute best."
>  
>
I think we might be able to deal with a somewhat more heavy-weight 
compression.  Considering how much faster the compression is than the 
disk access, the better the compression, the better the performance.  

Usually, if you have too much swapping, the CPU usage will drop, because 
things aren't getting done.  That means we have plenty of head room to 
spend time compressing rather than waiting.  The speed over-all would go 
up.  Theoretically, we could run into a situation where the compression 
time dominates.  In that case, it would be beneficial to have a tuning 
options which uses a less CPU-intensive compression algorithm.

>  
>



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-25 20:48 ` rmoser
  2003-04-25 21:14   ` Jörn Engel
@ 2003-04-25 21:17   ` John Bradford
  1 sibling, 0 replies; 36+ messages in thread
From: John Bradford @ 2003-04-25 21:17 UTC (permalink / raw)
  To: rmoser; +Cc: linux-kernel

> Sorry if this is HTML mailed.  I don't know how to control those settings

HTML mail is automatically filtered from LKML.

> COMPRESSED SWAP

We discussed this on the list quite recently, have a look at:

http://marc.theaimsgroup.com/?l=linux-kernel&m=105018674018129&w=2

and:

http://linuxcompressed.sourceforge.net/

John.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Swap Compression
  2003-04-25 20:48 ` rmoser
@ 2003-04-25 21:14   ` Jörn Engel
  2003-04-25 21:17   ` John Bradford
  1 sibling, 0 replies; 36+ messages in thread
From: Jörn Engel @ 2003-04-25 21:14 UTC (permalink / raw)
  To: rmoser; +Cc: linux-kernel

On Fri, 25 April 2003 16:48:15 -0400, rmoser wrote:
> 
> Sorry if this is HTML mailed.  I don't know how to control those settings

It is not, but if you could limit lines to <80 characters, that would
be nice.

> COMPRESSED SWAP
> 
> This is mainly for things like linux on iPaq (handhelds.org) and
> people who like to play (me :), but how about compressed swap and
> RAM as swap?  To be plausable, we need a very fast compression
> algorithm.  I'd say use the following back pointer algorithm (this
> is headerless and I coded a decompressor in 6502 assembly in about
> 315 bytes) and 100k block sizes (compress streams of data until they
> are 100k in size, then stop.  Include the cap at the end in the
> 100k).
> 
> [...]
> 
> CONCLUSION
> 
> I think compressed swap and swap-on-ram with compression would be a
> great idea, especially for embedded systems.  High-performance
> systems that can handle the compression/decompression without
> blinking would especially benefit, as the swap-on-ram feature would
> give an almost seamless RAM increase.  Low-performance systems would
> take a performance hit, but embedded devices would still benefit
> from the swap-on-ram with compression RAM boost, considering they
> can probably handle the algorithm.  I am looking forward to seeing
> this implimented in 2.4 and 2.5/2.6 if it is adopted.

Nice idea. This might even benefit normal pc style boxes, if the
performance loss through compression is overcompensated by io gains
(less data transferred).

The tiny problem I see is that most people here have tons of whacky
ideas themselves but lack the time to actually implement them. If you
really want to get it done, do it yourself. It doesn't have to be
perfect, if it works in principle and appears to be promising, you
will likely receive enough help to finish it. But you have to get
there first.

At least, that is how it usually works. Feel free to prove me wrong.

Jörn

-- 
When in doubt, use brute force.
-- Ken Thompson

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Swap Compression
       [not found] <200304251640110420.0069172B@smtp.comcast.net>
@ 2003-04-25 20:48 ` rmoser
  2003-04-25 21:14   ` Jörn Engel
  2003-04-25 21:17   ` John Bradford
  0 siblings, 2 replies; 36+ messages in thread
From: rmoser @ 2003-04-25 20:48 UTC (permalink / raw)
  To: linux-kernel

please CC a copy to me personally; I am not subscribed.

Sorry if this is HTML mailed.  I don't know how to control those settings


COMPRESSED SWAP

This is mainly for things like linux on iPaq (handhelds.org) and people who like to play (me :), but how about compressed swap and RAM as swap?  To be plausable, we need a very fast compression algorithm.  I'd say use the following back pointer algorithm (this is headerless and I coded a decompressor in 6502 assembly in about 315 bytes) and 100k block sizes (compress streams of data until they are 100k in size, then stop.  Include the cap at the end in the 100k).

Here is how the compression works (use fixed width font):
;
; Type Size Description
; Byte 1 Distance to the next backpointer. 0 means end-of-stream.
; Stream X Just straight data, no work needbe performed on it.
; Byte 1 Distance (up to 256, it's base 1) back to seek
; Byte 1 Number of bytes (Up to 255) to copy. 0 means don't
; really do anything (for chaining pointers in large
; areas of nonredundant data)
;
; The above repeats until the end of the stream is reached. Teach by example!
;
; 04 00 01 02 03 03 03 04 00 01 02 03 05 04 06 01 03 00 00 00
; ^ & # ^ & # ^ & # ^
; ^ = Distance to next; & = backseek; # = duplicate length
;
; The above stream uncompresses to:
; 00 01 02 03 00 01 02 00 01 02 03 01 02 00 01 01 03
;
; Note how very small datasets do not compress well. Very large would
; begin to catch up. This is only a 17 byte dataset.

Also, use a booyer-moore algorithm to do the redundancy searching (modify the one in the fdber project at fdber.sourceforge.net to work on binary data, for instance) to further speed it up.  In the end I'd project about a 2-4k code increase (compiled/assembled) in the kernel size, plus 256 bytes for the compression/decompression buffer, plus the dedicated 100k to load the compressed block into RAM.  So about 2-4k increase in the kernel size and 105k increase in RAM usage.

The feature should be optional, and controlled by swapon options.  For instance:

swapon -o compress /dev/hda5

The above could turn a swap partition on under compressed swap mode.  Of course we only would want to use 100k blocks of compressed data, but some extra code can allow the user to configure it:

swapon -o compress=1M /dev/hda5

1 MB block size for instance if you want.  Don't make this too limited; if such a thing were implimented, with such an option, I'd still expect the following to work:

swapon -o compress=1247299 /dev/hda5

to load a swap partition with 1,247,299 byte blocks.  Of course there'd be a rediculous cap on the high end (500 MB block size?!!!!!!!!!!!!), and an impossible cap on both ends (block size > available RAM; block size < 5 (a valid stream fits in 4 but it can't store any data or be processed)).

For predicting available swap, just take statistics and do some calculations, figure out what the average ratio is, and give that times real size as the total swap size.  If you really really care that much, discard outliers.

SWAP ON RAM

The other feature, for handheld devices, is for all those iPaqs with 32 or 64 MB RAM:  swap-on-RAM.  This is useless (i.e. swap on a RAMdisk), but with the swap compression it becomes useful.

Swap on RAM allows the swap driver to use RAM directly as swap, i.e. not as a swap file on a ramdisk.  For instance:

swapon -o compress -o swaponram=16M

The above would use 16 MB of my RAM as a compressed swap file, negating the overhead of disk access, filesystem control, ramdisk control, and so on.  On an iPaq with 32 MB RAM, I could access say 16 M RAM (physical) and 32 MB swap now, giving me 1.5x my real ram (predicted).  With 64 MB, it would be 82 MB RAM (1.25x real RAM), or I could just use 32MB (1.5x = 96 MB) or even 48 MB (1.75x = 112 MB).  Can't use all of it of course; and the more I use the more it swaps.

When a real swap and a RAM swap exist, a RAM swap should be the first choice for swapping out (highest precidence).  This would keep performence up the most under these odd conditions.


CONCLUSION

I think compressed swap and swap-on-ram with compression would be a great idea, especially for embedded systems.  High-performance systems that can handle the compression/decompression without blinking would especially benefit, as the swap-on-ram feature would give an almost seamless RAM increase.  Low-performance systems would take a performance hit, but embedded devices would still benefit from the swap-on-ram with compression RAM boost, considering they can probably handle the algorithm.  I am looking forward to seeing this implimented in 2.4 and 2.5/2.6 if it is adopted.

-- Bluefox Icy


^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2003-05-09  3:08 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-25 22:48 Re: Swap Compression rmoser
2003-04-26  9:17 ` Jörn Engel
     [not found]   ` <200304261148590300.00CE9372@smtp.comcast.net>
     [not found]     ` <20030426160920.GC21015@wohnheim.fh-wedel.de>
2003-04-26 23:41       ` Some code for " rmoser
2003-04-27  2:24       ` rmoser
2003-04-27  9:04         ` Jörn Engel
2003-04-27 17:24           ` rmoser
2003-04-27 17:51             ` Jörn Engel
2003-04-27 18:22               ` William Lee Irwin III
2003-04-27 18:31               ` rmoser
2003-04-27 19:04                 ` Jörn Engel
2003-04-27 19:57                   ` Livio Baldini Soares
2003-04-27 20:24                     ` rmoser
     [not found]                   ` <200304271609460030.01FC8C2B@smtp.comcast.net>
2003-04-27 20:10                     ` rmoser
2003-04-27 21:52                   ` rmoser
2003-04-27 21:55                     ` Re: Swap Compression -- Try 2 rmoser
2003-04-28  8:52                   ` Swap Compression Eric W. Biederman
2003-04-28 10:26                     ` Jörn Engel
     [not found]                 ` <3EAE8899.2010208@techsource.com>
     [not found]                   ` <200304291521120230.0462A551@smtp.comcast.net>
2003-04-29 19:21                     ` rmoser
     [not found]         ` <3EADAA5D.1090408@techsource.com>
     [not found]           ` <200304282258310030.00DED562@smtp.comcast.net>
2003-04-29  2:58             ` rmoser
  -- strict thread matches above, loose matches on Subject: below --
2003-05-09  3:21 Perez-Gonzalez, Inaky
2003-05-08  3:17 Perez-Gonzalez, Inaky
2003-05-08  8:07 ` Jörn Engel
2003-04-29 20:07 Timothy Miller
2003-04-29 20:40 ` rmoser
2003-04-29 21:14   ` John Bradford
2003-04-30  0:59     ` rmoser
2003-04-30  2:48       ` Con Kolivas
2003-04-30 12:59         ` Jörn Engel
2003-04-30 19:18           ` rmoser
2003-05-01 22:07           ` rmoser
2003-05-02  2:46             ` jw schultz
2003-04-25 22:32 rmoser
2003-04-28 21:35 ` Timothy Miller
2003-04-29  0:43   ` Con Kolivas
     [not found] <200304251640110420.0069172B@smtp.comcast.net>
2003-04-25 20:48 ` rmoser
2003-04-25 21:14   ` Jörn Engel
2003-04-25 21:17   ` John Bradford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).