History log of /freebsd/lib/libc/stdlib/tsearch.3 (Results 1 – 25 of 42)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: release/14.0.0
# b2c76c41 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line nroff pattern

Remove /^\.\\"\s*\$FreeBSD\$$\n/


Revision tags: release/13.2.0, release/12.4.0, release/13.1.0, release/12.3.0, release/13.0.0, release/12.2.0, release/11.4.0, release/12.1.0, release/11.3.0, release/12.0.0, release/11.2.0, release/10.4.0
# 531c2d7a 24-Jul-2017 Enji Cooper <ngie@FreeBSD.org>

MFhead@r320180


# bca9d05f 23-Jul-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Merge ^/head r319973 through 321382.


Revision tags: release/11.1.0
# 03f072d1 14-Jul-2017 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r320971 through r320993.


# a9796f9d 14-Jul-2017 Brad Davis <brd@FreeBSD.org>

Follow up to r320992, properly escape the backslash so it renders properly.

MFC after: 1 week
Forgotten by: brd
X-MFC-With: r320992


# d2919305 14-Jul-2017 Brad Davis <brd@FreeBSD.org>

Add a complete example to tsearch(3)

Reviewed by: wblock, sevan, bruffer
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D11053


# a0e610c4 16-Oct-2016 Dimitry Andric <dim@FreeBSD.org>

Merge ^/head r306906 through r307382.


# 279d8940 15-Oct-2016 Ed Schouten <ed@FreeBSD.org>

Improve phrasing of the STANDARDS section.

Reported by: wblock
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D8205


# 4ef9bd22 13-Oct-2016 Ed Schouten <ed@FreeBSD.org>

Improve typing of POSIX search tree functions.

Back in 2015 when I reimplemented these functions to use an AVL tree, I
was annoyed by the weakness of the typing of these functions. Both tree
nodes a

Improve typing of POSIX search tree functions.

Back in 2015 when I reimplemented these functions to use an AVL tree, I
was annoyed by the weakness of the typing of these functions. Both tree
nodes and keys are represented by 'void *', meaning that things like the
documentation for these functions are an absolute train wreck.

To make things worse, users of these functions need to cast the return
value of tfind()/tsearch() from 'void *' to 'type_of_key **' in order to
access the key. Technically speaking such casts violate aliasing rules.
I've observed actual breakages as a result of this by enabling features
like LTO.

I've filed a bug report at the Austin Group. Looking at the way the bug
got resolved, they made a pretty good step in the right direction. A new
type 'posix_tnode' has been added to correspond to tree nodes. It is
still defined as 'void' for source-level compatibility, but in the very
far future it could be replaced by a proper structure type containing a
key pointer.

MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D8205

show more ...


Revision tags: release/11.0.1, release/11.0.0, release/10.3.0
# b626f5a7 04-Jan-2016 Glen Barber <gjb@FreeBSD.org>

MFH r289384-r293170

Sponsored by: The FreeBSD Foundation


# 4c78ed5a 28-Dec-2015 Bjoern A. Zeeb <bz@FreeBSD.org>

Mfh r292839


# 459d04a5 22-Dec-2015 Ed Schouten <ed@FreeBSD.org>

Let tsearch()/tdelete() use an AVL tree.

The existing implementations of POSIX tsearch() and tdelete() don't
attempt to perform any balancing at all. Testing reveals that inserting
100k nodes into a

Let tsearch()/tdelete() use an AVL tree.

The existing implementations of POSIX tsearch() and tdelete() don't
attempt to perform any balancing at all. Testing reveals that inserting
100k nodes into a tree sequentially takes approximately one minute on my
system.

Though most other BSDs also don't use any balanced tree internally, C
libraries like glibc and musl do provide better implementations. glibc
uses a red-black tree and musl uses an AVL tree.

Red-black trees have the advantage over AVL trees that they only require
O(1) rotations after insertion and deletion, but have the disadvantage
that the tree has a maximum depth of 2*log2(n) instead of 1.44*log2(n).
My take is that it's better to focus on having a lower maximum depth,
for the reason that in the case of tsearch() the invocation of the
comparator likely dominates the running time.

This change replaces the tsearch() and tdelete() functions by versions
that create an AVL tree. Compared to musl's implementation, this version
is different in two different ways:

- We don't keep track of heights; just balances. This is sufficient.
This has the advantage that it reduces the number of nodes that are
being accessed. Storing heights requires us to also access all of the
siblings along the path.

- Don't use any recursion at all. We know that the tree cannot 2^64
elements in size, so the height of the tree can never be larger than
96. Use a 128-bit bitmask to keep track of the path that is computed.
This allows us to iterate over the same path twice, meaning we can
apply rotations from top to bottom.

Inserting 100k nodes into a tree now only takes 0.015 seconds. Insertion
seems to be twice as fast as glibc, whereas deletion has about the same
performance. Unlike glibc, it uses a fixed amount of memory.

I also experimented with both recursive and iterative bottom-up
implementations of the same algorithm. This iterative top-down version
performs similar to the recursive bottom-up version in terms of speed
and code size.

For some reason, the iterative bottom-up algorithm was actually 30%
faster for deletion, but has a quadratic memory complexity to keep track
of all the parent pointers.

Reviewed by: jilles
Obtained from: https://github.com/NuxiNL/cloudlibc
Differential Revision: https://reviews.freebsd.org/D4412

show more ...


Revision tags: release/10.2.0, release/10.1.0, release/9.3.0, release/10.0.0, release/9.2.0, release/8.4.0, release/9.1.0, release/8.3.0_cvs, release/8.3.0, release/9.0.0, release/7.4.0_cvs, release/8.2.0_cvs, release/7.4.0, release/8.2.0, release/8.1.0_cvs, release/8.1.0, release/7.3.0_cvs, release/7.3.0, release/8.0.0_cvs, release/8.0.0, release/7.2.0_cvs, release/7.2.0, release/7.1.0_cvs, release/7.1.0, release/6.4.0_cvs, release/6.4.0, release/7.0.0_cvs, release/7.0.0, release/6.3.0_cvs, release/6.3.0, release/6.2.0_cvs, release/6.2.0
# 1d3a1c8b 23-Jun-2006 Giorgos Keramidas <keramida@FreeBSD.org>

twalk() expects an `action' function not a comparison function.
The text is correct in the "DESCRIPTION" section, so fix "SYNOPSIS"
to use the correct name.

PR: docs/90498
Submitted by: Vasil Dimov

twalk() expects an `action' function not a comparison function.
The text is correct in the "DESCRIPTION" section, so fix "SYNOPSIS"
to use the correct name.

PR: docs/90498
Submitted by: Vasil Dimov
MFC after: 3 days

show more ...


Revision tags: release/5.5.0_cvs, release/5.5.0, release/6.1.0_cvs, release/6.1.0, release/6.0.0_cvs, release/6.0.0, release/5.4.0_cvs, release/5.4.0, release/4.11.0_cvs, release/4.11.0
# 24a0682c 20-Jan-2005 Ruslan Ermilov <ru@FreeBSD.org>

Sort sections.


Revision tags: release/5.3.0_cvs, release/5.3.0
# 1a0a9345 03-Jul-2004 Ruslan Ermilov <ru@FreeBSD.org>

Mechanically kill hard sentence breaks.


Revision tags: release/4.10.0_cvs, release/4.10.0, release/5.2.1_cvs, release/5.2.1, release/5.2.0_cvs, release/5.2.0, release/4.9.0_cvs, release/4.9.0, release/5.1.0_cvs, release/5.1.0, release/4.8.0_cvs, release/4.8.0, release/5.0.0_cvs, release/5.0.0
# 2efeeba5 19-Dec-2002 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police: "The .Fa argument.".


# 1fae73b1 18-Dec-2002 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police: "The .Fn function".


Revision tags: release/4.7.0_cvs
# 553c116d 03-Oct-2002 Mike Barcroft <mike@FreeBSD.org>

Add missing const qualifier in tfind().


# 58d38e25 06-Sep-2002 Tim J. Robbins <tjr@FreeBSD.org>

Style: One space between "restrict" qualifier and "*".


# 840b798c 14-Aug-2002 Robert Drehmel <robert@FreeBSD.org>

- Add the 'restrict' qualifier to match the IEEE Std 1003.1-2001
prototype of the tdelete(3) function.
- Remove duplicated space.
- Use an ANSI-C function definition for tdelete(3).
- Update th

- Add the 'restrict' qualifier to match the IEEE Std 1003.1-2001
prototype of the tdelete(3) function.
- Remove duplicated space.
- Use an ANSI-C function definition for tdelete(3).
- Update the manual page.

show more ...


Revision tags: release/4.6.2_cvs, release/4.6.2, release/4.6.1, release/4.6.0_cvs, release/4.5.0_cvs, release/4.4.0_cvs
# 8aefde06 07-Sep-2001 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>

Move to using .In instead of .Fd #include <> for include mark-up.

Inspired by comment from: dd


# 7ebcc426 15-Jul-2001 Dima Dorfman <dd@FreeBSD.org>

Remove whitespace at EOL.


Revision tags: release/4.3.0_cvs, release/4.3.0
# 75d5d29e 05-Feb-2001 Bruce Evans <bde@FreeBSD.org>

Fixed C error(s) in synopsis. Many were hiding under mdoc errors.


# d0353b83 01-Feb-2001 Ruslan Ermilov <ru@FreeBSD.org>

mdoc(7) police: split punctuation characters + misc fixes.


# 67206206 29-Dec-2000 Ruslan Ermilov <ru@FreeBSD.org>

Fixed typo not fixed in previous revision.


12