From: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
To: rmoser <mlmoser@comcast.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Re: Swap Compression
Date: Sun, 27 Apr 2003 19:51:47 +0200 [thread overview]
Message-ID: <20030427175147.GA5174@wohnheim.fh-wedel.de> (raw)
In-Reply-To: <200304271324370750.01655617@smtp.comcast.net>
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
next prev parent reply other threads:[~2003-04-27 17:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-25 22:48 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 [this message]
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-04-25 22:32 rmoser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030427175147.GA5174@wohnheim.fh-wedel.de \
--to=joern@wohnheim.fh-wedel.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mlmoser@comcast.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®