-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from symbiont-io/runtime-system-prototype
add: prototype runtime system
- Loading branch information
Showing
18 changed files
with
3,428 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,25 @@ | ||
steps: | ||
- imports: | ||
align: none | ||
list_align: with_module_name | ||
pad_module_names: false | ||
long_list_align: new_line_multiline | ||
empty_list_align: inherit | ||
list_padding: 7 # length "import " | ||
separate_lists: false | ||
space_surround: false | ||
- language_pragmas: | ||
style: vertical | ||
align: false | ||
remove_redundant: true | ||
- simple_align: | ||
cases: false | ||
top_level_patterns: false | ||
records: false | ||
- trailing_whitespace: {} | ||
|
||
# You need to put any language extensions that's enabled for the entire project | ||
# here. | ||
language_extensions: [] | ||
|
||
columns: 72 |
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 @@ | ||
# Revision history for stunt-double | ||
|
||
## 0.1.0.0 -- YYYY-mm-dd | ||
|
||
* First version. Released on an unsuspecting world. |
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,3 @@ | ||
Copyright (c) 2021 Symbiont Inc. | ||
|
||
All rights reserved. |
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,107 @@ | ||
### stunt-double | ||
|
||
`stunt-double` is an actor implementation where the real actors can easily and | ||
faithfully be swapped out for fakes, to make testing of distributed systems | ||
easier. | ||
|
||
#### Actors | ||
|
||
* Erlang is perhaps the most commonly associated programming language when one | ||
thinks of implementations of actor systems today | ||
|
||
* Many other programming languages have tried to copy Erlang, e.g. Scala, Cloud | ||
Haskell, etc. | ||
|
||
* The concept is, of course, older: Smalltalk (1972), Hewitt, Carl; Bishop, | ||
Peter; Steiger, Richard (1973). "A Universal Modular Actor Formalism for | ||
Artificial Intelligence". IJCAI. | ||
|
||
* Erlang was influenced by Smalltalk, which many people associated with OOP but | ||
as per Alan Key's | ||
[email](http://lists.squeakfoundation.org/pipermail/squeak-dev/1998-October/017019.html) | ||
the key idea is actually message passing. | ||
|
||
#### Interfaces (a.k.a. "behaviours") | ||
|
||
* Joe Armstrong's PhD thesis "Making reliable distributed systems in the | ||
presence of software errors" written in 2003 when he was 53 years old, he | ||
started working on telecom systems in 1981. Quite different from a typical PhD | ||
thesis written by a 20-something year old person with no or very little | ||
experience from industry... | ||
|
||
* Anyway, the thesis can perhaps best be summarised by "the big idea in Erlang | ||
isn't messaging/actors for concurrency, but using interfaces (a.k.a. | ||
"behaviours") to *abstract away the concurrency*" (these are not Joe's words, | ||
but rather my interpretation) | ||
|
||
* "network normal form" | ||
|
||
* Examples of interfaces: gen_server, gen_supervisor, gen_fsm, gen_event. The | ||
idea is that an application can be written by largely combining several | ||
instances of these. | ||
|
||
* Concurrent application becomes sequential, easier to write (especially for | ||
less experience programmers) according to Joe | ||
|
||
* easier to maintain, if an interface is improved or a bug fixed in it, then all | ||
application written against the interface will benefit | ||
|
||
* easier to test/prove according to Joe | ||
|
||
* In the future work section of the thesis: "How can we program components - the | ||
idea of a set of communicating processes leads naturally to the idea of | ||
writing the components in different languages. How can we do this?" | ||
|
||
#### Deployments | ||
|
||
* Infrastructure is a map from machine id (ip address) to set of Vat ids | ||
|
||
* Deployment is a supervisor tree (each actor and supervisor has a child id) and | ||
a map from child id to machine id and Vat id | ||
|
||
* Deploy git commit hashes or hashes of the AST (Unison-style)? | ||
|
||
* Join two deployments (make assumptions about existing deployments)? | ||
|
||
#### Live debugging | ||
|
||
* Connect to (remote) event loop | ||
* REPL | ||
* Check crashes that happened by checking the supervisors' logs | ||
* Check the source code of each actor | ||
* Check the state of each actor | ||
|
||
* Keep a ring buffer for each actor with the last X messages it received so we | ||
can step back and forth through time and see how the state changed | ||
|
||
* Keep a ring buffer with the latest Y crashes together with a ring buffer with | ||
the last Y messages before that crash | ||
|
||
#### Upgrades | ||
|
||
* Hot-code swapping | ||
|
||
* Automatic rollbacks | ||
|
||
#### Automatic scaling | ||
|
||
* E.g. kubernetes detects high resource usage on some event loop, provisions a new machine, writes to some global register that the new machine is available | ||
|
||
#### Protocols | ||
|
||
* Type system? Dynamic session types! | ||
|
||
|
||
#### Capabilities | ||
|
||
* E programming language | ||
* [Goblins](https://spritelyproject.org/#goblins) | ||
* OpenBSD's [pledge](https://man.openbsd.org/pledge.2) and | ||
[unveil](https://man.openbsd.org/unveil.2) | ||
|
||
#### Deterministic testing | ||
|
||
#### See also | ||
|
||
* Erlang's [supervisors](https://erlang.org/doc/man/supervisor.html); | ||
* https://capnproto.org/ |
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 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
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 @@ | ||
module Main where | ||
|
||
import Control.Concurrent | ||
|
||
main :: IO () | ||
main = print =<< getNumCapabilities |
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,11 @@ | ||
packages: . | ||
|
||
with-compiler: ghc-8.10.4 | ||
|
||
reject-unconstrained-dependencies: all | ||
|
||
package stunt-double | ||
ghc-options: -Wall | ||
|
||
allow-older: * | ||
allow-newer: * |
Oops, something went wrong.