jepsen.generator.translation-table

We burn a lot of time in hashcode and map manipulation for thread names, which are mostly integers 0…n, but sometimes non-integer names like :nemesis. It’s nice to be able to represent thread state internally as purely integers. To do this, we compute a one-time translation table which lets us map those names to integers and vice-versa.

all-names

(all-names translation-table)

A sequence of all names in the translation table, in the exact order of thread indices. Index 0’s name comes first, then 1, and so on.

index->name

(index->name translation-table thread-index)

Turns a thread index (an int) into a thread name (e.g. 0, 5, or :nemesis).

indices->names

(indices->names translation-table indices)

Takes a translation table and a BitSet of thread indices. Constructs a Bifurcan ISet out of those threads.

name->index

(name->index translation-table thread-name)

Turns a thread name (e.g. 0, 5, or :nemesis) into a primitive int.

names->indices

(names->indices translation-table names)

Takes a translation table and a collection of thread names. Constructs a BitSet of those thread indices.

thread-count

(thread-count translation-table)

How many threads in a translation table in all?

translation-table

(translation-table int-thread-count named-threads)

Takes a number of integer threads and a collection of named threads, and computes a translation table.