🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #24964

Re: Cleanfeed hashing

#24964
From: Kenneth Herron
Date: Wed, 07 Jan 1998 00:00
67 lines
2738 bytes
In article <000034B2C7DA.NO_UCE@mauve.demon.co.uk>,
Ian Stirling  <000034B2C7DA.NO_UCE@mauve.demon.co.uk> wrote:
|Kenneth Herron <kherron@campus.mci.net> wrote:
|: I've been hacking heavily on cleanfeed and have experimented with
|: perl's built-in CRC generator. CRCs are much faster than MD5, but more
|: prone to false positives.  Nevertheless, I've had good results
|
|Are they actually that much faster?

	# perl speedtrial
	md5 test: ............... 15000 calls, 40 seconds
	CRC test: ............... 15000 calls, 8 seconds
	# perl speedtrial
	md5 test: ............... 15000 calls, 35 seconds
	CRC test: ............... 15000 calls, 11 seconds
	# r
	perl speedtrial
	md5 test: ............... 15000 calls, 39 seconds
	CRC test: ............... 15000 calls, 7 seconds
	# cat speedtrial
	#!/usr/local/bin/perl
	my $md5;
	eval {require MD5; $md5 = new MD5};
	 
	# 36*84 = 3024 characters; avg article length is supposed to be ~ 3000.
	$test = 'abcdefghijklmnopqrstuvwxyz0123456789' x 84;
	 
	# call each hasher $runs * $trials times, with a dot every $trials call.
	$trials = 1000;
	$runs = 15;
	 
	$| = 1;
	 
	print "md5 test: ";
	$now = time;
	for ($j = $runs; $j--; ) {
		for ($i = $trials; $i--; ) {
			$foo = $md5->hexhash($test);
		}
		print '.';
	}
	$then = time;
	printf " %d calls, %d seconds\n", $trials * $runs, $then - $now;
	 
	print "CRC test: ";
	$now = time;
	for ($j = $runs; $j--; ) {
		for ($i = $trials; $i--; ) {
			$foo = unpack('%24S*', $test);
		}
		print '.';
	}
	$then = time;
	printf " %d calls, %d seconds\n", $trials * $runs, $then - $now;
	 
	exit 0;

The CRC is also shorter (~7 characters here, vs. 32 for the md5 hash).
As I noted before, CRC is an inferior algorithm so some additional
work must be done to guard against false matches, but the resource
savings over MD5 give you a lot of room to work with.
-- 
Kenneth Herron -- kherron@campus.mci.net
No animals were harmed during the production of this message.

Technical Details
Message-ID: <690i1e$i3a$2@news.campus.mci.net>
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
References: <000034AD3C93.NO_UCE@mauve.demon.co.uk> <68ucnc$abl$1@news.campus.mci.net> <000034B2C7DA.NO_UCE@mauve.demon.co.uk>

Show Full Headers
Complete Article Headers
Message-ID: <690i1e$i3a$2@news.campus.mci.net>
Subject: Re: Cleanfeed hashing
Date: Wed, 07 Jan 1998 00:00:00 +0000
From: kherron@campus.mci.net (Kenneth Herron)
References: <000034AD3C93.NO_UCE@mauve.demon.co.uk> <68ucnc$abl$1@news.campus.mci.net> <000034B2C7DA.NO_UCE@mauve.demon.co.uk>
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: 313691547
Distribution: inet
Supersedes: <690hf0$i3a$1@news.campus.mci.net>
Organization: CampusMCI
Newsgroups: news.software.nntp
X-Newsposter: trn 4.0-test54 (18 Feb 97)