svn commit: r266590 - stable/10/usr.sbin/pmcstat

Ed Maste emaste at FreeBSD.org
Fri May 23 17:46:01 UTC 2014


Author: emaste
Date: Fri May 23 17:46:00 2014
New Revision: 266590
URL: http://svnweb.freebsd.org/changeset/base/266590

Log:
  MFC r266208: Speed up pmcstat by improving string hash
  
    In one case generating callgraph output from a 24MB system-wide sampling
    data file took 17.4 seconds on average.  Profiling showed pmcstat
    spending a lot of time in strcmp, due to hash collisions.
  
    Replacing the XOR-only hash with FNV-1a reduces the run time for my
    test by 40%.

Modified:
  stable/10/usr.sbin/pmcstat/pmcstat_log.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/pmcstat/pmcstat_log.c
==============================================================================
--- stable/10/usr.sbin/pmcstat/pmcstat_log.c	Fri May 23 16:46:50 2014	(r266589)
+++ stable/10/usr.sbin/pmcstat/pmcstat_log.c	Fri May 23 17:46:00 2014	(r266590)
@@ -307,10 +307,10 @@ pmcstat_stats_reset(int reset_global)
 static int
 pmcstat_string_compute_hash(const char *s)
 {
-	int hash;
+	unsigned hash;
 
-	for (hash = 0; *s; s++)
-		hash ^= *s;
+	for (hash = 2166136261; *s; s++)
+		hash = (hash ^ *s) * 16777619;
 
 	return (hash & PMCSTAT_HASH_MASK);
 }


More information about the svn-src-all mailing list