Skip to content

Commit

Permalink
Update the crates README, clean up dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
rdaum committed Dec 6, 2024
1 parent fed66f6 commit 8630764
Show file tree
Hide file tree
Showing 23 changed files with 790 additions and 354 deletions.
384 changes: 109 additions & 275 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 1 addition & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,15 @@ clap_derive = "4.5"

## HTTP/websockets front-end
axum = { version = "0.7", features = ["ws"] }
axum-extra = "0.9"
serde = { version = "1.0", features = ["derive"] }
serde_derive = "1.0"
serde_json = "1.0"
tower-http = { version = "0.5.2", features = ["add-extension", "auth", "compression-full", "trace"] }

## Asynchronous transaction processing & networking, used in web-host and telnet-host.
## the daemon itself uses its own threading
futures = "0.3"
futures-util = { version = "0.3", features = ["sink", "std"] }
tokio = { version = "1.37", features = ["full"] }
tokio-test = "0.4"
tokio-util = { version = "0.7", features = ["full"] }

# Used for RPC daemon/client
Expand All @@ -82,29 +79,21 @@ zmq = "0.10"
## Logging & tracing
tracing = "0.1"
tracing-subscriber = "0.3"
tracing-test = "0.2"

# General usefulness
binary-layout = "4.0"
bincode = "2.0.0-rc.3"
bindgen = "0.70"
bytes = "1.7"
chrono = "0.4"
cmake = "0.1"
criterion = { version = "0.5", features = ["async_tokio"] }
crossbeam-channel = "0.5"
daumtils = { git = "https://github.com/rdaum/daumtils.git", version = "0.2.0" }
decorum = "0.3" # For ordering & comparing our floats
encoding_rs = "0.8.34"
enum-primitive-derive = "0.3"
im = "15.1"
inventory = "0.3"
itertools = "0.13"
lazy_static = "1.5"
num-traits = "0.2"
oneshot = { version = "0.1", default-features = false, features = ["std"] }
owo-colors = "3.5"
rustyline = "14.0"
strum = { version = "0.26", features = ["derive"] }
text-diff = "0.4"
ustr = "1.0"
Expand All @@ -131,7 +120,7 @@ thiserror = "2.0"
paste = "1.0"

# For the DB & values layer.
fjall = { version = "2.3.2", default-features = false, features = ["ssi_tx", "bytes"] }
fjall = { version = "2.4", default-features = false, features = ["ssi_tx", "bytes"] }
libc = "0.2"
text_io = "0.1" # Used for reading text dumps.

Expand Down
9 changes: 6 additions & 3 deletions crates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ Binaries:
network `host`s
- `web-host` - like the above, but hosts an HTTP server which provides a websocket interface to the system.
as well as various web APIs.
- `console-host` - console host which connects as a user to the `daemon` and provides a readline-type interface to the
system.
- `model-checker` - a tool for using the `elle` tool from Jepsen for verifying transactional properties of the\
database
- `moot` - a comprensive test suite for verifying the correctness of the MOO implementation, including a battery of
tests ported from ToastStunt.

Libraries:

- `values` - crate that implements the core MOO discriminated union (`Var`) value type,
plus all associated types and traits.
- `rdb` - implementation of a custom in-memory quasi-relational MVCC database system
- `db` - implementation of the `WorldState` object database overtop of `rdb`
- `compiler` - the MOO language grammar, parser, AST, and codegen, as well as the decompiler & unparser
- `kernel` - the kernel of the MOO driver: virtual machine, task scheduler, implementations of all builtin\
functions
- `rpc-common` - provides types & functions used by both `daemon` and each host binary, for the RPC interface
- `rpc-async-client` - provides an async RPC client for the `daemon`'s RPC interface
- `rpc-sync-client` - provides a synchronous RPC client for the `daemon`'s RPC interface
3 changes: 0 additions & 3 deletions crates/compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ description = "Functions and structures for compilation and decompilation of MOO
[dev-dependencies]
pretty_assertions.workspace = true
test-case.workspace = true
tracing-test.workspace = true
unindent.workspace = true

[dependencies]
Expand All @@ -24,8 +23,6 @@ moor-values = { path = "../values" }
## General usefulness
bincode.workspace = true
bytes.workspace = true
daumtils.workspace = true
itertools.workspace = true
lazy_static.workspace = true
strum.workspace = true

Expand Down
2 changes: 0 additions & 2 deletions crates/daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ rpc-common = { path = "../rpc-common" }
## Command line arguments parsing.
clap.workspace = true
clap_derive.workspace = true
strum.workspace = true

# General.
bincode.workspace = true
bytes.workspace = true
color-eyre.workspace = true
daumtils.workspace = true
eyre.workspace = true
fjall.workspace = true
oneshot.workspace = true
Expand Down
4 changes: 0 additions & 4 deletions crates/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ description = "Interfaces for describing the worldstate of a moor database"

[dev-dependencies]
tempfile.workspace = true
tracing-test.workspace = true

[dependencies]
## Own
Expand All @@ -22,12 +21,9 @@ moor-values = { path = "../values" }
## Error declaration/ handling
bytes.workspace = true
crossbeam-channel.workspace = true
daumtils.workspace = true
fjall.workspace = true
im.workspace = true
lazy_static.workspace = true
oneshot.workspace = true
strum.workspace = true
tempfile.workspace = true
thiserror.workspace = true
tracing.workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub trait Database: Send + WorldStateSource {
fn loader_client(&self) -> Result<Box<dyn LoaderInterface>, WorldStateError>;
}

#[derive(Clone)]
pub struct TxDB {
storage: Arc<WorldStateDB>,
}
Expand Down
4 changes: 1 addition & 3 deletions crates/db/src/tx/global_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ where
},
);

self.source
.put(op.write_ts, domain.clone(), codomain)
.unwrap();
self.source.put(op.write_ts, domain.clone(), codomain).ok();
}
OpType::Delete => {
inner.index.insert(
Expand Down
7 changes: 0 additions & 7 deletions crates/kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@ moor-db = { path = "../db" }

criterion.workspace = true
eyre.workspace = true
inventory.workspace = true
pretty_assertions.workspace = true
tempfile.workspace = true
test-case.workspace = true
test_each_file.workspace = true
text-diff.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
tracing-test.workspace = true
unindent.workspace = true

[[test]]
name = "regression-suite"
Expand All @@ -51,8 +46,6 @@ moor-values = { path = "../values" }
bytes.workspace = true
chrono.workspace = true
crossbeam-channel.workspace = true
daumtils.workspace = true
decorum.workspace = true
encoding_rs.workspace = true
lazy_static.workspace = true
libc.workspace = true
Expand Down
34 changes: 23 additions & 11 deletions crates/kernel/benches/vm_benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use moor_values::util::BitEnum;
use moor_values::Symbol;
use moor_values::{AsByteBuffer, Var, NOTHING, SYSTEM_OBJECT};

fn create_worldstate() -> TxDB {
fn create_db() -> TxDB {
let (ws_source, _) = TxDB::open(None);
let mut tx = ws_source.new_world_state().unwrap();
let _sysobj = tx
Expand Down Expand Up @@ -78,7 +78,7 @@ pub fn prepare_call_verb(
}

fn prepare_vm_execution(
ws_source: &mut dyn WorldStateSource,
ws_source: &dyn WorldStateSource,
program: &str,
max_ticks: usize,
) -> VmHost {
Expand Down Expand Up @@ -156,11 +156,10 @@ fn execute(
}
}

fn do_program(program: &str, max_ticks: usize, iters: u64) -> Duration {
fn do_program(state_source: TxDB, program: &str, max_ticks: usize, iters: u64) -> Duration {
let mut cumulative = Duration::new(0, 0);

let mut state_source = create_worldstate();
let mut vm_host = prepare_vm_execution(&mut state_source, program, max_ticks);
let mut vm_host = prepare_vm_execution(&state_source, program, max_ticks);
let mut tx = state_source.new_world_state().unwrap();
let session = Arc::new(NoopClientSession::new());
let (scs_tx, _scs_rx) = crossbeam_channel::unbounded();
Expand All @@ -184,32 +183,43 @@ fn do_program(program: &str, max_ticks: usize, iters: u64) -> Duration {
}

fn opcode_throughput(c: &mut Criterion) {
let db = create_db();

let mut group = c.benchmark_group("opcode_throughput");
group.sample_size(300);
group.sample_size(50);
group.measurement_time(Duration::from_secs(10));

let num_ticks = 300000;
group.throughput(criterion::Throughput::Elements(num_ticks as u64));
group.bench_function("while_loop", |b| {
b.iter_custom(|iters| do_program("while (1) endwhile", num_ticks, iters));
b.iter_custom(|iters| do_program(db.clone(), "while (1) endwhile", num_ticks, iters));
});
group.bench_function("while_increment_var_loop", |b| {
b.iter_custom(|iters| do_program("i = 0; while(1) i=i+1; endwhile", num_ticks, iters));
b.iter_custom(|iters| {
do_program(
db.clone(),
"i = 0; while(1) i=i+1; endwhile",
num_ticks,
iters,
)
});
});
group.bench_function("for_in_range_loop", |b| {
b.iter_custom(|iters| {
do_program(
db.clone(),
"while(1) for i in [1..1000000] endfor endwhile",
num_ticks,
iters,
)
});
});
// Measure range iteration over a static list

group.bench_function("for_in_static_list_loop", |b| {
b.iter_custom(|iters| {
do_program(
r#"while(1)
do_program(db.clone(),
r#"while(1)
for i in ({1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10})
endfor
endwhile"#,
Expand All @@ -222,6 +232,7 @@ fn opcode_throughput(c: &mut Criterion) {
group.bench_function("list_append_loop", |b| {
b.iter_custom(|iters| {
do_program(
db.clone(),
r#"while(1)
base_list = {};
for i in [0..1000]
Expand All @@ -237,7 +248,8 @@ fn opcode_throughput(c: &mut Criterion) {
group.bench_function("list_set", |b| {
b.iter_custom(|iters| {
do_program(
r#"while(1)
db.clone(),
r#"while(1)
list = {1};
for i in [0..10000]
list[1] = i;
Expand Down
9 changes: 4 additions & 5 deletions crates/kernel/src/builtins/bf_num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// this program. If not, see <https://www.gnu.org/licenses/>.
//

use decorum::R64;
use rand::Rng;

use moor_compiler::offset_for_builtin;
Expand Down Expand Up @@ -45,8 +44,8 @@ fn bf_min(bf_args: &mut BfCallState<'_>) -> Result<BfRet, BfErr> {
match (&bf_args.args[0].variant(), &bf_args.args[1].variant()) {
(Variant::Int(a), Variant::Int(b)) => Ok(Ret(v_int(*a.min(b)))),
(Variant::Float(a), Variant::Float(b)) => {
let m = R64::from(*a).min(R64::from(*b));
Ok(Ret(v_float(m.into())))
let m = a.min(*b);
Ok(Ret(v_float(m)))
}
_ => Err(BfErr::Code(E_TYPE)),
}
Expand All @@ -61,8 +60,8 @@ fn bf_max(bf_args: &mut BfCallState<'_>) -> Result<BfRet, BfErr> {
match (&bf_args.args[0].variant(), &bf_args.args[1].variant()) {
(Variant::Int(a), Variant::Int(b)) => Ok(Ret(v_int(*a.max(b)))),
(Variant::Float(a), Variant::Float(b)) => {
let m = R64::from(*a).max(R64::from(*b));
Ok(Ret(v_float(m.into())))
let m = a.max(*b);
Ok(Ret(v_float(m)))
}
_ => Err(BfErr::Code(E_TYPE)),
}
Expand Down
5 changes: 5 additions & 0 deletions crates/kernel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ pub use crate::tasks::suspension::{SuspendedTask, WakeCondition};
pub use crate::tasks::task::Task;
pub use crate::tasks::ServerOptions;
pub use moor_values::tasks::TaskId;
use std::cell::Cell;
use std::marker::PhantomData;

pub mod builtins;
pub mod config;
pub mod tasks;
pub mod textdump;
pub mod vm;

/// A phantom type for explicitly marking types as !Sync
type PhantomUnsync = PhantomData<Cell<()>>;
2 changes: 1 addition & 1 deletion crates/kernel/src/tasks/vm_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use bincode::enc::Encoder;
use bincode::error::{DecodeError, EncodeError};
use bincode::{BorrowDecode, Decode, Encode};
use bytes::Bytes;
use daumtils::PhantomUnsync;
use tracing::{debug, error, trace, warn};

use moor_compiler::Name;
Expand All @@ -48,6 +47,7 @@ use crate::vm::vm_call::VerbProgram;
use crate::vm::VmExecParams;
use crate::vm::{ExecutionResult, Fork, VerbExecutionRequest};
use crate::vm::{FinallyReason, VMExecState};
use crate::PhantomUnsync;
use moor_values::matching::command_parse::ParsedCommand;

/// Return values from exec_interpreter back to the Task scheduler loop
Expand Down
2 changes: 1 addition & 1 deletion crates/kernel/src/vm/exec_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
use std::time::{Duration, SystemTime};

use bincode::{Decode, Encode};
use daumtils::PhantomUnsync;

use moor_values::Var;
use moor_values::NOTHING;
use moor_values::{Obj, Symbol};

use crate::vm::activation::{Activation, Frame};
use crate::PhantomUnsync;
use moor_values::tasks::TaskId;

// {this, verb-name, programmer, verb-loc, player, line-number}
Expand Down
5 changes: 2 additions & 3 deletions crates/kernel/src/vm/moo_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
// this program. If not, see <https://www.gnu.org/licenses/>.
//

use crate::vm::FinallyReason;
use bincode::de::{BorrowDecoder, Decoder};
use bincode::enc::Encoder;
use bincode::error::{DecodeError, EncodeError};
use bincode::{BorrowDecode, Decode, Encode};
use daumtils::{BitArray, Bitset16};

use crate::vm::FinallyReason;
use moor_compiler::Name;
use moor_compiler::{GlobalName, Label, Op, Program};
use moor_values::util::{BitArray, Bitset16};
use moor_values::Error::E_VARNF;
use moor_values::{v_none, Error, Var};

Expand Down
7 changes: 0 additions & 7 deletions crates/model-checker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,16 @@ clap.workspace = true
clap_derive.workspace = true
color-eyre.workspace = true
eyre.workspace = true
pretty_assertions.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true

# Auth/Auth
ed25519-dalek.workspace = true
pem.workspace = true
rusty_paseto.workspace = true

## ZMQ / RPC
tmq.workspace = true
uuid.workspace = true

## Asynchronous transaction processing & networking
futures.workspace = true
tokio.workspace = true
tokio-util.workspace = true

edn-format.workspace = true
rand.workspace = true
Loading

0 comments on commit 8630764

Please sign in to comment.