Thread View: news.software.nntp
4 messages
4 total messages
Started by Sang-yong Suh
Tue, 26 Aug 1997 00:00
A Study on INN history cache
Author: 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;
}
Re: A Study on INN history cache
Author: Ken Leland
Date: Wed, 27 Aug 1997 00:00
Date: Wed, 27 Aug 1997 00:00
22 lines
1401 bytes
1401 bytes
In article <5u2ilk$2ji$1@news2.xs4all.nl>, Cor Bosman <cor@xs4all.nl> wrote: > >Then explain me why Im having serious trouble with just this setup. >I have a diablo server for incoming/outgoing feeds, and 1 feed towards >2 reader boxes. They can not keep up. Here's the mountpoints: ... > >Am I just forgetting some incredible speed improving patch? Or is >my disksetup the worst you've ever seen? How are you doing on tuning tips (spinne.com et al). Running crosspost? Whats your OS IO Buffer area size (BUFFMEM etc)? Mine wants to be huge (50M). Have you put the timer patch in? What does it say for msecs/artwrite, msecs/hishave, where the time is going etc. 1.5.1 should work, with a little more investigation. Ken Leland
Re: A Study on INN history cache
Author: coneill
Date: Wed, 27 Aug 1997 00:00
Date: Wed, 27 Aug 1997 00:00
73 lines
4001 bytes
4001 bytes
sysuh@news.kigam.re.kr (Sang-yong Suh) writes: > I'm afraid that we are talking about different sujbect, because > my answers to the above are completely different from you. :-( Yes, I'm afraid I initally misunderstood your question. > I have been running two in boxes with 1024K HISCACHESIZE, both having > 20+ peers, and still I belive I'll have to increase it if I can afford > the memory. I still think you'd be better off implementing a better collision handling algorithm so that you get better temporal locality. OTOH, you may want to look at the new dbz code since you're already using 8mb for cache on a 32bit machine, and the new dbz code pretty much eliminates the need for history cache if you have the memory to mmap the .pag file. Typical lookup time for me on a PPro200 is measured in tens of microseconds. > There are two types of hash collisions. The first is that two different > msg ids give same hash value. The second type is collision of the two > different hashes within the hash table produced by > (hash_val % HISCASHSIZE). If you keep the original msg id string, > like your first announced history cache, I agree you, i.e., no need to > use more than 512K HISCACHESIZE, and the existing dbzhash() is sufficient. > Actually, the dbzhash() is named by you but not Jeff Garzik. > > Due to my short writing skill, I wrote > > "Is Jeff Garzik's dbzhash() suffcient?", > > hoping you to understand as > > "Is 32-bit dbzhash(), used in Jeff Garzik's history cache, > enough for the history cache? His cache does not store original > MessageID string in memory, and relies on the cache status > for the existence of the msg id." I'm no longer using my original history cache code. What I'm using now more closely resembles Jeff's code, but I'm also using a 48bit md5 hash instead of the crc32. See ftp://ftp.fnord.net/pub/cvs-inn/snapshots for the current code. > If two different msg ids give same hash value, we must not determine > the existence of a msg id from the hash alone, and have to store the > original string like yours and use strcmp(). However, if we are sure > that the collision rarely occurs, say, one message per year, some people, > like me, may prefer not to store the string in memory. The risk is > compensated by the better history performance. May be some people > prefer yours, because it has zero probability of error. It also uses memory much less efficently and has memory leaks. :( > Obviously, my test result showed that the current dbzhash() will > errorneously refuse to receive an article once per 18K messages. > The error rate may be one message per hour. > To avoid this, we must purge cache rapidly, meaning we must > use small caches. How much small should it be? > My intension is improving Jeff's idea. I'm surprised that crc32 is colliding that often. I suppose that is a problem :) > I am now sure that our approaches are quite different. I am trying to > make the cache more perfect. However, you have aother tool beyond > the history cache. You're trying to make the hash more perfect, I'm trying to increase the hit rate on the cache. I'd prefer that whatever solution we come to not use GCCism's such as long long. Anyone have any good modulus code that isn't recursive?
Re: A Study on INN history cache
Author: coneill
Date: Thu, 28 Aug 1997 00:00
Date: Thu, 28 Aug 1997 00:00
16 lines
1436 bytes
1436 bytes
cor@xs4all.nl (Cor Bosman) writes: > Turns out 1 of our admins mistakenly put one of the machines in a > 10mbit switch instead of a 100mbit switch. With a dozen switches around > i guess you can make a mistake easily..(LART!) I decided to check this > after I concluded that my setup was not at fault. > > After putting it where it belongs the performance increased dramatically. > So I can safely conclude that a 10mbit switched ethernet is not > enough to deal with 3 feeds, and 200 clients. More likely you had a mismatched duplex setting on the ethernet switch. I've found that if the switch and the card don't agree on the duplex it's hard to get even one feed in.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads