socsvn commit: r236294 - soc2012/gpf/misc
gpf at FreeBSD.org
gpf at FreeBSD.org
Thu May 24 15:57:56 UTC 2012
Author: gpf
Date: Thu May 24 15:57:53 2012
New Revision: 236294
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=236294
Log:
adding a few misc files for safekeeping
Added:
soc2012/gpf/misc/calc_space.sh (contents, props changed)
soc2012/gpf/misc/ph.py
soc2012/gpf/misc/server_results.txt
soc2012/gpf/misc/vm_results.txt
Added: soc2012/gpf/misc/calc_space.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2012/gpf/misc/calc_space.sh Thu May 24 15:57:53 2012 (r236294)
@@ -0,0 +1,82 @@
+#!/bin/sh
+# XXXgpf: script to generate a few useful statistics about system files
+
+#BLOCKSIZE="K"
+
+count_dir(){
+ cd "$1"
+ #echo `pwd`
+
+ for file in `ls`
+ do
+ if [ -d "$file" ]
+ then
+ count_dir $file
+ cd ..
+ else
+ check=1
+ # only take into account static & dynamic libraries
+ if [ $libr_flag -eq 1 ]
+ then
+ type=`echo $file | awk -F"." '{print $2}'`
+ if [ "$type" != "a" ] && [ "$type" != "so" ]
+ then
+ check=0
+ fi
+ fi
+
+ if [ $check -eq 1 ]
+ then
+ size=`du $file | cut -f 1`
+ if [ "$size" -gt "$max" ]
+ then
+ max=$size
+ fi
+ #size=`ls -l $file_path | awk -F" " '{print $5}'`
+ size_sum=`expr $size_sum + $size`
+ nfiles=`expr $nfiles + 1`
+ fi
+ fi
+ done
+}
+
+compute(){
+ size_average=`echo "scale=2;$size_sum/$nfiles" | bc`
+ avg_hashes_per_file=`echo "scale=2;$size_average/4" | bc`
+ avg_total_hashes_size_per_file=`echo "scale=2;$avg_hashes_per_file*64" | bc`
+
+ echo "total size sum =" $size_sum "K"
+ echo "total files =" $nfiles
+ echo "arithmetic mean file size =" $size_average "K"
+ echo "max file size =" $max "K"
+ echo "average hashes per file=" $avg_hashes_per_file
+ echo "assuming 64byte hashes, that's" $avg_total_hashes_size_per_file "bytes per file"
+ echo
+}
+
+# system binaries
+for dir in `echo $PATH | awk -F":" '{print $1,$2,$3,$4,$5,$6,$7}'`
+do
+ size_sum=0
+ nfiles=0
+ libr_flag=0
+ max=0
+ echo "computing for directory" $dir
+ count_dir $dir
+ compute
+done
+
+#system libraries
+LIBPATH="/lib:/usr/lib:/usr/local/lib"
+for dir in `echo $LIBPATH | awk -F":" '{print $1,$2,$3}'`
+do
+ size_sum=0
+ nfiles=0
+ libr_flag=1
+ max=0
+ echo "computing for directory" $dir
+ count_dir $dir
+ compute
+done
+
+exit 0
Added: soc2012/gpf/misc/ph.py
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2012/gpf/misc/ph.py Thu May 24 15:57:53 2012 (r236294)
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# gleb's script to try out hash table stuff
+
+import random
+import gmpy
+from gmpy import mpz
+
+def count_coll(R, p, embed):
+ s = 0
+ c = [ 0 for x in xrange(0, p) ]
+ for i in xrange(0, len(R)):
+ r = R[i]
+ c[r % p] += 1
+ m = max(c)
+ coll = [ c.count(i) for i in xrange(m, 0, -1) ]
+ slots = p * embed
+ fast = sum([ coll[-i] * i for i in xrange(1, embed + 1)])
+ fast = float(100) * fast / len(R)
+ unused0 = c.count(0) * embed
+ unused = sum([ coll[-i] * (embed - i) for i in xrange(1, embed)])
+ unusedp = float(100) * (unused0 + unused) / slots
+ return "Max collisions: %s, slots: %d/%d, unused: %.02f%% %d+%d, embedded %d: %.02f%%, %s" % \
+ (m, p, slots, unusedp, unused0, unused, embed, fast, coll)
+
+def clp2(x):
+ x = x - 1
+ x = x | (x >> 1)
+ x = x | (x >> 2)
+ x = x | (x >> 4)
+ x = x | (x >> 8)
+ x = x | (x >>16)
+ return x + 1
+
+def generate_ph(n):
+ # pz = int(gmpy.next_prime(mpz(n*2/5)))
+ pz = int(gmpy.next_prime(mpz(n*3/5)))
+ pz1 = int(gmpy.next_prime(mpz(n)))
+ p2 = int(clp2(n) / 2)
+ print 'Items: %s' % (n,)
+ R = [ random.getrandbits(64) for i in xrange(0, n) ]
+ while len(R) != len(set(R)):
+ print 'Initial hash collisions, regenerating: %s/%s', len(set(R)), n
+ R = [ random.getrandbits(64) for i in xrange(0, n) ]
+
+ print 'Prime ', count_coll(R, pz, 4)
+ print 'Power2', count_coll(R, p2, 4)
+ print 'Prime ', count_coll(R, pz, 2)
+ print 'Power2', count_coll(R, p2, 2)
+ print 'Prime ', count_coll(R, pz1, 1)
+ print 'Power2', count_coll(R, p2 * 2, 1)
+ print ''
+
+generate_ph(1000)
+generate_ph(11000)
+generate_ph(22000)
+generate_ph(140000)
Added: soc2012/gpf/misc/server_results.txt
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2012/gpf/misc/server_results.txt Thu May 24 15:57:53 2012 (r236294)
@@ -0,0 +1,80 @@
+computing for directory /sbin
+total size sum = 5508 K
+total files = 129
+arithmetic mean file size = 42.69 K
+max file size = 736 K
+average hashes per file= 10.67
+assuming 64byte hashes, that's 682.88 bytes per file
+
+computing for directory /bin
+total size sum = 1488 K
+total files = 44
+arithmetic mean file size = 33.81 K
+max file size = 324 K
+average hashes per file= 8.45
+assuming 64byte hashes, that's 540.80 bytes per file
+
+computing for directory /usr/sbin
+total size sum = 32120 K
+total files = 286
+arithmetic mean file size = 112.30 K
+max file size = 2144 K
+average hashes per file= 28.07
+assuming 64byte hashes, that's 1796.48 bytes per file
+
+computing for directory /usr/bin
+total size sum = 131292 K
+total files = 464
+arithmetic mean file size = 282.95 K
+max file size = 29152 K
+average hashes per file= 70.73
+assuming 64byte hashes, that's 4526.72 bytes per file
+
+computing for directory /usr/games
+total size sum = 0 K
+total files = 0
+arithmetic mean file size = 0.00 K
+max file size = 0 K
+average hashes per file= 0.00
+assuming 64byte hashes, that's 0.00 bytes per file
+
+computing for directory /usr/local/sbin
+total size sum = 2604 K
+total files = 41
+arithmetic mean file size = 63.51 K
+max file size = 1120 K
+average hashes per file= 15.87
+assuming 64byte hashes, that's 1015.68 bytes per file
+
+computing for directory /usr/local/bin
+total size sum = 189868 K
+total files = 751
+arithmetic mean file size = 252.82 K
+max file size = 4992 K
+average hashes per file= 63.20
+assuming 64byte hashes, that's 4044.80 bytes per file
+
+computing for directory /lib
+total size sum = 7560 K
+total files = 61
+arithmetic mean file size = 123.93 K
+max file size = 1440 K
+average hashes per file= 30.98
+assuming 64byte hashes, that's 1982.72 bytes per file
+
+computing for directory /usr/lib
+total size sum = 50004 K
+total files = 541
+arithmetic mean file size = 92.42 K
+max file size = 2976 K
+average hashes per file= 23.10
+assuming 64byte hashes, that's 1478.40 bytes per file
+
+computing for directory /usr/local/lib
+total size sum = 250968 K
+total files = 1107
+arithmetic mean file size = 226.71 K
+max file size = 30080 K
+average hashes per file= 56.67
+assuming 64byte hashes, that's 3626.88 bytes per file
+
Added: soc2012/gpf/misc/vm_results.txt
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2012/gpf/misc/vm_results.txt Thu May 24 15:57:53 2012 (r236294)
@@ -0,0 +1,80 @@
+computing for directory /sbin
+total size sum = 6736 K
+total files = 131
+arithmetic mean file size = 51.41 K
+max file size = 832 K
+average hashes per file= 12.85
+assuming 64byte hashes, that's 822.40 bytes per file
+
+computing for directory /bin
+total size sum = 1552 K
+total files = 44
+arithmetic mean file size = 35.27 K
+max file size = 336 K
+average hashes per file= 8.81
+assuming 64byte hashes, that's 563.84 bytes per file
+
+computing for directory /usr/sbin
+total size sum = 33060 K
+total files = 290
+arithmetic mean file size = 114.00 K
+max file size = 2176 K
+average hashes per file= 28.50
+assuming 64byte hashes, that's 1824.00 bytes per file
+
+computing for directory /usr/bin
+total size sum = 147164 K
+total files = 479
+arithmetic mean file size = 307.23 K
+max file size = 33664 K
+average hashes per file= 76.80
+assuming 64byte hashes, that's 4915.20 bytes per file
+
+computing for directory /usr/games
+total size sum = 224 K
+total files = 14
+arithmetic mean file size = 16.00 K
+max file size = 52 K
+average hashes per file= 4.00
+assuming 64byte hashes, that's 256.00 bytes per file
+
+computing for directory /usr/local/sbin
+total size sum = 2856 K
+total files = 30
+arithmetic mean file size = 95.20 K
+max file size = 928 K
+average hashes per file= 23.80
+assuming 64byte hashes, that's 1523.20 bytes per file
+
+computing for directory /usr/local/bin
+total size sum = 94196 K
+total files = 710
+arithmetic mean file size = 132.67 K
+max file size = 4992 K
+average hashes per file= 33.16
+assuming 64byte hashes, that's 2122.24 bytes per file
+
+computing for directory /lib
+total size sum = 7884 K
+total files = 62
+arithmetic mean file size = 127.16 K
+max file size = 1472 K
+average hashes per file= 31.79
+assuming 64byte hashes, that's 2034.56 bytes per file
+
+computing for directory /usr/lib
+total size sum = 56656 K
+total files = 579
+arithmetic mean file size = 97.85 K
+max file size = 3232 K
+average hashes per file= 24.46
+assuming 64byte hashes, that's 1565.44 bytes per file
+
+computing for directory /usr/local/lib
+total size sum = 260688 K
+total files = 1486
+arithmetic mean file size = 175.42 K
+max file size = 12640 K
+average hashes per file= 43.85
+assuming 64byte hashes, that's 2806.40 bytes per file
+
More information about the svn-soc-all
mailing list