Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 May 2019 14:39:25 +0000
From:      Rick Macklem <rmacklem@uoguelph.ca>
To:        Peter Eriksson <pen@lysator.liu.se>, "freebsd-fs@freebsd.org" <freebsd-fs@FreeBSD.org>
Subject:   test hash functions for fsid
Message-ID:  <YQBPR0101MB2260D82BAE348FB82902508CDD320@YQBPR0101MB2260.CANPRD01.PROD.OUTLOOK.COM>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Hi,

If you have a FreeBSD system with lots of local file systems (1000s), maybe you could
run the attached program on it and email me the stats.
I'm just trying to see how well these hash functions work on fsids.

Thanks in advance, rick

[-- Attachment #2 --]
#include <stdio.h>
#include <sys/param.h>
#include <sys/fnv_hash.h>
#include <sys/hash.h>
#include <sys/mount.h>

int
main(int argc, char *argv[])
{
	int h1[256], h2[256], h3[256], h4[256], i, max, min, num;
	struct statfs *mntbufp;

	for (i = 0; i < 256; i++) {
		h1[i] = 0;
		h2[i] = 0;
		h3[i] = 0;
		h4[i] = 0;
	}
	num = getmntinfo(&mntbufp, MNT_NOWAIT);
	for (i = 0; i < num; i++) {
		h1[fnv_32_buf(&mntbufp[i].f_fsid, sizeof(fsid_t), 0) % 256]++;
		h2[fnv_32_buf(&mntbufp[i].f_fsid, sizeof(fsid_t), FNV1_32_INIT) % 256]++;
		h3[hash32_buf(&mntbufp[i].f_fsid, sizeof(fsid_t), 0) % 256]++;
		h4[hash32_buf(&mntbufp[i].f_fsid, sizeof(fsid_t), HASHINIT) % 256]++;
	}
	min = 10000000;
	max = 0;
	for (i = 0; i < 256; i++) {
		if (h1[i] > max)
			max = h1[i];
		if (h1[i] < min)
			min = h1[i];
	}
	printf("H1: max=%d min=%d\n", max, min);
	min = 10000000;
	max = 0;
	for (i = 0; i < 256; i++) {
		if (h2[i] > max)
			max = h2[i];
		if (h2[i] < min)
			min = h2[i];
	}
	printf("H2: max=%d min=%d\n", max, min);
	min = 10000000;
	max = 0;
	for (i = 0; i < 256; i++) {
		if (h3[i] > max)
			max = h3[i];
		if (h3[i] < min)
			min = h3[i];
	}
	printf("H3: max=%d min=%d\n", max, min);
	min = 10000000;
	max = 0;
	for (i = 0; i < 256; i++) {
		if (h4[i] > max)
			max = h4[i];
		if (h4[i] < min)
			min = h4[i];
	}
	printf("H4: max=%d min=%d\n", max, min);
}

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YQBPR0101MB2260D82BAE348FB82902508CDD320>