Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

From the cost accounting perspective, reduction of the rholang program is one of the following:
1. Evaluating a term.
2. Substituting variables in the term.
3. Spatial match algorithm.
4. Methods called on rholang terms.
5. Interaction with RSpace.

Evaluating a term

TODOWe charge constant cost for evaluating a term like: send, receive, method call, variable. This is a constant cost for which order is the same as basic methods like nth method call, keys etc.

Substitution

Substitution is the process where we substitute bound variables with the environment variables they bind to. This process can either succeed or fail (failing to substitute is an error but we charge nevertheless). The cost of substitution is:
- for success cost proportional to the byte size of the substitute term
- for failure cost proportional to the byte size of the original term

...

so the more (term, pattern) comparisons match requires the more expensive it is. The actual cost of comparing term against pattern is proportional to the byte size of the smaller object. This is based on the java equality method.

Methods



nthtoByteArrayhexToBytestoUtf8BytesuniondiffadddeletecontainsgetgetOrElsesetkeyssizelengthsliceappendinterpolate
ListC

--


n/an/an/an/an/an/an/an/an/an/an/an/aCproportional to value of higher indexproportional to the length of underlying stringn/a
GByteArrayn/an/an/an/an/an/an/an/anan/an/an/an/an/an/aproportional to value of higher indexproportional to the logarithm of length of target byte arrayn/a
TupleC--n/an/an/an/an/an/an/an/an/an/an/an/an/an/an/an/a
Setn/a--n/an/aproportional to the size of collection that is an argument method proportional to the size of collection that is an argument methodCCCn/an/an/an/aproportional to the size of base collection on which this method is called. Complexity of the size method is O(n)n/an/asame as unionn/a
Mapn/a--n/an/aproportional to the size of collection that is an argument method proportional to the size of collection that is an argument methodn/aCCCCCCproportional to the size of base collection on which this method is called. Complexity of the size method is O(n)n/an/asame as unionn/a
any termn/aproportional to the byte size of the underlying rholang termn/an/an/an/an/an/an/an/an/an/an/an/an/an/an/an/a
Stringn/a--proportional to the length of underlying stringproportional to the length of underlying stringn/an/an/an/an/an/an/an/an/an/aCproportional to value of higher indexproportional to the sum of the lengths of both stringsproportional to length_of_string * number_of_entries_in_map
  • C - constant
  • n/a - method not available

...