Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ jobs:
run: rivetkit-rust/packages/rivetkit-core/scripts/check-event-driven-drains.sh

- name: Check
run: cargo check --all-targets --all-features
run: cargo check --workspace --exclude rivetkit-wasm
env:
# Deny warnings
RUSTFLAGS: --cfg tokio_unstable -D warnings
RUSTFLAGS: --cfg tokio_unstable -D warnings -A unsafe-op-in-unsafe-fn

# test:
# name: Test
Expand Down
5 changes: 5 additions & 0 deletions docker/build/darwin-arm64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ARG BUILD_MODE=release
ARG BUILD_FRONTEND=false
ARG VITE_APP_API_URL=__SAME__
ARG VITE_FEATURE_FLAGS=
ARG RUST_TOOLCHAIN=1.91.1

ENV BINDGEN_EXTRA_CLANG_ARGS_aarch64_apple_darwin="--sysroot=/root/osxcross/target/SDK/MacOSX11.3.sdk -isystem /root/osxcross/target/SDK/MacOSX11.3.sdk/usr/include" \
CFLAGS_aarch64_apple_darwin="-B/root/osxcross/target/bin" \
Expand All @@ -32,6 +33,10 @@ ENV RUSTC_WRAPPER=sccache \
WORKDIR /build
COPY . .

RUN rustup toolchain install "${RUST_TOOLCHAIN}" --profile minimal && \
rustup default "${RUST_TOOLCHAIN}" && \
rustup target add aarch64-apple-darwin

RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
Expand Down
5 changes: 5 additions & 0 deletions docker/build/darwin-x64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ARG BUILD_MODE=release
ARG BUILD_FRONTEND=false
ARG VITE_APP_API_URL=__SAME__
ARG VITE_FEATURE_FLAGS=
ARG RUST_TOOLCHAIN=1.91.1

ENV BINDGEN_EXTRA_CLANG_ARGS_x86_64_apple_darwin="--sysroot=/root/osxcross/target/SDK/MacOSX11.3.sdk -isystem /root/osxcross/target/SDK/MacOSX11.3.sdk/usr/include" \
CFLAGS_x86_64_apple_darwin="-B/root/osxcross/target/bin" \
Expand All @@ -32,6 +33,10 @@ ENV RUSTC_WRAPPER=sccache \
WORKDIR /build
COPY . .

RUN rustup toolchain install "${RUST_TOOLCHAIN}" --profile minimal && \
rustup default "${RUST_TOOLCHAIN}" && \
rustup target add x86_64-apple-darwin

RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
Expand Down
5 changes: 5 additions & 0 deletions docker/build/linux-arm64-gnu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ARG BUILD_MODE=release
ARG BUILD_FRONTEND=false
ARG VITE_APP_API_URL=__SAME__
ARG VITE_FEATURE_FLAGS=
ARG RUST_TOOLCHAIN=1.91.1

ENV RUSTFLAGS="--cfg tokio_unstable"
ENV RUSTC_WRAPPER=sccache \
Expand All @@ -19,6 +20,10 @@ ENV RUSTC_WRAPPER=sccache \
WORKDIR /build
COPY . .

RUN rustup toolchain install "${RUST_TOOLCHAIN}" --profile minimal && \
rustup default "${RUST_TOOLCHAIN}" && \
rustup target add aarch64-unknown-linux-gnu

RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
Expand Down
5 changes: 5 additions & 0 deletions docker/build/linux-arm64-musl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ARG BUILD_MODE=release
ARG BUILD_FRONTEND=false
ARG VITE_APP_API_URL=__SAME__
ARG VITE_FEATURE_FLAGS=
ARG RUST_TOOLCHAIN=1.91.1

ENV OPENSSL_DIR=/musl-aarch64 \
OPENSSL_INCLUDE_DIR=/musl-aarch64/include \
Expand All @@ -25,6 +26,10 @@ ENV RUSTC_WRAPPER=sccache \
WORKDIR /build
COPY . .

RUN rustup toolchain install "${RUST_TOOLCHAIN}" --profile minimal && \
rustup default "${RUST_TOOLCHAIN}" && \
rustup target add aarch64-unknown-linux-musl

RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
Expand Down
5 changes: 5 additions & 0 deletions docker/build/linux-x64-gnu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ARG BUILD_MODE=release
ARG BUILD_FRONTEND=false
ARG VITE_APP_API_URL=__SAME__
ARG VITE_FEATURE_FLAGS=
ARG RUST_TOOLCHAIN=1.91.1

ENV RUSTFLAGS="--cfg tokio_unstable"

Expand All @@ -27,6 +28,10 @@ ENV RUSTC_WRAPPER=sccache \
WORKDIR /build
COPY . .

RUN rustup toolchain install "${RUST_TOOLCHAIN}" --profile minimal && \
rustup default "${RUST_TOOLCHAIN}" && \
rustup target add x86_64-unknown-linux-gnu

# Build frontend if building engine with frontend enabled.
RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
Expand Down
5 changes: 5 additions & 0 deletions docker/build/linux-x64-musl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ARG BUILD_MODE=release
ARG BUILD_FRONTEND=false
ARG VITE_APP_API_URL=__SAME__
ARG VITE_FEATURE_FLAGS=
ARG RUST_TOOLCHAIN=1.91.1

ENV OPENSSL_DIR=/musl-x86_64 \
OPENSSL_INCLUDE_DIR=/musl-x86_64/include \
Expand All @@ -24,6 +25,10 @@ ENV RUSTC_WRAPPER=sccache \
WORKDIR /build
COPY . .

RUN rustup toolchain install "${RUST_TOOLCHAIN}" --profile minimal && \
rustup default "${RUST_TOOLCHAIN}" && \
rustup target add x86_64-unknown-linux-musl

RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
Expand Down
5 changes: 5 additions & 0 deletions docker/build/windows-x64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ARG BUILD_MODE=release
ARG BUILD_FRONTEND=false
ARG VITE_APP_API_URL=__SAME__
ARG VITE_FEATURE_FLAGS=
ARG RUST_TOOLCHAIN=1.91.1

# Windows-specific build flags:
# - lld linker is ~5x faster than MinGW's default ld for big Rust binaries.
Expand All @@ -32,6 +33,10 @@ ENV RUSTC_WRAPPER=sccache \
WORKDIR /build
COPY . .

RUN rustup toolchain install "${RUST_TOOLCHAIN}" --profile minimal && \
rustup default "${RUST_TOOLCHAIN}" && \
rustup target add x86_64-pc-windows-gnu

RUN if [ "$BUILD_TARGET" = "engine" ] && [ "$BUILD_FRONTEND" = "true" ]; then \
export NODE_OPTIONS="--max-old-space-size=8192" && \
export SKIP_NAPI_BUILD=1 && \
Expand Down
4 changes: 2 additions & 2 deletions docker/builder-base/engine-builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ RUN apt-get update -y && \
openssl \
pkg-config \
wget && \
rustup toolchain install 1.91.0 && \
rustup default 1.91.0 && \
rustup toolchain install 1.91.1 && \
rustup default 1.91.1 && \
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
apt-get install -y --no-install-recommends nodejs && \
corepack enable && \
Expand Down
2 changes: 1 addition & 1 deletion docker/builder-base/linux-gnu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# and the aarch64 cross-compiler.
#
# Build & push: scripts/docker-builder-base/build-push.sh linux-gnu
FROM rust:1.89.0-bullseye
FROM rust:1.91.1-bullseye

# Install base packages. Bullseye ships clang 11; we pull clang 14 from the
# official LLVM apt repo (https://apt.llvm.org) for modern bindgen support
Expand Down
2 changes: 1 addition & 1 deletion docker/builder-base/linux-musl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Pre-bakes Rust, Node.js 22, napi-rs CLI.
#
# Build & push: scripts/docker-builder-base/build-push.sh linux-musl
FROM rust:1.89.0-bookworm
FROM rust:1.91.1-bookworm

RUN apt-get update && apt-get install -y --no-install-recommends \
musl-tools \
Expand Down
2 changes: 1 addition & 1 deletion docker/builder-base/osxcross.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Build & push: scripts/docker-builder-base/build-push.sh osxcross
# syntax=docker/dockerfile:1.10.0
FROM rust:1.89.0-bookworm
FROM rust:1.91.1-bookworm

RUN apt-get update && apt-get install -y \
git-lfs \
Expand Down
2 changes: 1 addition & 1 deletion docker/builder-base/windows-mingw.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Pre-bakes MinGW-w64, Rust target, Node.js 22, napi-rs CLI.
#
# Build & push: scripts/docker-builder-base/build-push.sh windows-mingw
FROM rust:1.89.0-bookworm
FROM rust:1.91.1-bookworm

RUN apt-get update && apt-get install -y --no-install-recommends \
llvm-14-dev \
Expand Down
4 changes: 4 additions & 0 deletions docker/engine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ ARG CARGO_BUILD_MODE=debug
ARG VITE_APP_API_URL=__SAME__
ARG VITE_APP_TURNSTILE_SITE_KEY=
ARG OVERRIDE_GIT_SHA
ARG RUST_TOOLCHAIN=1.91.1

WORKDIR /app

COPY . .

RUN rustup toolchain install "${RUST_TOOLCHAIN}" --profile minimal && \
rustup default "${RUST_TOOLCHAIN}"

# Build frontend. Use --ignore-scripts because the root postinstall runs
# `lefthook install`, which needs a .git directory (excluded by
# .dockerignore). lefthook is a dev-only git hook manager and has no
Expand Down
25 changes: 19 additions & 6 deletions engine/packages/depot-client/src/vfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
pub total_ns: u64,
pub commit_count: u64,
pub page_cache_entries: u64,
pub page_cache_weighted_size: u64,
pub page_cache_capacity_pages: u64,
pub write_buffer_dirty_pages: u64,
pub db_size_pages: u64,
Expand Down Expand Up @@ -835,7 +836,7 @@
}

fn cached_page(&self, config: &VfsConfig, pgno: u32) -> Option<Vec<u8>> {
if !can_read_cached_page(config, pgno) {

Check warning on line 839 in engine/packages/depot-client/src/vfs.rs

View workflow job for this annotation

GitHub Actions / Rustfmt

Diff in /home/runner/work/rivet/rivet/engine/packages/depot-client/src/vfs.rs
return None;
}
self
Expand All @@ -859,7 +860,13 @@
}
}

fn seed_page(&mut self, config: &VfsConfig, kind: PageCacheInsertKind, pgno: u32, page: Vec<u8>) {
fn seed_page(
&mut self,
config: &VfsConfig,
kind: PageCacheInsertKind,
pgno: u32,
page: Vec<u8>,
) {
if pgno == 1 {
self.seed_main_page(config, kind, page);
} else {
Expand Down Expand Up @@ -1028,6 +1035,10 @@
.entry_count()
.saturating_add(state.committed_page_cache.entry_count())
.saturating_add(state.protected_page_cache.len() as u64),
page_cache_weighted_size: state
.page_cache
.weighted_size()
.saturating_add(state.protected_page_cache.len() as u64),
page_cache_capacity_pages: self.config.cache_capacity_pages,
write_buffer_dirty_pages: state.write_buffer.dirty.len() as u64,
db_size_pages: state.db_size_pages as u64,
Expand Down Expand Up @@ -1120,10 +1131,7 @@
.startup_preload_first_page_count
.min(state.db_size_pages);
for pgno in 1..=early_page_count {
if !snapshot
.ranges
.iter()
.any(|range| range.contains(pgno))
if !snapshot.ranges.iter().any(|range| range.contains(pgno))
&& existing_pgnos.insert(pgno)
{
snapshot.pgnos.push(pgno);
Expand Down Expand Up @@ -1741,7 +1749,12 @@
) -> std::result::Result<Option<Vec<u8>>, String> {
fetch_initial_pages(transport, actor_id, 1)
.await
.map(|pages| pages.into_iter().find(|(pgno, _)| *pgno == 1).map(|(_, bytes)| bytes))
.map(|pages| {
pages
.into_iter()
.find(|(pgno, _)| *pgno == 1)
.map(|(_, bytes)| bytes)
})
}

async fn fetch_initial_pages(
Expand Down
5 changes: 4 additions & 1 deletion engine/packages/depot-client/tests/inline/fault/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ impl<'a> InvariantScan<'a> {
}

let Some(current) = resolved else {
self.violate(format!("database pointer for {} is missing", self.database_id));
self.violate(format!(
"database pointer for {} is missing",
self.database_id
));
return Ok(None);
};
if let Some(scanned_current) = scanned_current
Expand Down
46 changes: 38 additions & 8 deletions engine/packages/depot-client/tests/inline/vfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

use crate::optimization_flags::{
DEFAULT_STARTUP_PRELOAD_MAX_BYTES, DEFAULT_VFS_PAGE_CACHE_CAPACITY_PAGES,
DEFAULT_VFS_PROTECTED_CACHE_PAGES, DEFAULT_VFS_STAGING_CACHE_TTL_MS,
SqliteOptimizationFlags, SqliteReadAheadMode, SqliteVfsPageCacheMode,
DEFAULT_VFS_PROTECTED_CACHE_PAGES, DEFAULT_VFS_STAGING_CACHE_TTL_MS, SqliteOptimizationFlags,
SqliteReadAheadMode, SqliteVfsPageCacheMode,
};
use crate::query::{BindParam, ColumnValue};
use crate::vfs::SqliteVfsMetrics;
Expand Down Expand Up @@ -61,7 +61,7 @@
let config = VfsConfig::from_optimization_flags(flags);
assert_eq!(config.page_cache_mode, SqliteVfsPageCacheMode::Startup);
assert_eq!(
config.cache_capacity_pages,

Check warning on line 64 in engine/packages/depot-client/tests/inline/vfs.rs

View workflow job for this annotation

GitHub Actions / Rustfmt

Diff in /home/runner/work/rivet/rivet/engine/packages/depot-client/src/../tests/inline/vfs.rs
DEFAULT_VFS_PAGE_CACHE_CAPACITY_PAGES / 2
);
assert_eq!(
Expand Down Expand Up @@ -178,14 +178,34 @@
};
let mut state = VfsState::new(&config);

state.cache_page(&config, PageCacheInsertKind::Target, 2, vec![2; DEFAULT_PAGE_SIZE]);
state.cache_page(
&config,
PageCacheInsertKind::Target,
2,
vec![2; DEFAULT_PAGE_SIZE],
);
assert!(state.cached_page(&config, 2).is_none());

state.cache_page(&config, PageCacheInsertKind::Prefetch, 3, vec![3; DEFAULT_PAGE_SIZE]);
state.cache_page(&config, PageCacheInsertKind::Startup, 4, vec![4; DEFAULT_PAGE_SIZE]);
state.cache_page(
&config,
PageCacheInsertKind::Prefetch,
3,
vec![3; DEFAULT_PAGE_SIZE],
);
state.cache_page(
&config,
PageCacheInsertKind::Startup,
4,
vec![4; DEFAULT_PAGE_SIZE],
);
assert!(state.cached_page(&config, 3).is_some());
assert!(state.cached_page(&config, 4).is_some());
assert!(state.protected_page_cache.read_sync(&3, |_, _| ()).is_none());
assert!(
state
.protected_page_cache
.read_sync(&3, |_, _| ())
.is_none()
);

state.evict_target_read_pages(&[1, 3, 4]);
assert!(state.cached_page(&config, 1).is_none());
Expand All @@ -202,8 +222,18 @@
};
let mut state = VfsState::new(&config);

state.cache_page(&config, PageCacheInsertKind::Prefetch, 2, vec![2; DEFAULT_PAGE_SIZE]);
state.cache_page(&config, PageCacheInsertKind::Startup, 3, vec![3; DEFAULT_PAGE_SIZE]);
state.cache_page(
&config,
PageCacheInsertKind::Prefetch,
2,
vec![2; DEFAULT_PAGE_SIZE],
);
state.cache_page(
&config,
PageCacheInsertKind::Startup,
3,
vec![3; DEFAULT_PAGE_SIZE],
);
assert!(state.cached_page(&config, 1).is_some());
assert!(state.cached_page(&config, 2).is_none());
assert!(state.cached_page(&config, 3).is_none());
Expand Down
Loading
Loading