Liking cljdoc? Tell your friends :D

knossos.history

Operations on histories

Operations on histories
raw docstring

completeclj

(complete history)

When a request is initiated, we may not know what the result will be--but find out when it completes. In the history, this might look like

[{:type :invoke :f :read :value nil} ; We don't know what we're going to read. {:type :ok :f :read :value 2}] ; We received 2.

This function fills in missing values for invocations, where those requests complete. It constructs a new history in which we 'already knew' what the results of successful operations would have been.

For failed operations, complete fills in the value for both invocation and completion; depending on whichever has a value available. We also add a :fails? key to invocations which will fail, allowing checkers to skip them.

When a request is initiated, we may not know what the result will be--but
find out when it completes. In the history, this might look like

[{:type :invoke
:f    :read
:value nil}    ; We don't know what we're going to read.
{:type  :ok
:f     :read
:value 2}]     ; We received 2.

This function fills in missing values for invocations, where those requests
complete. It constructs a new history in which we 'already knew' what the
results of successful operations would have been.

For failed operations, complete fills in the value for both invocation
and completion; depending on whichever has a value available. We *also* add a
:fails? key to invocations which will fail, allowing checkers to skip them.
sourceraw docstring

complete-fold-opclj

(complete-fold-op [history index] op)

Folds an operation into a completed history, keeping track of outstanding invocations.

History is our complete history of operations: a transient vector. Index is a transient map of processes to the index of their most recent invocation. Note that we assume processes are singlethreaded; e.g. they do not perform multiple invocations without receiving responses.

Folds an operation into a completed history, keeping track of outstanding
invocations.

History is our complete history of operations: a transient vector. Index is a
transient map of processes to the index of their most recent invocation. Note
that we assume processes are singlethreaded; e.g. they do not perform
multiple invocations without receiving responses.
sourceraw docstring

completionclj

(completion pair-index op)

Returns the completion for an op, using a pair index. If the op is itself a completion, returns the op. If the op is an invocation, looks up its completion in the pair index.

Returns the completion for an op, using a pair index. If the op is itself a
completion, returns the op. If the op is an invocation, looks up its
completion in the pair index.
sourceraw docstring

convert-op-indexclj

(convert-op-index mapping op)

Maps the index of the op to its corresponding value in the given mapping

Maps the index of the op to its corresponding value in the given mapping
sourceraw docstring

convert-op-indicesclj

(convert-op-indices mapping ops)

Maps convert-op-index over a collection of ops

Maps `convert-op-index` over a collection of ops
sourceraw docstring

crashed-invokesclj

(crashed-invokes history)

Which invoke ops in a history have no corresponding :ok or :fail?

Which invoke ops in a history have no corresponding :ok or :fail?
sourceraw docstring

ensure-indexedclj

(ensure-indexed history)

Makes sure a history is indexed when we start our analysis

Makes sure a history is indexed when we start our analysis
sourceraw docstring

indexclj

(index history)

Attaches an :index key to each element of the history, identifying its position in the history vector.

Attaches an :index key to each element of the history, identifying its
position in the history vector.
sourceraw docstring

indexed?clj

(indexed? history)

Is the given history indexed?

Is the given history indexed?
sourceraw docstring

invocationclj

(invocation pair-index op)

Returns the invocation for an op, using a pair index. If the op is itself a completion, returns the op. If the op is an invocation, looks up its completion in the pair index.

Returns the invocation for an op, using a pair index. If the op is itself a
completion, returns the op. If the op is an invocation, looks up its
completion in the pair index.
sourceraw docstring

kindexclj

(kindex history)

Takes a history and returns a new history with internal knossos indices and a map of knossos indices to external indices. Throws IllegalArgumentException if given history does not have unique indices

Takes a history and returns a new history with internal knossos indices and
a map of knossos indices to external indices. Throws IllegalArgumentException
if given history does not have unique indices
sourceraw docstring

pair-indexclj

(pair-index history)
(pair-index pair-fn history)

Given a history, constructs a map from operations to their counterparts--invocations to their completions or completions to their invocations. Infos map to nil.

Given a history, constructs a map from operations to their
counterparts--invocations to their completions or completions to their
invocations. Infos map to nil.
sourceraw docstring

pair-index+clj

(pair-index+ history)

Like pair-index, but matches invokes to infos as well.

Like pair-index, but matches invokes to infos as well.
sourceraw docstring

pairsclj

(pairs history)
(pairs invocations [op & ops])

Pairs up ops from each process in a history. Yields a lazy sequence of [info] or [invoke, ok|fail] pairs.

Pairs up ops from each process in a history. Yields a lazy sequence of [info]
or [invoke, ok|fail] pairs.
sourceraw docstring

pairs+clj

(pairs+ history)
(pairs+ invocations [op & ops])

Pairs up ops from each process in a history. Yields a lazy sequence of [info] or [invoke, ok|fail|info] pairs. The difference from pairs is that this variant maps invocations to infos.

Pairs up ops from each process in a history. Yields a lazy sequence of [info]
or [invoke, ok|fail|info] pairs. The difference from `pairs` is that this
variant maps invocations to infos.
sourceraw docstring

parse-opsclj

(parse-ops history)

We're going to construct Op defrecords throughout our analysis, which means that a map without a value, e.g. {:type :invoke, :f :lock, :process 2} is not equal to the corresponding Op, which will have an explicit :value nil. We convert all maps in the history to Ops before doing anything else.

We're going to construct Op defrecords throughout our analysis, which means
that a map without a value, e.g. {:type :invoke, :f :lock, :process 2} is not
equal to the corresponding Op, which will have an explicit :value nil. We
convert all maps in the history to Ops before doing anything else.
sourceraw docstring

preprocessclj

(preprocess history)

We're going to make several assumptions in Knossos about the structure of histories. This function massages histories to make those assumptions legal.

  1. First, we make sure we have an :index field on ops. This is important so we can uniquely identify operations.

  2. We convert all operation maps to our internal Op representation.

  3. We fill in invocation :values with the results of completions, because we may not know exactly what an operation does at invocation time.

  4. We strip out failed ops; they can't influence state.

  5. We append synthetic :info operations for any incomplete invocations.

  6. We re-index the history so that indices go 0, 1, 2, ..., and compute a map of these knossos :index'es to original :index'es.

We're going to make several assumptions in Knossos about the structure of
histories. This function massages histories to make those assumptions legal.

1. First, we make sure we have an :index field on ops. This is important so we
can uniquely identify operations.

2. We convert all operation maps to our internal Op representation.

3. We fill in invocation :values with the results of completions, because we
may not know exactly what an operation does at invocation time.

5. We strip out failed ops; they can't influence state.

6. We append synthetic :info operations for any incomplete invocations.

7. We re-index the history so that indices go 0, 1, 2, ..., and compute a map
of these knossos :index'es to original :index'es.
sourceraw docstring

processesclj

(processes history)

What processes are in a history?

What processes are in a history?
sourceraw docstring

render-opclj

(render-op indices op)

Prepares an op to be returned by converting it to a plain old map and reassigning its external index

Prepares an op to be returned by converting it to a plain old map and reassigning its
external index
sourceraw docstring

sort-processesclj

(sort-processes coll)

Sort a collection of processes. Puts numbers second, keywords first.

Sort a collection of processes. Puts numbers second, keywords first.
sourceraw docstring

unmatched-invokesclj

(unmatched-invokes history)

Which invoke ops in a history have no corresponding :ok, :fail, or :info?

Which invoke ops in a history have no corresponding :ok, :fail, or :info?
sourceraw docstring

with-synthetic-infosclj

(with-synthetic-infos history)

Histories may arrive with :invoke operations that never complete. We append synthetic :info ops to the end of the history for any in-process calls.

Histories may arrive with :invoke operations that never complete. We append
synthetic :info ops to the end of the history for any in-process calls.
sourceraw docstring

without-failuresclj

(without-failures history)

Takes a completed history, and returns a copy of the given history without any failed operations--either invocations or completions.

Takes a completed history, and returns a copy of the given history without
any failed operations--either invocations or completions.
sourceraw docstring

without-infosclj

(without-infos history)

Takes a completed history, and returns a copy of that history without any :info operations.

Takes a completed history, and returns a copy of that history without any
:info operations.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close