Re: BFS cpu scheduler and skip list implementation

From: Andi Kleen
Date: Fri Sep 23 2011 - 21:21:23 EST


Con Kolivas <kernel@xxxxxxxxxxx> writes:

> Many of you may know about Skip lists as an alternative to balanced binary
> search trees. They feature O(log n) insertion, lookup and removal of table
> entries. Anyway I've been looking for some time at the O(n) lookup of BFS
> (which is O(1) insertion and removal) to try and find a solution that didn't
> cost us at the desktop level since O(n) of small numbers of n is very fast.
> The problem is of course at higher numbers of n (or server type loads), where
> it gets linearly slower, and the cache trashing aspect of scanning linked
> lists becomes expensive.

The big problem with skiplists is that it is hard to resize the pointer
arrays: so you either waste a lot of memory/cache or you have a highest
limit after which they start performing poorly.

I investigated them some time ago to replace the non scalable rbtrees
we have currently, but got discouraged by these problems.

> +struct nodeStructure {
> + int level; /* Levels in this structure */
> + keyType key;
> + valueType value;
> + skiplist_node *next[16];
> + skiplist_node *prev[16];
> +};

That's 128 byte / 2 cache lines, not too bad, but it limits
the maximum number of tasks that can be efficiently handled
(my guess to around 64k with maxlevel == 16, but someone may
correct me on that)

-Andi

--
ak@xxxxxxxxxxxxxxx -- Speaking for myself only
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/