anishathalye/porcupine is one of the open-source repositories TopGit tracks, currently at 1.3k stars, written primarily in Go. A fast linearizability checker written in Go 🔎
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Porcupine is a fast linearizability checker used in both academia and
industry for testing the correctness of distributed systems. It takes a
sequential specification as executable Go code, along with a concurrent
history, and it determines whether the history is linearizable with respect to
the sequential specification. Porcupine also implements a visualizer for
histories and linearization points.
(click for interactive version)
Porcupine implements the algorithm described in Faster linearizability
checking via P-compositionality, an
optimization of the algorithm described in Testing for
Linearizability.
Porcupine is faster and can handle more histories than Knossos's
linearizability checker. Testing on the data in test_data/jepsen/, Porcupine
is generally 1,000x-10,000x faster and has a much smaller memory
footprint. On histories where it can take advantage of P-compositionality,
Porcupine can be millions of times faster.
Usage
Porcupine takes an executable model of a system along with a history, and it
runs a decision procedure to determine if the history is linearizable with
respect to the model. Porcupine supports specifying history in two ways, either
as a list of operations with given call and return times, or as a list of
call/return events in time order. Porcupine can also visualize histories, along
with partial linearizations, which may aid in debugging.
See the documentation for how to write a model and
specify histories. You can also check out some
example implementations of models from the tests.
Once you've written a model and have a history, you can use the
CheckOperations and CheckEvents functions
to determine if your history is linearizable. If you want to visualize a
history, along with partial linearizations, you can use the
Visualize function.
Testing linearizability
Suppose we're testing linearizability for operations on a read/write register
that's initialized to 0. We write a sequential specification for the register
like this:
type registerInput struct {
op bool // false = put, true = get
value int
}
// a sequential specification of a register
registerModel := porcupine.Model{
Init: func() interface{} {
return 0
},
// step function: takes a state, input, and output, and returns whether it
// was a legal operation, along with a new state
Step: func(state, input, output interface{}) (bool, interface{}) {
regInput := input.(registerInput)
if regInput.op == false {
return true, regInput.value // always ok to execute a put
} else {
readCorrectValue := output == state
return readCorrectValue, state // state is unchanged
}
},
// computes a hash for a state (optional field, improves performance)
Hash: func(state interface{}) uint64 {
return uint64(state.(int))
},
}
Suppose we have the following concurrent history from a set of 3 clients. In a
row, the first | is when the operation was invoked, and the second | is
when the operation returned.
See porcupine_test.go for more examples on how to write
models and histories.
Visualizing histories
Porcupine provides functionality to visualize histories, along with the
linearization (or partial linearizations and illegal linearization points, in
the case of a non-linearizable history). The result is an HTML page that draws
an interactive visualization using JavaScript. The output looks like this:
You can see the full interactive version
here.
The visualization is by partition: all partitions are essentially independent,
so with the key-value store example above, operations related to each unique
key are in a separate partition.
Statically, the visualization shows all history elements, along with
linearization points for each partition. If a partition has no full
linearization, the visualization shows the longest partial linearization. It
also shows, for each history element, the longest partial linearization
containing that event, even if it's not the longest overall partial
linearization; these are greyed out by default. It also shows illegal
linearization points, history elements that were checked to see if they could
occur next but which were illegal to linearize at that point according to the
model.
When a history element is hovered over, the visualization highlights the most
relevant partial linearization. When it exists, the longest partial
linearization containing the event is shown. Otherwise, when it exists, the
visualization shows the longest partial linearization that ends with an illegal
LP that is the event being hovered over. Hovering over an event also shows a
tooltip showing extra information, such as the previous and current states of
the state machine, as well as the time the operation was invoked and when it
returned. This information is derived from the currently selected linearization.
Clicking on a history element selects it, which highlights the event with a
bold border. This has the effect of making the selection of a partial
linearization "sticky", so it's possible to move around the history without
de-selecting it. Clicking on another history element will select that one
instead, and clicking on the background will deselect.
All that's needed to visualize histories is the
CheckOperationsVerbose /
CheckEventsVerbose functions, which return extra
information that's used by the visualization, and the Visualize
function, which produces the visualization. For the visualization to be good,
it's useful to fill out the DescribeOperation and DescribeState fields of
the model. See visualization_test.go for an
end-to-end example of how to visualize a history using Porcupine.
You can also add custom annotations to visualizations, as shown in the example
above. This can be helpful for attaching debugging information, for example,
from servers or the test framework. You can do this using the
AddAnnotations method.
Notes
If Porcupine runs really slowly on your model/history, it may be inevitable,
due to state space explosion. See this
issue for a discussion
of this challenge in the context of a particular model and history.
When recording timestamps for operations, especially on ARM and other
weakly-ordered architectures, you may need to use memory barriers or atomic
operations to ensure accurate measurements and avoid spurious linearizability
violations. See this
issue for details.
Users
Porcupine is used in both academia and industry. It can be helpful to look at
existing uses of Porcupine to learn how you can design a robust testing
framework with linearizability checking at its core.
etcd uses Porcupine's linearizability checker and visualizer in its robustness tests [KubeCon 2023eu talk].
Amazon MemoryDB (SIGMOD'24) uses Porcupine to test MemoryDB consistency.
S2 Stream Store uses Porcupine's linearizability checker and visualizer in its linearizability tests.
LEGOStore (VLDB'22) uses Porcupine to test the linearizability of LEGOStore.
Fission uses Porcupine to test the linearizability of its per-function key-value statestore.
UnisonDB uses Porcupine to test the linearizability of its key-value storage engine.
Querator uses Porcupine's linearizability checker and visualizer in its linearizability tests to check FIFO ordering and lease semantics.
BuildBuddy uses Porcupine's linearizability checker and visualizer in its Raft store linearizability tests.
MIT 6.5840 (Distributed Systems) key-value store was the original motivation for the development of Porcupine, which is used to test the linearizability of the course's Raft-based distributed key-value store.
IIT Delhi COL733 (Cloud computing technology fundamentals) object store's testing harness uses Porcupine to test the linearizability of the strongly-consistent variant of CRAQ.
Does your system use Porcupine? Send a PR to add it to this list!
Citation
@misc{athalye2017porcupine,
author = {Anish Athalye},
title = {Porcupine: A fast linearizability checker in {Go}},
year = {2017},
howpublished = {\url{https://github.com/anishathalye/porcupine}}
}
License
Copyright (c) Anish Athalye. Released under the MIT License. See
LICENSE.md for details.
TopGit's last sync did not record any GitHub topics for anishathalye/porcupine. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on anishathalye/porcupine?
The most recent commit recorded on anishathalye/porcupine was 2 months ago, based on the GitHub push timestamp. The repository has 71 forks — one of the better signals of community interest.
How many stars does anishathalye/porcupine have?
anishathalye/porcupine has 1.3k GitHub stars — refresh the page for the live number, or check github.com/anishathalye/porcupine. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is anishathalye/porcupine open source?
Yes — anishathalye/porcupine ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/anishathalye/porcupine.
Where can I see anishathalye/porcupine in action?
The project maintains a homepage at https://anishathalye.com/testing-distributed-systems-for-linearizability/. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about anishathalye/porcupine?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/anishathalye/porcupine is the definitive source.
Read full README in the tab above.
Is porcupine worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of porcupine.