perf: reduce release compilation through domain boundaries #1

Closed
Wuast94 wants to merge 0 commits from perf/release-domain-boundaries into main
Owner

Erledigt am 16.10.2026: Der vollständige Branchstand 511b968a1c880c45bd13e49d9e035bc73b68fcfe ist bereits Vorfahr von main (370c50680525811511c5bb2dd45d21050ee7e80f) und damit in v0.2.0 enthalten. Der Git-Ancestry-Abgleich ist erfolgreich, git cherry enthält keine fehlenden Commits und der verbleibende PR-Diff ist leer. Dieser überholte PR wird deshalb ohne zusätzlichen Merge geschlossen; es ist dafür kein weiterer Build oder Release erforderlich.


Rustfin emitted most API processing and large shared service futures in its root library. This change confines whole operations to their domain owners and composes independently compiled API routers with narrow current-state views. Existing routes, responses, ownership, cancellation and transaction contracts remain intact.

Controlled M4 Max measurements use Rust 1.99, production defaults and unchanged opt3/Fat-LTO/CGU1:

Release compilation Before After
Cold wall time 1046.61 s 669.88 s (-36.0%)
Root library 525.38 s 85.65 s (-83.7%)
Final binary 458.67 s 435.92 s
Unchanged warm build 0.97 s 0.95 s, no compilation

User CPU increased 8.7%; no memory reduction is claimed. Eleven additional internal domain crates preserve all application behavior without external dependency, pin, release-profile or runner-parallelism changes. Real Items, streaming and version-change probes verify invalidation boundaries.

Validation: full gate passed, 449 Rust / 189 Node tests, none ignored, including actual PostgreSQL/schema, formatting, clippy, architecture, deny and machete. The unchanged production Dockerfile built AMD64 successfully; real image acceptance passed FFmpeg/subtitles/VOB/Chromaprint, migrations, readiness, setup/login/session and complete SIGTERM shutdown. A forced Docker no-cache attempt was diagnosed as an invalid warm measurement; corrected executed Cargo warm run took 1.13 s with no compilation.

Completed compiler self-profile and Perfetto analysis explain the remaining global work: instrumented host compilation spends 270.414 s in LLVM optimization, 392.396 s in code generation and only 0.788 s in the external linker. The 109,267 distinct backend symbols show distributed cost rather than one dominant function. Instrumentation overhead, ARM64 versus AMD64, and LLVM23.1.1 versus Wolfi LLVM22.1.8 prevent treating these phase times as production predictions. The first full AMD64 event trace exhausted the 16 GiB VM; the complete native trace succeeded. No production profiling flags were introduced.

Crate graph, measurements, weak-result investigation, cache-method correction and evidence: docs/build-optimization.md. Intel hardware acceptance remains a cluster check; broader CI-to-release cache analysis remains deferred as requested.

**Erledigt am 16.10.2026:** Der vollständige Branchstand `511b968a1c880c45bd13e49d9e035bc73b68fcfe` ist bereits Vorfahr von `main` (`370c50680525811511c5bb2dd45d21050ee7e80f`) und damit in v0.2.0 enthalten. Der Git-Ancestry-Abgleich ist erfolgreich, `git cherry` enthält keine fehlenden Commits und der verbleibende PR-Diff ist leer. Dieser überholte PR wird deshalb ohne zusätzlichen Merge geschlossen; es ist dafür kein weiterer Build oder Release erforderlich. --- Rustfin emitted most API processing and large shared service futures in its root library. This change confines whole operations to their domain owners and composes independently compiled API routers with narrow current-state views. Existing routes, responses, ownership, cancellation and transaction contracts remain intact. Controlled M4 Max measurements use Rust 1.99, production defaults and unchanged opt3/Fat-LTO/CGU1: | Release compilation | Before | After | | --- | ---: | ---: | | Cold wall time | 1046.61 s | **669.88 s (-36.0%)** | | Root library | 525.38 s | **85.65 s (-83.7%)** | | Final binary | 458.67 s | 435.92 s | | Unchanged warm build | 0.97 s | **0.95 s, no compilation** | User CPU increased 8.7%; no memory reduction is claimed. Eleven additional internal domain crates preserve all application behavior without external dependency, pin, release-profile or runner-parallelism changes. Real Items, streaming and version-change probes verify invalidation boundaries. Validation: full gate passed, **449 Rust / 189 Node tests**, none ignored, including actual PostgreSQL/schema, formatting, clippy, architecture, deny and machete. The unchanged production Dockerfile built AMD64 successfully; real image acceptance passed FFmpeg/subtitles/VOB/Chromaprint, migrations, readiness, setup/login/session and complete SIGTERM shutdown. A forced Docker no-cache attempt was diagnosed as an invalid warm measurement; corrected executed Cargo warm run took **1.13 s with no compilation**. Completed compiler self-profile and Perfetto analysis explain the remaining global work: instrumented host compilation spends 270.414 s in LLVM optimization, 392.396 s in code generation and only 0.788 s in the external linker. The 109,267 distinct backend symbols show distributed cost rather than one dominant function. Instrumentation overhead, ARM64 versus AMD64, and LLVM23.1.1 versus Wolfi LLVM22.1.8 prevent treating these phase times as production predictions. The first full AMD64 event trace exhausted the 16 GiB VM; the complete native trace succeeded. No production profiling flags were introduced. Crate graph, measurements, weak-result investigation, cache-method correction and evidence: `docs/build-optimization.md`. Intel hardware acceptance remains a cluster check; broader CI-to-release cache analysis remains deferred as requested.
perf: compose API routes in independently compiled domain crates
Some checks failed
CI / Quality (pull_request) Successful in 37m37s
CI / Build production (pull_request) Has been cancelled
511b968a1c
Wuast94 closed this pull request 2026-10-16 19:46:07 +02:00
Some checks failed
CI / Quality (pull_request) Successful in 37m37s
CI / Build production (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Wuast94/rustfin!1
No description provided.