Skip to content

chore: replace lazy_static with std LazyLock#5028

Open
onx2 wants to merge 2 commits into
clockworklabs:masterfrom
onx2:chore/use-rust-lazylock
Open

chore: replace lazy_static with std LazyLock#5028
onx2 wants to merge 2 commits into
clockworklabs:masterfrom
onx2:chore/use-rust-lazylock

Conversation

@onx2
Copy link
Copy Markdown
Contributor

@onx2 onx2 commented May 15, 2026

Description of Changes

Replaces direct lazy_static usage with standard library primitives.

Most usages were replaced with std::sync::LazyLock. One simple static list of required JWT claims was replaced with a plain static array, and an unused lazy regex in the benchmark summarizer was removed.

This also removes direct lazy_static dependencies from the workspace crates that no longer use it.

Various other deps still use it but the general ecosystem vibe is to use std instead:

This is primarily dependency hygiene rather than a performance optimization. Since this codebase targets a modern Rust version, direct lazy_static usage can be replaced with standard library primitives, reducing maintenance burden and one direct dependency.

API and ABI breaking changes

None

Expected complexity level and risk

1 - trivial, matching behavior in std

Testing

Ran:

cargo fmt --all --manifest-path SpacetimeDB/Cargo.toml

cargo check --manifest-path SpacetimeDB/Cargo.toml -p spacetimedb-bench --benches

cargo check --manifest-path SpacetimeDB/Cargo.toml -p spacetimedb-standalone

Also verified there are no remaining direct lazy_static usages in Rust source files.

Comment on lines +140 to +141
// Eventually we will want to add more required claims.
const REQUIRED_CLAIMS: [&str; 2] = ["sub", "iss"];
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed like it should have been const, can change to static though if I'm missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant