Skip to content

Commit 1e03b02

Browse files
authored
Merge branch 'main' into aumetra/db-restructure
2 parents cb79b6e + 54af999 commit 1e03b02

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

crates/kitsune-config/src/mrf.rs

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ use serde::{Deserialize, Serialize};
22
use smol_str::SmolStr;
33
use std::{collections::HashMap, num::NonZeroUsize};
44

5+
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
6+
#[serde(rename_all = "kebab-case")]
7+
pub enum AllocationStrategy {
8+
OnDemand,
9+
#[default]
10+
Pooling,
11+
}
12+
513
#[derive(Clone, Debug, Deserialize, Serialize)]
614
pub struct ArtifactCache {
715
pub path: SmolStr,
@@ -30,6 +38,8 @@ pub enum KvStorage {
3038
#[derive(Clone, Debug, Deserialize, Serialize)]
3139
#[serde(rename_all = "kebab-case")]
3240
pub struct Configuration {
41+
#[serde(default)]
42+
pub allocation_strategy: AllocationStrategy,
3343
pub artifact_cache: Option<ArtifactCache>,
3444
pub module_dir: SmolStr,
3545
pub module_config: HashMap<SmolStr, SmolStr>,

crates/kitsune-wasm-mrf/src/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use color_eyre::{eyre, Section};
1010
use fred::{clients::RedisPool, interfaces::ClientLike, types::RedisConfig};
1111
use futures_util::{stream::FuturesUnordered, Stream, TryFutureExt, TryStreamExt};
1212
use kitsune_config::mrf::{
13-
Configuration as MrfConfiguration, FsKvStorage, KvStorage, RedisKvStorage,
13+
AllocationStrategy, Configuration as MrfConfiguration, FsKvStorage, KvStorage, RedisKvStorage,
1414
};
1515
use kitsune_derive::kitsune_service;
1616
use kitsune_error::Error;
@@ -171,9 +171,14 @@ impl MrfService {
171171
}
172172
};
173173

174+
let allocation_strategy = match config.allocation_strategy {
175+
AllocationStrategy::OnDemand => InstanceAllocationStrategy::OnDemand,
176+
AllocationStrategy::Pooling => InstanceAllocationStrategy::pooling(),
177+
};
178+
174179
let mut engine_config = Config::new();
175180
engine_config
176-
.allocation_strategy(InstanceAllocationStrategy::pooling())
181+
.allocation_strategy(allocation_strategy)
177182
.async_support(true)
178183
.wasm_component_model(true);
179184

docs/src/configuring/mrf.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ For example, you can use it to:
1414

1515
## Configuration
1616

17+
### `allocation-strategy`
18+
19+
⚠ You usually don't need to touch this setting!
20+
21+
It has two possible values:
22+
23+
- `on-demand`
24+
- `pooling`
25+
26+
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.
27+
28+
If Kitsune crashes on startup complaining about `failed to create stack pool mapping`, you might want to try changing this setting to `on-demand`.
29+
1730
### `module-dir`
1831

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

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

4558
We provide multiple backends here:
4659

docs/src/running/basic-configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type = "in-process"
4040

4141
[server]
4242
frontend-dir = "./kitsune-fe/dist"
43-
max-upload-size = 20242880 # 5MB
43+
max-upload-size = "5MiB"
4444
media-proxy-enabled = false
4545
port = 5000
4646
request-timeout-secs = 60

0 commit comments

Comments
 (0)