Skip to content

Commit

Permalink
Merge branch 'main' into aumetra/db-restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra authored Jun 9, 2024
2 parents cb79b6e + 54af999 commit 1e03b02
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
10 changes: 10 additions & 0 deletions crates/kitsune-config/src/mrf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ use serde::{Deserialize, Serialize};
use smol_str::SmolStr;
use std::{collections::HashMap, num::NonZeroUsize};

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum AllocationStrategy {
OnDemand,
#[default]
Pooling,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ArtifactCache {
pub path: SmolStr,
Expand Down Expand Up @@ -30,6 +38,8 @@ pub enum KvStorage {
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct Configuration {
#[serde(default)]
pub allocation_strategy: AllocationStrategy,
pub artifact_cache: Option<ArtifactCache>,
pub module_dir: SmolStr,
pub module_config: HashMap<SmolStr, SmolStr>,
Expand Down
9 changes: 7 additions & 2 deletions crates/kitsune-wasm-mrf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use color_eyre::{eyre, Section};
use fred::{clients::RedisPool, interfaces::ClientLike, types::RedisConfig};
use futures_util::{stream::FuturesUnordered, Stream, TryFutureExt, TryStreamExt};
use kitsune_config::mrf::{
Configuration as MrfConfiguration, FsKvStorage, KvStorage, RedisKvStorage,
AllocationStrategy, Configuration as MrfConfiguration, FsKvStorage, KvStorage, RedisKvStorage,
};
use kitsune_derive::kitsune_service;
use kitsune_error::Error;
Expand Down Expand Up @@ -171,9 +171,14 @@ impl MrfService {
}
};

let allocation_strategy = match config.allocation_strategy {
AllocationStrategy::OnDemand => InstanceAllocationStrategy::OnDemand,
AllocationStrategy::Pooling => InstanceAllocationStrategy::pooling(),
};

let mut engine_config = Config::new();
engine_config
.allocation_strategy(InstanceAllocationStrategy::pooling())
.allocation_strategy(allocation_strategy)
.async_support(true)
.wasm_component_model(true);

Expand Down
15 changes: 14 additions & 1 deletion docs/src/configuring/mrf.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ For example, you can use it to:

## Configuration

### `allocation-strategy`

⚠ You usually don't need to touch this setting!

It has two possible values:

- `on-demand`
- `pooling`

By default it is set to `pooling` which will offer the best throughput since Kitsune instantiates short-lived WASM modules, where pooled allocation can improve performance.

If Kitsune crashes on startup complaining about `failed to create stack pool mapping`, you might want to try changing this setting to `on-demand`.

### `module-dir`

This configuration option tells Kitsune where to scan for WASM modules to load and compile.
Expand All @@ -40,7 +53,7 @@ path = "./artifact-cache"
### `storage`

Kitsune provides MRF modules with scoped key-value storages to allow them to persist data across runs for things like counters or spam lists.
Kitsune provides MRF modules with scoped key-value storages to allow them to persist data across runs for things like counters or spam lists.

We provide multiple backends here:

Expand Down
2 changes: 1 addition & 1 deletion docs/src/running/basic-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type = "in-process"

[server]
frontend-dir = "./kitsune-fe/dist"
max-upload-size = 20242880 # 5MB
max-upload-size = "5MiB"
media-proxy-enabled = false
port = 5000
request-timeout-secs = 60
Expand Down

0 comments on commit 1e03b02

Please sign in to comment.