FreeBSD src
Go to file
Ed Schouten 2747eff128 Replace implementation of hsearch() by one that scales.
Traditionally the hcreate() function creates a hash table that uses
chaining, using a fixed user-provided size. The problem with this
approach is that this often either wastes memory (table too big) or
yields bad performance (table too small). For applications it may not
always be easy to estimate the right hash table size. A fixed number
only increases performance compared to a linked list by a constant
factor.

This problem can be solved easily by dynamically resizing the hash
table. If the size of the hash table is at least doubled, this has no
negative on the running time complexity. If a dynamically sized hash
table is used, we can also switch to using open addressing instead of
chaining, which has the advantage of just using a single allocation for
the entire table, instead of allocating many small objects.

Finally, a problem with the existing implementation is that its
deterministic algorithm for hashing makes it possible to come up with
fixed patterns to trigger an excessive number of collisions. We can
easily solve this by using FNV-1a as a hashing algorithm in combination
with a randomly generated offset basis.

Measurements have shown that this implementation is about 20-25% faster
than the existing implementation (even if the existing implementation is
given an excessive number of buckets). Though it allocates more memory
through malloc() than the old implementation (between 4-8 pointers per
used entry instead of 3), process memory use is similar to the old
implementation as if the estimated size was underestimated by a factor
10. This is due to the fact that malloc() needs to perform less
bookkeeping.

Reviewed by:	jilles, pfg
Obtained from:	https://github.com/NuxiNL/cloudlibc
Differential Revision:	https://reviews.freebsd.org/D4644
2015-12-27 07:50:11 +00:00
bin sh: Add tests for #/##/%/%% on $* and $@. 2015-12-26 22:27:48 +00:00
cddl Reduce zfs utilities overlinking 2015-12-24 11:56:37 +00:00
contrib Upgrade our copies of clang and llvm to 3.7.1 release. This is a 2015-12-25 21:39:45 +00:00
crypto Incorrect length in calloc() call, already fixed upstream. 2015-12-17 19:36:25 +00:00
etc Let old-style (shell-based) jail configuration handle jail names that 2015-12-26 23:01:34 +00:00
gnu Install ld also as ld.bfd, for use with cc -fuse-ld=bfd 2015-12-23 14:31:26 +00:00
include Replace implementation of hsearch() by one that scales. 2015-12-27 07:50:11 +00:00
kerberos5 DIRDEPS_BUILD: Update dependencies. 2015-12-07 23:53:01 +00:00
lib Replace implementation of hsearch() by one that scales. 2015-12-27 07:50:11 +00:00
libexec rtld: remove old XXX comment missed in r35529 2015-12-24 18:53:17 +00:00
release Fix tmpfs(5) '/tmp' mount point. 2015-11-25 19:10:04 +00:00
rescue Fix the build after ifconfig was converted over to lib80211 in r291470 2015-11-30 16:34:13 +00:00
sbin Reduce overlinking 2015-12-24 11:30:29 +00:00
secure Build engines in parallel. 2015-12-15 19:57:56 +00:00
share procfs(5) is not required by ps(1) and w(1) anymore 2015-12-26 14:23:35 +00:00
sys Fix missing path conversion from the previous commit to shuffle mdio around. 2015-12-27 07:39:44 +00:00
targets local.meta.sys.mk already defines TARGET_ARCHES_arm 2015-12-08 00:22:24 +00:00
tests Delete the comment about running test_libugidfw_strings before testing 2015-12-23 10:02:51 +00:00
tools Upgrade our copies of clang and llvm to 3.7.1 release. This is a 2015-12-25 21:39:45 +00:00
usr.bin Merge bmake-20151220 2015-12-25 16:19:21 +00:00
usr.sbin Fix includes in usr.sbin/fstyp/zfs.c 2015-12-26 19:48:36 +00:00
.arcconfig Add repository.callsign, to help arcanist figure out what repo it's 2015-07-02 22:23:52 +00:00
.arclint phabricator related changes: 2015-04-20 20:33:22 +00:00
COPYRIGHT
LOCKS
MAINTAINERS Refer to creating Phabricator Herald notifications 2015-12-22 17:46:14 +00:00
Makefile Import bmake-20151220 2015-12-25 08:09:48 +00:00
Makefile.inc1 Fixup native-xtools target for poudriere cross build jails after svn 2015-12-23 21:55:54 +00:00
ObsoleteFiles.inc Upgrade our copies of clang and llvm to 3.7.1 release. This is a 2015-12-25 21:39:45 +00:00
README
UPDATING pxeboot: make the tftp loader use the option root-path directive 2015-12-16 17:13:09 +00:00

This is the top level of the FreeBSD source directory.  This file
was last revised on:
$FreeBSD$

For copyright information, please see the file COPYRIGHT in this
directory (additional copyright information also exists for some
sources in this tree - please see the specific source directories for
more information).

The Makefile in this directory supports a number of targets for
building components (or all) of the FreeBSD source tree.  See build(7)
and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
for more information, including setting make(1) variables.

The `buildkernel` and `installkernel` targets build and install
the kernel and the modules (see below).  Please see the top of
the Makefile in this directory for more information on the
standard build targets and compile-time flags.

Building a kernel is a somewhat more involved process.  See build(7), config(8),
and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html
for more information.

Note: If you want to build and install the kernel with the
`buildkernel` and `installkernel` targets, you might need to build
world before.  More information is available in the handbook.

The kernel configuration files reside in the sys/<arch>/conf
sub-directory.  GENERIC is the default configuration used in release builds.
NOTES contains entries and documentation for all possible
devices, not just those commonly used.


Source Roadmap:
---------------

bin		System/user commands.

cddl		Various commands and libraries under the Common Development
		and Distribution License.

contrib		Packages contributed by 3rd parties.

crypto		Cryptography stuff (see crypto/README).

etc		Template files for /etc.

games		Amusements.

gnu		Various commands and libraries under the GNU Public License.
		Please see gnu/COPYING* for more information.

include		System include files.

kerberos5	Kerberos5 (Heimdal) package.

lib		System libraries.

libexec		System daemons.

release		Release building Makefile & associated tools.

rescue		Build system for statically linked /rescue utilities.

sbin		System commands.

secure		Cryptographic libraries and commands.

share		Shared resources.

sys		Kernel sources.

tests		Regression tests which can be run by Kyua.  See tests/README
		for additional information.

tools		Utilities for regression testing and miscellaneous tasks.

usr.bin		User commands.

usr.sbin	System administration commands.


For information on synchronizing your source tree with one or more of
the FreeBSD Project's development branches, please see:

  http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/synching.html