Tuplespace

Tuple spaces is a coordination model for communication in parallel computing environments.

A tuple space is a place where processes can put, read, and take tuples, which are in turn just sequences of values. For example, ("job", 12, 1.23) is a tuple made up of a string, an integer, and a floating-point number; a tuple space can contain zero or more copies of that tuple, or of tuples containing other types of values, simple or complex.

A process puts something in tuple space with put(a, b, c, ...), take something out with take(a, b, c, ...), or copy something leaving the original in tuple space with copy(a, b, c, ...). The arguments to take and copy are either actual values, or variables with specific types; values match themselves, while types match things of that type. For example:

  • put("job", 12, 1.23) puts the tuple (“job”, 12, 1.23) in the tuple space
  • if f is a floating point variable, take("job", 12, ?f) takes that tuple out of tuple space, assigning 1.23 to f
  • but take("job", 15, ?f) blocks, because there is no tuple in tuple space matching the pattern (12 doesn’t match 15)
  • and if i is an integer variable, copy("job", ?i, ?f) assigns 12 to i and 1.23 to f, but leaves the tuple in tuple space.

There are non-blocking versions of take and copy called try_take and try_copy that either match right away and return true, assigning values to variables in their patterns, or fail to match, don’t do any assignment, and return false.

Summary

  • put: Puts a tuple into the tuplespace
  • take: Takes out a tuple that matches a given pattern from the tuplespace (if there’s no match, the operation is blocked)
  • copy: Copies a tuple that matches a given pattern from the tuplespace (if there’s no match, the operation is blocked)
  • try_take: A non-blocking version of in (if there’s no match, an error message is returned)
  • try_copy: A non-blocking version of rd (if there’s no match, an error message is returned)
2 Likes

Fond memories of Linda… I played with it many years ago. Very nice (and safe!) to use. But less efficient than more low-level mechanisms (message passing in particular), at least for typical applications in scientific computing, so it mostly disappeared.

1 Like

Any insights in what ways this is good for malleability?

What use cases does it cover? Database? RPC?
Are there weirder communication patterns that are neither-DB-nor-RPC-like?

I wonder if Dynamicland’s distributed wish/claim semantics is somewhat similar :thinking:

It’s a minimal specification that allows multiple programs written in different languages to talk, in parallel. It feels somewhat relevant here because it’s the stuff of We Still Don’t Know How To Compute talk.

It’s at the core of the copy/paste server that I use daily, it allows me to move data between programs that don’t know about the others, and it’s also, in a way, closer to how cells work I suppose. Some people are familiar with tuplespace through Linda, but I thought I’d put it here as a reminder and also so new people could adapt this system to their own needs if it

2 Likes