Home

Awesome

Survey of Skip List Implementations

Here is a brief summary of skip list packages available in Go that you may consider using after a quick Google/Github search. If you know of any others, please contact me so I can add them here.

Some things most of the packages have in common:

Here are some brief notes on each implementation:

Benchmarks

Running the benchmarks found in this repo locally is easy:

go get github.com/sean-public/skiplist-survey
go install github.com/sean-public/skiplist-survey
skiplist-survey > output.csv

The results are in CSV format for easy charting and analysis.

Here is a summary of results I recorded on a Macbook Pro 15 with a 2.7 GHz Intel Core i7 and 16GB RAM. It takes over an hour to run all the benchmarks.

best inserts chart

The chart above shows the best-case insert speeds. The vertical axis is nanoseconds per operation and the horizontal is the number of items in the list. These are the "best" inserts because they happen at the front of the list, which shouldn't require any searching. The difference in speed here demonstrates the overhead each package introduces in even the most basic operations.

worst inserts chart

Worst-case inserts. These inserts are at the end of the list, requiring searching all the way to the end and then adding the new node. As you can see, mtchavez does not scale as well as the other implementations, which only show a small variance even after millions of nodes are added.

average search chart

Average search speed. You can see mtchavez again is not searching in O(log n) or even O(n). zhenjl also appears to have a lot of overhead in its search compared to the other implementations.

worst case delete chart

Worst case deletions. In this benchmark, a skip list of a given length is created and then every item is removed, starting from the last one and moving to the front.

zoom worse cases deletions

If we zoom in, we can see the speed differences between the fastest implementations a bit better. The fastest overall is sean, which averages 10-50ns faster in all operations than the next fastest implementation.

Todo