Re: sysctl is too slow

From: Joerg Sonnenberger <joerg_at_bec.de>
Date: Mon, 16 Aug 2021 22:03:45 UTC
On Mon, Aug 16, 2021 at 09:30:51PM +0200, Mateusz Guzik wrote:
> Last time I checked lookup of a sysctl was very bad with linear scans all over.
> 
> Short of complete revamp of the entire thing I would start with
> replacing the scans with a RB tree at each level. As is if you indeed
> have 5000 datasets, you are doing increasingly longer walks.

The RB tree is what NetBSD is doing. The alternative that might be
simpler is to have a flag bit in the node "child nodes are sorted" and
lazily apply a sort whenever the node is scanned first, dropping the
flag when new children are attached or detached. That would allow a
binary search without extra memory cost?

Joerg