-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4cec1d6
Showing
51 changed files
with
4,054 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
======================================================================== | ||
Mon Jun 16 00:22:38 2008 | ||
|
||
- Clean up code, remove experimental nameserver stuff as it is not | ||
really needed | ||
|
||
======================================================================== | ||
Thu Mar 13 00:39:57 2008 | ||
|
||
- Cleaned up initialization, so that no set! would be used | ||
- A node will now properly report an error in the primordial thread | ||
if the tcp port is already used | ||
|
||
|
||
======================================================================== | ||
Tue Mar 11 01:01:29 2008 | ||
|
||
- Fixed a problem with MATCH macro | ||
- TAGS are now unique objects and only get an UUID assigned if | ||
"exported" (ie sent to another node) to avoid the creation of symbols | ||
that will not be garbage collected (bug reported by Nicholas Walton) | ||
|
||
|
||
======================================================================== | ||
Wed Feb 13 22:21:59 2008 | ||
|
||
- Removed useless code from match.scm that was impeding compilation | ||
(reported by Guillaume Cartier) | ||
- Termite is now licensed under the same term as Gambit is, as it will | ||
simplify inter-operation with Gambit's code | ||
|
||
======================================================================== | ||
|
||
Wed Feb 6 19:45:59 2008 | ||
Version 0.11 | ||
|
||
- Updated export list | ||
- Minor code cleanup | ||
|
||
======================================================================== | ||
|
||
Thu Nov 15 01:02:19 2007 | ||
Version 0.10 | ||
|
||
- Changed the format of Termite from an "included in Gambit" format to | ||
a Gambit library format | ||
|
||
======================================================================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# These are the installation instructions for Termite | ||
|
||
#1 Install the latest Gambit-C | ||
|
||
#2 Get Termite and untar it in Gambit's lib/ directory | ||
|
||
cd /usr/lobal/Gambit-C/current/lib | ||
|
||
wget http://toute.ca/termite.tar.gz | ||
tar -xzvf termite.tar.gz | ||
|
||
# Optional: | ||
# Manually copy the "tsi" file from Termite's directory to | ||
# Gambit's "bin" directory | ||
# That's for convenience so you can start a console that acts | ||
# like gsi but has Termite already loaded | ||
|
||
# All done! |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
Termite is Copyright 2005-2008 by Guillaume Germain | ||
(guillaume.germain@gmail.com), All Rights Reserved. | ||
|
||
Termite is released under the same license as Gambit itself, | ||
see the LICENSE file. | ||
|
||
* See the 'INSTALL' file for installation instructions. * | ||
|
||
The current code should be considered as beta quality. That is, | ||
some of it isn't yet implemented using a very good style, might | ||
contains some bug, will probably change in the near future, and the | ||
interaction with Gambit might be a little 'rough' for now. | ||
|
||
Don't hesitate to bug me (guillaume.germain@gmail.com) if something | ||
doesn't work as it should, if you have questions or if you have | ||
feature requests. | ||
|
||
-------------------------------------------------------- | ||
|
||
Here is some incomplete documentation about the system. | ||
|
||
|
||
Some Notes | ||
---------- | ||
|
||
See "examples/start1.sh" for a minimal Termite program. | ||
|
||
The global environment should be the same on every node, because it | ||
isn't included in the serialization of ojects. | ||
|
||
One should avoid to make references to unserializable objects in | ||
closures and continuations, else things will fail. | ||
|
||
The programs should not use mutations. Instead, rely on the fact that | ||
passing messages around /is/ a representation of mutable state. See | ||
"examples/cons.scm" for an example. Still, mutable data structures | ||
can be hidden behind processes with some care. Have a look at | ||
'data.scm' for examples. | ||
|
||
To stay in the "spirit" of Termite, one should not use SET!, SET-CAR!, | ||
SET-CDR!, VECTOR-SET!, STRING-SET! and similar functions. Better | ||
integration in the future with Gambit might prevent those forms and | ||
functions from being available. | ||
|
||
|
||
Datatypes: | ||
--------- | ||
|
||
NODE -> node ID | ||
(make-node ip-address tcp-port#) | ||
|
||
TAG -> universally unique identifier | ||
(make-tag) | ||
|
||
|
||
Functions and special forms: | ||
--------------------------- | ||
|
||
(node-init node) | ||
|
||
Necessary to initialize the system. | ||
|
||
(spawn thunk) | ||
|
||
Start a new process executing the 'body' code and return its PID. | ||
|
||
|
||
(spawn-link thunk) | ||
|
||
Start a new process executing the 'body' code and linking that process | ||
to the current one and return its PID. | ||
|
||
|
||
(remote-spawn node thunk) | ||
|
||
Spawn a new thunk on a remote node and return its PID. | ||
|
||
|
||
(self) | ||
|
||
Get the PID of the running process. | ||
|
||
|
||
(current-node) | ||
|
||
Get the current node we're executing on. | ||
|
||
|
||
(! pid message) | ||
Send message to process. | ||
|
||
|
||
(? [timeout [default-value]]) | ||
|
||
Receive a message, block for 'timeout' seconds if no messages. An | ||
exception will be raised if no default-value is specified. | ||
|
||
|
||
(?? pred? [timeout [default-value]]) | ||
Receive a message for which (pred? message) is true. | ||
|
||
|
||
(recv | ||
(pattern . code) | ||
(pattern (where clause) . code) | ||
(after seconds . code)) | ||
|
||
Selectively receive a message that match a pattern, and destructure | ||
it. The last clause can optionally be a 'timeout' clause, with code | ||
to execute if no messages received after a certain amount of time. | ||
|
||
|
||
(!? pid message [timeout [default-value]]) | ||
|
||
Remote procedure call (or synchronous message). This requires | ||
doing something like: | ||
|
||
(recv | ||
... | ||
((from token message) (! from (list token reply))) | ||
...) | ||
|
||
|
||
(shutdown!) | ||
|
||
Nicely terminate the execution of the current process. | ||
|
||
|
||
(terminate! pid) | ||
|
||
Forcefully terminate the execution of a local process. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
The files in this folder are the implementations for the benchmarks | ||
that were used in the Termite paper (http://toute.ca/termite.pdf). | ||
|
||
They were run automatically by a Perl script that I'm too ashamed of | ||
to include here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(define-macro (time* . code) | ||
(let ((t0 (gensym))) | ||
`(let ((,t0 (time->seconds (current-time)))) | ||
(begin ,@code) | ||
(inexact->exact | ||
(round (* 1000 (- (time->seconds (current-time)) ,t0))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(define node1 (make-node "dino11" 3000)) | ||
(define node2 (make-node "dino12" 3001)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(define node1 (make-node "127.0.0.1" 3000)) | ||
(define node2 (make-node "127.0.0.1" 3000)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(define node1 (make-node "127.0.0.1" 3000)) | ||
(define node2 (make-node "127.0.0.1" 3001)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-module(fib). | ||
|
||
-export([run/1, fib/1]). | ||
|
||
|
||
fib(X) when X < 2 -> X; | ||
fib(X) -> | ||
fib(X-1)+fib(X-2). | ||
|
||
run([Arg]) -> | ||
N = list_to_integer(Arg), | ||
{Time, _} = timer:tc(fib,fib,[N]), | ||
io:format("(fib erlang ~w ~w)~n", [N, round(Time / 1000)]), | ||
halt(0). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/local/Gambit-C/bin/gsi -:dar1 | ||
|
||
(include "bench.scm") | ||
|
||
(define (fib n) | ||
(if (< n 2) | ||
n | ||
(+ (fib (- n 1)) | ||
(fib (- n 2))))) | ||
|
||
(define (main n) | ||
(let ((n (string->number n))) | ||
(write `(fib termite ,n ,(time* (fib n)))) | ||
(newline))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(declare (block)) | ||
|
||
(include "bench.scm") | ||
|
||
(define (run n) | ||
(let ((this (self))) | ||
(spawn | ||
(lambda () | ||
(let loop ((n n)) | ||
(if (> n 0) | ||
(begin | ||
(if (even? n) | ||
(migrate-task node2) | ||
(migrate-task node1))) | ||
(begin | ||
(! this 'done) | ||
(shutdown!))) | ||
(loop (- n 1)))))) | ||
(?)) | ||
|
||
(define (main n) | ||
(cond | ||
((equal? (current-node) node1) | ||
;; code for node 1 | ||
(write `(migrate | ||
termite | ||
,n | ||
,(time* (run n)))) | ||
(newline) | ||
(remote-spawn node2 (lambda () (exit))) | ||
(? 1 'done)) | ||
|
||
;; code for node2 | ||
(else (?)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-module(nrev). | ||
|
||
-export([run/1, nrev/1, iota/1]). | ||
|
||
|
||
iota(X) -> | ||
iota (X-1, []). | ||
|
||
iota(0, L) -> | ||
[0|L]; | ||
|
||
iota(X, L) -> | ||
iota(X-1, [X|L]). | ||
|
||
nrev([]) -> | ||
[]; | ||
|
||
nrev([A|B]) -> | ||
nrev(B) ++ [A]. | ||
|
||
|
||
run([Arg]) -> | ||
N = list_to_integer(Arg), | ||
L = iota(N), | ||
{Time, _} = timer:tc(nrev,nrev,[L]), | ||
io:format("(nrev erlang ~w ~w)~n", [N, round(Time / 1000)]), | ||
halt(0). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/local/Gambit-C/bin/gsi -:dar1 | ||
|
||
(include "bench.scm") | ||
|
||
(define (iota n) | ||
(define (i n acc) | ||
(if (= n 0) | ||
acc | ||
(i (- n 1) | ||
(cons n acc)))) | ||
(i n '())) | ||
|
||
(define (nrev lst) | ||
(if (null? lst) | ||
lst | ||
(append (nrev (cdr lst)) | ||
(list (car lst))))) | ||
|
||
(define (main n) | ||
(let* ((n (string->number n)) | ||
(lst (iota n))) | ||
(write `(nrev termite ,n ,(time* (nrev lst)))) | ||
(newline))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
-module(pingpong). | ||
|
||
-export([run/1, bench/3, pingpong_player/1, iota/1]). | ||
|
||
|
||
iota(0) -> []; | ||
iota(N) -> [N] ++ iota(N - 1). | ||
|
||
pingpong_player(N) -> | ||
receive | ||
{From, done} -> | ||
From ! N, | ||
exit(normal); | ||
{From, Ball} -> | ||
From ! {self(), Ball} | ||
end, | ||
pingpong_player(N + 1). | ||
|
||
bench(Duration, Len, Remote) -> | ||
Player1 = spawn(pingpong, pingpong_player, [0]), | ||
Player2 = spawn(Remote, pingpong, pingpong_player, [1]), | ||
Player1 ! {Player2, iota(Len)}, | ||
receive | ||
after Duration -> ok | ||
end, | ||
Player1 ! {self(), done}, | ||
Player2 ! {self(), done}, | ||
receive | ||
X -> | ||
io:format("(pingpong erlang ~w ~w)~n", | ||
[Len, round(X / (Duration / 1000))]) | ||
end. | ||
|
||
run([Len, Node]) -> | ||
Remote = case Node of | ||
"remote" -> | ||
receive X -> X end; | ||
_ -> list_to_atom(Node) | ||
end, | ||
Duration = 5000, | ||
bench(Duration, list_to_integer(Len), Remote), | ||
spawn(Remote, erlang, halt, [0]), | ||
halt(0). |
Oops, something went wrong.