Skip to content

Commit 02a34b0

Browse files
authored
Increase default SMB connections to 8 and simplify setup action (#16)
- Change default SPICEIO_SMB_CONNECTIONS from 4 to 8 for better concurrent request throughput. - Remove already-running instance detection from the setup action; always start a fresh instance (port auto-increment handles conflicts). - Expose `pid` output from the setup action so callers can stop spiceio at the end of their workflow with `if: always()`.
1 parent 7009d5f commit 02a34b0

3 files changed

Lines changed: 8 additions & 29 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ outputs:
3535
endpoint:
3636
description: The S3-compatible endpoint URL
3737
value: ${{ steps.start.outputs.endpoint }}
38+
pid:
39+
description: PID of the spiceio process (use to stop it at the end of your workflow)
40+
value: ${{ steps.start.outputs.pid }}
3841

3942
runs:
4043
using: composite
@@ -80,31 +83,6 @@ runs:
8083
run: |
8184
set -euo pipefail
8285
83-
# Check if spiceio is already listening on the requested address
84-
WANT_VERSION=$(spiceio --version | awk '{print $2}')
85-
RUNNING_HEADER=$(curl -s -I "http://${SPICEIO_BIND}/" 2>/dev/null | grep -i '^server:.*spiceio' | tr -d '\r' || true)
86-
if [[ -n "$RUNNING_HEADER" ]]; then
87-
# Extract version from "Server: spiceio/X.Y.Z"; bare "Server: spiceio"
88-
# (no slash) means a pre-versioned build — treat as outdated.
89-
RUNNING_VERSION="${RUNNING_HEADER##*/}"
90-
RUNNING_VERSION="${RUNNING_VERSION// /}"
91-
if [[ "$RUNNING_HEADER" == */* && "$RUNNING_VERSION" == "$WANT_VERSION" ]]; then
92-
echo "spiceio $WANT_VERSION already running at http://${SPICEIO_BIND} — skipping start"
93-
echo "endpoint=http://${SPICEIO_BIND}" >> "$GITHUB_OUTPUT"
94-
exit 0
95-
fi
96-
# Old or mismatched version — kill it so we can replace it
97-
mapfile -t OLD_PIDS < <(lsof -ti "tcp:${SPICEIO_BIND##*:}" -sTCP:LISTEN 2>/dev/null || true)
98-
if (( ${#OLD_PIDS[@]} > 0 )); then
99-
echo "replacing spiceio ${RUNNING_VERSION:-unknown} (PID(s) ${OLD_PIDS[*]}) with $WANT_VERSION"
100-
kill "${OLD_PIDS[@]}" 2>/dev/null || true
101-
for i in $(seq 1 10); do
102-
lsof -ti "tcp:${SPICEIO_BIND##*:}" -sTCP:LISTEN >/dev/null 2>&1 || break
103-
sleep 1
104-
done
105-
fi
106-
fi
107-
10886
# Parse smb://user:pass@server:port/share
10987
# Strips the smb:// prefix, then splits on :, @, /
11088
URL="${SMB_URL#smb://}"
@@ -163,6 +141,7 @@ runs:
163141
if [[ -n "$ENDPOINT" ]] && curl -fsS -o /dev/null "$ENDPOINT/" 2>/dev/null; then
164142
echo "spiceio ready at $ENDPOINT (PID $PID)"
165143
echo "endpoint=$ENDPOINT" >> "$GITHUB_OUTPUT"
144+
echo "pid=$PID" >> "$GITHUB_OUTPUT"
166145
exit 0
167146
fi
168147
sleep 1

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The binary requires these environment variables:
3434
- `SPICEIO_SMB_DOMAIN` — SMB domain (default empty)
3535
- `SPICEIO_BUCKET` — virtual S3 bucket name (defaults to `SPICEIO_SMB_SHARE`)
3636
- `SPICEIO_REGION` — AWS region to advertise (default `us-east-1`)
37-
- `SPICEIO_SMB_CONNECTIONS` — number of SMB TCP connections in the pool (default `4`)
37+
- `SPICEIO_SMB_CONNECTIONS` — number of SMB TCP connections in the pool (default `8`)
3838
- `SPICEIO_SMB_MAX_IO` — max standalone read/write I/O size in bytes (default `65536`; raise for servers that handle larger I/O)
3939
- `SPICEIO_LOG_FILE` — append logs to this file in addition to stderr (optional; non-blocking, never stalls the proxy)
4040

@@ -54,7 +54,7 @@ The codebase has three modules:
5454

5555
- Zero external crypto dependencies — all crypto goes through `crypto::ffi` to CommonCrypto.
5656
- No `async-trait` — the SMB client uses `tokio::sync::Mutex` around the TCP stream with manual `async` methods.
57-
- Connection pool — N TCP connections (default 4) to the same SMB server, round-robin dispatched. Concurrent S3 requests fan out across connections instead of serializing on a single mutex. File handles are pinned to the connection that opened them.
57+
- Connection pool — N TCP connections (default 8) to the same SMB server, round-robin dispatched. Concurrent S3 requests fan out across connections instead of serializing on a single mutex. File handles are pinned to the connection that opened them.
5858
- Pipelined reads — streaming GetObject sends batches of 8 read requests before collecting responses, hiding per-request round-trip latency.
5959
- Configurable I/O cap — standalone read/write ops default to 64 KB (safe for commodity NAS); raisable via `SPICEIO_SMB_MAX_IO` for compliant servers. Compound operations always cap at 64 KB.
6060
- GetObject streams SMB read chunks directly to the HTTP response via `SpiceioBody::channel` — no full-file buffering.

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct Config {
4343
bucket_name: String,
4444
/// AWS region to advertise
4545
region: String,
46-
/// Number of SMB TCP connections in the pool (default 4)
46+
/// Number of SMB TCP connections in the pool (default 8)
4747
smb_connections: usize,
4848
/// Max I/O size for standalone read/write operations (default 1MB)
4949
smb_max_io: u32,
@@ -72,7 +72,7 @@ impl Config {
7272
smb_connections: env::var("SPICEIO_SMB_CONNECTIONS")
7373
.ok()
7474
.and_then(|s| s.parse().ok())
75-
.unwrap_or(4),
75+
.unwrap_or(8),
7676
smb_max_io: env::var("SPICEIO_SMB_MAX_IO")
7777
.ok()
7878
.and_then(|s| s.parse().ok())

0 commit comments

Comments
 (0)