Skip to content

Reduce BEAM runtime overhead through shared flake profiles - #302

Merged
jgoux merged 1 commit into
mainfrom
fix/beam-runtime-footprint
Sep 7, 2026
Merged

jgoux merged 1 commit into
mainfrom
fix/beam-runtime-footprint

Conversation

@jgoux

@jgoux jgoux commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Reduce local BEAM service overhead through the runtime profiles consumed by the root Nix flake, so portable artifacts and derived images share the defaults. Realtime, Pooler, and Analytics default to standalone distribution while preserving explicit named-distribution and scheduler overrides. Realtime disables its default Postgres cluster discovery; Pooler reduces its metadata database pool from 25 connections to two. Existing single-scheduler, no-busy-wait, and Analytics pool settings remain in place.

This adapts Filipe Cabaço’s changes in #296 to main. Its Dockerfile path fixes are obsolete after the flake migration, and its unconditional distribution export would overwrite callers’ settings. The existing caller-preserving release patch stays in place; the default comes from runtime.env. Analytics also drops the explicit short-name argument from its image entrypoint.

Native smoke probes exercise the packaged release launcher with default and overridden distribution/scheduler settings. Container startup, preparation, and health smokes run with one CPU and a 384 MiB budget for Realtime/Pooler or 768 MiB for Analytics. These are smoke budgets, not hard-coded runtime limits. Cluster deployments must explicitly enable distribution and the service’s discovery configuration; Realtime can use RELEASE_DISTRIBUTION=name with CLUSTER_STRATEGIES=POSTGRES.

Validation: repository checks, shell syntax, ShellCheck, and the release-environment regression fixture pass. All six release validations pass at commit 42a789b: 18 platform jobs covering each service’s floor and latest version across Linux amd64, Linux arm64, and macOS arm64. Linux jobs validate both derived images and raw host artifacts. Runs used validation_only=true, preserving published releases. The release inventory found no unpublished stable backlog for these services. No release floor or version pins change.

Supersedes #296

Service Version Validation
Realtime v2.123.5 Passed
Realtime v2.134.8 Passed
Pooler v2.9.10 Passed
Pooler v2.9.12 Passed
Analytics v1.49.2 Passed
Analytics v1.50.9 Passed

Latest Linux image smoke RSS observations:

Service arm64 amd64 Smoke memory budget
Realtime v2.134.8 176.7 MiB 193.1 MiB 384 MiB
Pooler v2.9.12 164.2 MiB 175.0 MiB 384 MiB
Analytics v1.50.9 506.4 MiB 521.3 MiB 768 MiB

These smoke measurements verify the configured budgets. Incremental memory savings have not been isolated in a benchmark, and the service RSS measurements exclude Postgres backend memory saved by smaller connection pools.

@jgoux
jgoux marked this pull request as ready for review September 7, 2026 09:27
@jgoux
jgoux merged commit 4a4073b into main Sep 7, 2026
38 checks passed
@jgoux
jgoux deleted the fix/beam-runtime-footprint branch September 7, 2026 09:34
pull Bot pushed a commit to oogalieboogalie/cli that referenced this pull request Sep 7, 2026
## Summary

Rewrites `@supabase/stack` around one managed-only runtime shared by
strict native and container execution modes. The package owns durable
configuration and secrets, sticky ports, artifact preparation, lifecycle
arbitration, per-service eager or lazy activation, service migrations,
ingress, retained and live logs, and exact resource cleanup.

A stopped stack has no resident supervisor or runtime resources: status
and retained logs come from durable state, while a later start creates a
fresh owner and performs clean recovery. PostgreSQL 17 is the only eager
service by default; other enabled services activate through stack
ingress, and callers can configure eager activation. Dependency-ready
workloads start concurrently. Docker-compatible engines, including
Podman, share the same container path.

Enabled lazy services prepare their artifacts in the background after
startup by default. `preparation: "on-demand"` retains full lazy
downloading, while explicit `prepare()` remains available in either
mode. Foreground activation prepares its dependency closure concurrently
and shares in-flight downloads with background preparation. All selected
workload downloads can run concurrently. Native archives are streamed to
disk while hashing, verified before extraction, and decompressed without
retaining whole archives in memory. Runtime cleanup cancels unfinished
transfers and retains completed cache entries. Status exposes artifact
preparation separately from service readiness, and explicit preparation
reports progress through `onProgress`.

Edge Functions are served through the stack-owned Edge Runtime for
package consumers. The package runs independently of the CLI and accepts
normalized `StackConfig` values without reading `config.toml`. All CLI
integration, including `supabase functions serve` and lifecycle commands
under `experimental start`, belongs to M5 in separate PRs. Existing CLI
Functions behavior is preserved. The deleted `next` CLI was a disposable
proving ground and is not part of this PR.

Service preparation now lives in the published runtime artifacts:
PostgreSQL owns first boot and bundled migrations, service helpers own
migration and Pooler tenant provisioning, and Node services expose
public launchers shared with their images. The stack supplies instance
settings and sequences those commands. Default images use the configured
slim-services tags or digests, including the artifacts from
[slim-services #299](supabase/slim-services#299)
and the BEAM versions republished after [slim-services
#302](supabase/slim-services#302). Native
downloads are checked against the checksum published with the same
release. BEAM launchers own the shared runtime defaults in native and
container modes; Vector configuration and Edge Functions bootstrap
remain stack-owned.

Unix control sockets bind inside owner-private directories. Container
mount paths preserve CSV special characters, and default state paths use
the user home directory when `HOME` is absent.

Obsolete process-compose integration and superseded runtime helpers are
removed.

Supersedes supabase#6385
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.

2 participants