Skip to content
Merged
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
22 changes: 19 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -307,24 +307,40 @@ opt-level = 3
[profile.dev.package.sonora-simd]
opt-level = 3

# The Go mirror stores native staticlibs in Git, whose per-file limit is 100 MB.
# Keep all release entry points on the same compact native profile.
[profile.release]
panic = "abort"
lto = "fat"
codegen-units = 1
strip = "symbols"

# UniFFI reads ELF's regular symbol table to generate bindings, including in
# maturin and downstream generators. Remove debug data but retain that metadata.
[profile.release.package.moq-ffi]
strip = "debuginfo"

[profile.profiling]
inherits = "release"
debug = "line-tables-only"
strip = "none"
# frame pointers: pass RUSTFLAGS="-C force-frame-pointers=yes" when building

# Package overrides are inherited too and take precedence over the profile.
[profile.profiling.package.moq-ffi]
strip = "none"

[profile.release-with-debug]
inherits = "release"
debug = true
strip = "none"

[profile.release-with-debug.package.moq-ffi]
strip = "none"

# Size-optimized build for the browser/WASM bindings (rs/moq-wasm). Shipping over
# the wire, so optimize for size, not speed (~579KB -> ~471KB gzipped vs the
# default release profile). `just js wasm` builds with `--profile wasm-release`.
[profile.wasm-release]
inherits = "release"
opt-level = "z"
lto = "fat"
codegen-units = 1
strip = true
12 changes: 10 additions & 2 deletions cpp/moq/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ else()
endif()
if(WIN32)
set(MOQ_FFI_LIB "${_cargo_target}/${_profile}/moq_ffi.lib")
set(_metadata "${_cargo_target}/${_profile}/moq_ffi.dll")
elseif(APPLE)
set(MOQ_FFI_LIB "${_cargo_target}/${_profile}/libmoq_ffi.a")
set(_metadata "${_cargo_target}/${_profile}/libmoq_ffi.dylib")
else()
set(MOQ_FFI_LIB "${_cargo_target}/${_profile}/libmoq_ffi.a")
set(_metadata "${_cargo_target}/${_profile}/libmoq_ffi.so")
endif()

find_program(UNIFFI_BINDGEN_CPP uniffi-bindgen-cpp REQUIRED)

# Read metadata from the linked cdylib, like the other binding generators,
# without depending on UniFFI support for every static archive object format.
# Linking still uses the staticlib, so consumers need no runtime shared library.
# Rendered to a scratch directory and copied only when changed, so a no-op cargo build does
# not recompile the bindings.
set(_generated "${CMAKE_CURRENT_BINARY_DIR}/include/moq/ffi")
Expand All @@ -43,12 +51,12 @@ list(TRANSFORM _generated_files PREPEND "${_render}/" OUTPUT_VARIABLE _render_pa
add_custom_target(moq_ffi ALL
COMMAND cargo build --locked --package moq-ffi ${_cargo_flags}
COMMAND ${CMAKE_COMMAND} -E rm -rf "${_render}"
COMMAND "${UNIFFI_BINDGEN_CPP}" --library "${MOQ_FFI_LIB}"
COMMAND "${UNIFFI_BINDGEN_CPP}" --library "${_metadata}"
--config "${CMAKE_CURRENT_SOURCE_DIR}/uniffi.toml" --out-dir "${_render}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${_generated}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_render_paths} "${_generated}"
WORKING_DIRECTORY "${_workspace}"
BYPRODUCTS "${MOQ_FFI_LIB}" ${_generated_paths}
BYPRODUCTS "${MOQ_FFI_LIB}" "${_metadata}" ${_generated_paths}
COMMENT "Building moq-ffi and rendering its C++ bindings"
VERBATIM
)
Expand Down
5 changes: 0 additions & 5 deletions cpp/moq/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Shrink the release staticlib the way rs/moq-c/build.sh does: thin LTO with one codegen
# unit dead-strips the monomorphizations Rust bakes into a staticlib.
export CARGO_PROFILE_RELEASE_LTO="${CARGO_PROFILE_RELEASE_LTO:-thin}"
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS="${CARGO_PROFILE_RELEASE_CODEGEN_UNITS:-1}"

TARGET=""
OUTPUT_DIR="dist"

Expand Down
8 changes: 0 additions & 8 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,6 @@ let
rustPlatform.bindgenHook
];

# libmoq.a carries moq-ffi's whole dep tree, so an unstripped build is
# ~75 MB+. Thin LTO with a single codegen unit dead-strips the unused
# monomorphizations Rust bakes into a staticlib, halving the artifact
# with no source or ABI change, which keeps the release tarball and
# brew download small. Mirrors rs/moq-c/build.sh's Windows cargo path.
CARGO_PROFILE_RELEASE_LTO = "thin";
CARGO_PROFILE_RELEASE_CODEGEN_UNITS = "1";

# moq-c is a staticlib; crane's default install phase only handles
# binaries. Lay out the artifact tree the way release tarballs and
# downstream `find_package(moq-c)` consumers already expect.
Expand Down
1 change: 0 additions & 1 deletion quest/m1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ session outcomes, and embedder refusals inside session outcomes.
- [moqsrc A/V alignment](/quest/m1/gst-src-av-sync.md) - every `moqsrc` pad of a run shares one timestamp reference and segment base
- [TS passthrough export](/quest/m1/ts-passthrough-export.md) - `export ts --passthrough` writes the `m2ts` track back byte-identical (less late drops) on a fixed delay
- [FLV and MKV export delay](/quest/m1/export-delay.md) - FLV and MKV interleave through the shared jitter buffer on a fixed delay, breaking the CLI once
- [Release profile](/quest/m1/release-profile.md) - every release build gets fat LTO, one codegen unit, and stripping from the workspace profile instead of three script exports
- [Size report](/quest/m1/size-report.md) - a nightly job reports every shipped artifact's size, native and JS, and alerts when one grows
- [Bindings size profile](/quest/m1/ffi-size-profile.md) - a benchmark decides whether the moq-ffi builds ship at opt-level "s", which halves the dylib
- [Go mirror delivery](/quest/m1/go-mirror-delivery.md) - the Go binding's staticlibs stop growing git history by ~210 MiB per release
Expand Down
4 changes: 0 additions & 4 deletions quest/m1/ffi-size-profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,3 @@ Guidance:
- If it's adopted, use a named profile (for example `[profile.ffi]`,
inheriting release) that every binding build path selects, so the relay
and self-builders keep opt-level 3.

## Required

- [Release profile](/quest/m1/release-profile.md) - the baseline this compares against
9 changes: 3 additions & 6 deletions quest/m1/go-mirror-delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ limit, and each release adds about 210 MiB of history.
- a module proxy we host
- release assets fetched by a build step
Git LFS is out, because the Go module proxy doesn't serve LFS objects.
- The release profile quest shrinks the staticlibs (121 to 41 MiB on macOS),
which buys headroom but doesn't stop the history growth.
- The workspace release profile (fat LTO, one codegen unit) shrinks the
staticlibs (121 to 41 MiB on macOS), which buys headroom but doesn't stop
the history growth.
- Deliverable: the chosen approach recorded here, and a follow-up quest to
implement it. Split this if the prototype turns out large.

## Related

- [Release profile](/quest/m1/release-profile.md) - shrinks what the mirror carries
1 change: 0 additions & 1 deletion quest/m1/perf/lock-profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@ CPU and heap:

- [kio channel contention](/quest/m1/perf/kio-channel-contention.md) - requires this for its before and after
- [Benchmark reporting](/bench/README.md) - shares the workload lifecycle and artifact conventions
- [Release profile](/quest/m1/release-profile.md) - also changes the profile `[profile.profiling]` inherits; land one, then rebase the other
52 changes: 0 additions & 52 deletions quest/m1/release-profile.md

This file was deleted.

6 changes: 5 additions & 1 deletion quest/m1/size-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ Decided in planning:
separately.
- The work lives in a `sh/` script behind a `just` recipe, and `nightly.yml`
calls the recipe.
- Cover Linux x86_64 and aarch64, and record each artifact's release build
time alongside its size. The unified release profile (fat LTO, one codegen
unit, stripped; #5274) landed without a Linux aarch64 artifact matrix or a
controlled before/after build-cost comparison, so this job's first runs
supply them. Check the Go mirror's staticlibs stay under its 100 MB limit.

Considered and declined (do not re-ask):

Expand All @@ -56,5 +61,4 @@ Considered and declined (do not re-ask):

## Related

- [Release profile](/quest/m1/release-profile.md) - the profile this report measures
- [Benchmark regressions in CI](/quest/m1/bench-ci.md) - the same nightly-trend shape for Criterion
11 changes: 0 additions & 11 deletions rs/moq-c/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
RS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
WORKSPACE_DIR="$(cd "$RS_DIR/.." && pwd)"

# Shrink the release staticlib. libmoq.a carries the same heavy dep tree as
# moq-ffi, so an unstripped build is ~75 MB+. moq-c ships as a release
# tarball (not a git mirror, so no hard 100 MB limit like moq-go), but thin
# LTO with a single codegen unit dead-strips the unused monomorphizations Rust
# bakes into a staticlib, halving the artifact with no source or ABI changes.
# This covers the Windows cargo path below; the nix/crane path (Linux/macOS)
# sets the same vars in nix/overlay.nix. Scoped here so a plain
# `cargo build --release` stays fast; a caller can still override.
export CARGO_PROFILE_RELEASE_LTO="${CARGO_PROFILE_RELEASE_LTO:-thin}"
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS="${CARGO_PROFILE_RELEASE_CODEGEN_UNITS:-1}"

TARGET=""
VERSION=""
OUTPUT_DIR="dist"
Expand Down
13 changes: 0 additions & 13 deletions rs/moq-ffi/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
RS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
WORKSPACE_DIR="$(cd "$RS_DIR/.." && pwd)"

# Shrink the release staticlib. The Go mirror commits the native libs straight
# into git, and GitHub's pre-receive hook hard-rejects any file over 100 MB
# (GH001). An unstripped moq-ffi staticlib is ~110 MB on Linux, which silently
# blocked every moq-go mirror push and pinned consumers to a stale release.
# Thin LTO with a single codegen unit dead-strips the unused monomorphizations
# Rust bakes into a staticlib, cutting it by ~60% (~110 MB to ~35 MB) with no
# source or ABI changes. (Swift ships an XCFramework release asset and Kotlin a
# Maven .so, so neither hits the git limit, but both still get smaller libs.)
# Scoped here via env vars so a plain `cargo build --release` stays fast; a
# caller can still override.
export CARGO_PROFILE_RELEASE_LTO="${CARGO_PROFILE_RELEASE_LTO:-thin}"
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS="${CARGO_PROFILE_RELEASE_CODEGEN_UNITS:-1}"

# Resolve cargo target directory (respects CARGO_TARGET_DIR, .cargo/config, etc.)
TARGET_BASE_DIR=$(cargo metadata --format-version 1 --manifest-path "$WORKSPACE_DIR/Cargo.toml" --no-deps 2>/dev/null |
sed -n 's/.*"target_directory":"\([^"]*\)".*/\1/p' ||
Expand Down
5 changes: 2 additions & 3 deletions sh/go/stage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,8 @@ echo "go stage: assembling ffi module..." >&2
# --skip-size-check because the lib above is a plain host build, unrelated to
# what the mirror publishes. It is a debug build by default now, so it carries
# full line-table debug info and measured 619 MiB against a 100 MiB limit; even
# at MOQ_FFI_PROFILE=release it skips the thin LTO that rs/moq-ffi/build.sh
# applies on the publish path. Enforcing the limit here fails on a lib nobody
# publishes.
# at MOQ_FFI_PROFILE=release this staging path is for local checks, not
# publication. The release packager enforces the limit on shipped artifacts.
bash "$SCRIPT_DIR/package-ffi.sh" \
--version "0.0.0-dev" \
--source-dir "$GO_DIR/ffi" \
Expand Down
Loading