espace
Introduction
espace is an Erlang implementation of the Tuple Spaces
(or Linda) paradigm. Details can be found on Wikipedia for
Linda and Tuple Spaces.
Another good source that describes the paradigm well is the following paper:
Carriero, Nicholas & Gelernter, David. (1989). How to Write Parallel Programs: A Guide to the Perplexed. ACM Computing Surveys. 21. 323-357.
Further details can be found on the wiki pages.
Recent changes
The espace_lite branch has now been merged into the master
branch. Going forward all changes will be on the master branch.
The
worker_supsupervisor andtspool_srvgen server have been removed.All the processes that used to be started by the
evalandworkeroperations are now started from within the client API, and are no longer run under a supervisor.The entire application has now been reduced to one supervisor and two gen_servers, plus
etsmgr. However, the use ofetsmgrwill be provided as a startup option in future.microbenchmarks have been added for the various
espaceoperations. The benchmark modules are kept in thebench/directory. They can be produced withrebar3 bench -d bench.
Less resent changes
The
etsmgrapplication is used to ensure the tuple space and pattern data held in ETS tables survive the server restarts.As we have started using the
handle_continuecallback of gen_server, we can only support OTP versions from 21.0 onwards.evalnow behaves like the original Linda specification, i.e. likeout, it takes a tuple and adds it to the tuple space, however, if the tuple contains any expressions, for espace they arefunexpressions, those expressions are replaced with their respective values before adding the tuple to the tuple space. See the module documentation forespace:eval/1,2for details.A new module has been created
espace_util, which contains the current, and future, support functions.
Upcoming changes
- Some work is planned for performance measurement and tracing.
Current Status
- The project has been developed and tested on a Linux system. Using Erlang/OTP 20 and 21, and rebar3.
- Tests are carried out using a set of basic Eunit tests, via
rebar3 eunit. - General documentation can be found on the wiki pages.
- Documentation for the source code can be generated via
rebar3 docs. - There are some example programs in the
Examples/directory.
Build and testing
rebar3 is used throughout for all stages of the build and test. All
the below commands should be run from the top level directory:
- To compile the code:
rebar3 do clean,compile
- To run the tests:
rebar3 eunit
- To run dialyzer:
rebar3 dialyzer
- To generate the documentation:
rebar3 edoc
- To produce the microbenchmarks:
rebar3 bench -d bench
To try out the application
- Change to the top level directory of the project
- ensure that you have the erlang binaries and rebar3 in your shell path
- build the application
$ rebar3 do clean,compile
- Start the application
$ rebar3 shell
> espace:start().
- At the erlang shell prompt, if desired, bring up the Observer
> observer:start().
- Run the tiny test program
> cd("Examples/adder1").
> adder1:start().
- This will kick off two worker processes via
eval. - One will, continuously, wait for an
{add, X, Y}tuple to appear in the pool, and it will then add the two numbers andouttheir sum as{sum, X, Y, X+Y}. - The second worker will, continuously, wait for a
{sum,X,Y,Z}tuple, and it will then print the contents viaio:format/2 - Following the
evalcalls, three{add, X, Y}tuples are added to the pool, which result in the first worker to pick them up and generate the corresponding{sum, X, Y, X+Y}tuples. These are in turn picked up by the second worker, which in turn prints the result to the terminal. - You can use the table viewer in the Observer to see the progress of the two workers.
- try adding new tuples to the pool, e.g.
> espace:out({add, 42, 43}).
- There will always be two patterns in the
tspace_patttable,{add, '$1', '$2'}and{sum, '$1', '$2', '$3'}. You can check that the waiting pattern pids match the child process pids ofworker_supon the Applcation tab.
Enjoy!
Fred