From owner-svn-src-all@FreeBSD.ORG Fri May 23 17:46:00 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DAC8A7E0; Fri, 23 May 2014 17:46:00 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C7ECC2576; Fri, 23 May 2014 17:46:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4NHk0TN062035; Fri, 23 May 2014 17:46:00 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4NHk0iJ062034; Fri, 23 May 2014 17:46:00 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201405231746.s4NHk0iJ062034@svn.freebsd.org> From: Ed Maste Date: Fri, 23 May 2014 17:46:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r266590 - stable/10/usr.sbin/pmcstat X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 May 2014 17:46:01 -0000 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); }