Article View: news.software.nntp
Article #20979A Study on INN history cache
From: Sang-yong Suh
Date: Tue, 26 Aug 1997 00:00
Date: Tue, 26 Aug 1997 00:00
137 lines
5404 bytes
5404 bytes
It looks like that history cache is one of the important issues among
Usenet news admins. I am also interested in it. Spent some time,
and would like to report you about the result.
My topics cover followings:
1. Is it possible to find optimum cache size?
2. Is Jeff Garzik's 32bit dbzhash() enough to avoid hash collision?
3. If the 32bit dbzhash() is not enough, what would be an alternative
that can effectively avoid the hash collision?
I have written a tiny program which examines the collision of the 32-bit
dbzhash() used in some version of INN history cache. The program reads
history text file, extracts the MessageID and calls the 32-bit dbzhash().
The MessageID and hash value are saved to check whether some of the
different MessageIDs produce same hash value or not. If it detects
the hash collision, the hash value and the IDs are printed.
I made input history text from a running news server with following
command:
% cut -f1 history | sort | uniq >history.uniq
and got containing 1,862,518 IDs in history.uniq.
1. Cache usage study:
My test program used HISCACHESIZE of 65536 (64K) as found in the original
distribution. The program printed cache usage histogram at every 16K
up to 64K. The first column is the frequency of a cache usage.
The second column is the total number of slots used that many times until
16K messages were processed. The third column is the same number when
32K messages were processed, ... and so on. The result is:
freq 16384 32768 49152 65536
---- ----- ----- ----- -----
0 51035 39763 30909 24119
1 12768 19822 23314 24085
2 1587 1587 5026 8639
3 143 817 2200 4020
4 2 97 413 1015
5 1 11 58 206
6 0 0 3 26
7 0 0 0 3
The row of "freq 0" means that the number of unsed slots.
The row of "freq 1" represents the number of slots just once, which,
in ideal situation, must be same as the total number of input messages.
Sorry! I can't determine the optimum cache size yet. I just guess
that the 60%(19822/32768) messages are still cacheable if I use cache
size which is two times bigger than the expected number of fresh
messages.
2. Collision study: The sample run gave me:
-- 292988b5
<01bcad76$112f7400$06b01fc3@olialiconp133>
<01bcae78$33b8f840$1faf31ce@pstacey.global.co.za>
-- 7992489d
<01bcaca8$e2e56960$3c4346d1@linkous.clark.net>
<01bcaeac$f11c4160$bd0753d1@bill49>
[many lines omitted...]
----------------------------
Total 1862519 collisions 106
----------------------------
Oops! There are some hash collisions! The collided hash values are
shown with the input MessageID pairs. For the sample history,
the hash will collide with the probability of once every 18K articles.
This means that we may errorneously refuse one message out of 18K articles.
Is this result comply with the known hash theory? I remember MD5
using 128 bit hash has the collision probability of 2**(-64).
If that's true, for 31-bit (dbzhash is actually 31 bit hash) hash,
the collision probabilty should be about 2**(-15.5).
3. An extension to dbzhash()
I have an idea extending the existing 32-bit dbzhash() to 64 bits.
Let me first tell about you my result, and then how I made it.
My test program, "cachetest64", using the same input history gave me
following output:
--------------------------
Total 1862519 collisions 0
--------------------------
Now it's the time to tell you how I am ignorant on hash theory.
The appended is my extension to dbzhash(). It just computes the
existing dbzhash twice --- forward, and then backward. The most
significant bit of the second hash is generated from the input
length. The two 32-bit hashes are combined to make 64-bit hash.
Actually, it is 63 bits. The unused bit can be used to save
the FOUND flag. And the probability of the hash collision,
I guess, is 2**(-31.5), which can be safely applied for our current
Usenet history cahche.
--
sysuh
#define HASH64 /* use extended dbzhash */
#ifdef HASH64
#define _HASH long long
#else
#define _HASH long
#endif
_HASH
dbzhash(name, size_in)
register char *name;
register int size_in;
{
long sum = 0L;
int size;
_HASH hash;
size = size_in;
while (size--) {
sum = (sum >> 7) ^ CrcTable[(sum ^ (*name++)) & 0x7f];
}
hash = sum;
#ifdef HASH64
size = size_in;
while (size--) {
sum = (sum >> 7) ^ CrcTable[(sum ^ (*--name)) & 0x7f];
}
if (size_in % 2) sum |= 0x80000000;
hash = (hash << 32) | sum;
#endif
return hash;
}
Technical Details
Message-ID:
<5tu1mf$s4c@news.kigam.re.kr>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <5tu1mf$s4c@news.kigam.re.kr> Subject: A Study on INN history cache Date: Tue, 26 Aug 1997 00:00:00 +0000 From: sysuh@news.kigam.re.kr (Sang-yong Suh) Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 268566644 Organization: Korea Inst Geology Mining & Materials Reply-To: sysuh@kigam.re.kr Newsgroups: news.software.nntp