mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 04:22:38 +01:00
Merge pull request #2166 from aiongg/dev-profile-local
build: dev-build tuning lives in cl; Cargo.toml profiles match main
This commit is contained in:
4 files changed
+24
-47
No files matched your search
-41
@@ -314,44 +314,3 @@ opt-level = 3
|
||||
# 2 MiB stack of a test thread. The apps this reader came from build their crates at this level.
|
||||
[profile.dev.package.craft-affinity]
|
||||
opt-level = 1
|
||||
# Dev and test builds never run LTO: with `lto = false` (cargo's default) rustc runs thin-local LTO across every
|
||||
# optimised crate's 256 codegen units on each rebuild, which multiplied the incremental rebuild of the framework
|
||||
# crates. Off, a one-line edit re-optimises only the changed units.
|
||||
[profile.dev]
|
||||
lto = "off"
|
||||
|
||||
# Dependencies (egui, rendering, text shaping, syn) run optimised in dev and test builds, so
|
||||
# screen tests, design-lint and the debug gallery run at a usable speed. They build once per
|
||||
# target dir; the workspace's own crates stay unoptimised and incremental.
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 2
|
||||
|
||||
# craft-theme's colour maths and the behaviour cores, which run in every screen-test frame, and craft-proof, whose
|
||||
# tests parse and check whole dictionaries, build at opt-level 1: unoptimised, they made the test binaries several
|
||||
# times slower, and they are rarely edited. Every other workspace crate, the framework runtime included, stays at
|
||||
# opt-level 0: an edit to craft-ui-contract (65k lines) rebuilt for 35-90 s at opt-level 1 and rebuilds in seconds at 0,
|
||||
# and the runtime's hot pipeline is generic, so it compiles in the dependants at their opt-level anyway.
|
||||
[profile.dev.package.craft-theme]
|
||||
opt-level = 1
|
||||
[profile.dev.package.craft-behavior]
|
||||
opt-level = 1
|
||||
[profile.dev.package.craft-proof]
|
||||
opt-level = 1
|
||||
|
||||
# The gallery on the Mac: optimised like release, but the workspace's crates build in many small
|
||||
# units, incrementally, so a change to craft-ui rebuilds in minutes. Dependencies keep release
|
||||
# settings and build once in target/gallery. `cargo run --profile gallery -p craft-ui-gallery`.
|
||||
[profile.gallery]
|
||||
inherits = "release"
|
||||
incremental = true
|
||||
codegen-units = 256
|
||||
opt-level = 1
|
||||
|
||||
# The workspace's own crates build at opt-level 1 in the gallery profile: rustc shares generic instantiations across
|
||||
# crates at opt-level 0, 1, s and z only, so at 1 a change in a framework crate no longer makes every dependant
|
||||
# re-generate its own copies of that crate's generics and inlined functions (a one-line edit rebuilt the gallery in
|
||||
# 25 s at opt-level 1 and 69–84 s at 3). `package."*"` matches the dependencies only: they keep release optimisation,
|
||||
# so this changes nothing in their settings.
|
||||
[profile.gallery.package."*"]
|
||||
codegen-units = 16
|
||||
opt-level = 3
|
||||
@@ -107,7 +107,7 @@ The gallery shows every registered story of every crate with a `ui` feature, und
|
||||
|
||||
```
|
||||
git switch craft-framework
|
||||
cargo run --profile gallery -p craft-ui-gallery
|
||||
cargo run --release -p craft-ui-gallery
|
||||
```
|
||||
|
||||
- The `gallery` profile is release optimisation with incremental builds; `cl build gallery` builds the debug gallery instead. Both are described in [development.md](development.md), with the story renderer (`cl render`), which writes one component's stories to PNG files without building the gallery.
|
||||
@@ -179,7 +179,7 @@ Inside `craft-libs`, every local cargo command goes through `tools/cl`, which gi
|
||||
| Check the crate you changed | `cl check <crate>` |
|
||||
| Run its suite and trials | `cl test <crate>`, or `cl test <crate> -- <filter>` |
|
||||
| One component's stories as PNG files | `cl render <crate> <Component>` (`ui` for the library's own components) |
|
||||
| The gallery | `cl build gallery` (debug), or `cargo run --profile gallery -p craft-ui-gallery` |
|
||||
| The gallery | `cl build gallery` (debug), or `cargo run --release -p craft-ui-gallery` |
|
||||
|
||||
Writing a component, its stories and its trials: [authoring.md](authoring.md). Moving an app's UI onto the framework: [porting.md](porting.md).
|
||||
|
||||
|
||||
+3
-2
@@ -89,14 +89,15 @@ A crate without its own workflow (craft-behavior, craft-host, the domain crates
|
||||
|
||||
## Profiles
|
||||
|
||||
`cl` passes the dev settings below to every cargo command as `--config` arguments (`DEV_PROFILE_CONFIG` in `tools/cl`), so Cargo.toml's `[profile]` table stays the one CI's cache key hashes and local builds keep these settings.
|
||||
|
||||
- Dependencies build at `opt-level = 2` in dev and test builds, once per target directory, so screen tests and the debug gallery run at a usable speed.
|
||||
- `lto = "off"` in dev: with cargo's default (`lto = false`) rustc runs thin-local LTO across every optimised crate's codegen units on each rebuild; off, a one-line edit re-optimises only the changed units (widgets' one-line rebuild went from 41 s to 4 s).
|
||||
- craft-theme, craft-behavior and craft-proof build at `opt-level = 1`: their code runs in every screen-test frame (colour maths, behaviour cores) or in dictionary-sized tests, and they are rarely edited. Every other workspace crate, the runtime (craft-ui-contract) included, builds at 0, where rustc shares generic instantiations across crates and an edit rebuilds in seconds (the runtime's 65k lines cost 35–90 s of codegen per edit at opt-level 1).
|
||||
- The `gallery` profile (the native gallery): release optimisation, incremental, 256 codegen units, and the workspace's own crates at `opt-level = 1`, which keeps rustc sharing generics across crates so a framework edit does not re-generate every dependant's copies; dependencies keep `opt-level = 3`.
|
||||
|
||||
## Measuring frame time
|
||||
|
||||
Frame-time numbers come from the gallery profile, the build a developer runs on the target machine: `cl cargo build --profile gallery -p craft-ui-gallery --bin craft-ui-gallery` (the same command as `cargo run --profile gallery -p craft-ui-gallery`, with nothing added). Build it in a worktree kept for measuring only, so its gallery profile stays warm and a rebuild after a change compiles only the crates the change reaches. Build the old gallery with the same settings (for a tree without the gallery profile, release with the gallery profile's values passed as `--config profile.release...` overrides), so a ratio compares the code and not the optimisation. Measure the old and the new gallery at the same time, on two virtual displays, in every round: load on a shared machine moves both by more than one fix does, and the same load cancels in the comparison. What a frame runs (passes per frame, measuring runs, runs per interaction) is asserted by count trials, not counted in the measured build.
|
||||
Frame-time numbers come from the release build of the gallery, the build a developer runs on the target machine: `cargo run --release -p craft-ui-gallery`. Build it in a worktree kept for measuring only, so its release build stays warm and a rebuild after a change compiles only the crates the change reaches. Build the old gallery with the same settings, so a ratio compares the code and not the optimisation. Measure the old and the new gallery at the same time, on two virtual displays, in every round: load on a shared machine moves both by more than one fix does, and the same load cancels in the comparison. What a frame runs (passes per frame, measuring runs, runs per interaction) is asserted by count trials, not counted in the measured build.
|
||||
|
||||
## The job pool
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
the component's stories (--card: its Overview cards) as PNGs through the story-render bin
|
||||
cl features <crate> print the --features value cl adds for <crate>
|
||||
cl doctor check the manifests for drift from the one feature resolution
|
||||
cl cargo <args...> cargo through the job pool, nothing added
|
||||
cl cargo <args...> cargo through the job pool, the dev profile settings added
|
||||
|
||||
In an app workspace (one whose root Cargo.toml has `[workspace.metadata.cl]`) the commands are different; see "App
|
||||
workspaces" below:
|
||||
@@ -95,6 +95,21 @@ APP_FEATURE_FLAGS = ("--features", "-F", "--no-default-features")
|
||||
# Set by main() from the workspace's `[workspace.metadata.cl]` in an app workspace; None in craft-libs.
|
||||
APP = None
|
||||
DRY_RUN = bool(os.environ.get("CL_DRY_RUN"))
|
||||
# The dev-build tuning of craft-libs, passed to every cargo command as `--config`. It lives here and not in Cargo.toml
|
||||
# because CI builds with the `[profile]` table of main (its cache key hashes that table), so CI's artifacts and cache
|
||||
# match main's; these settings speed up local screen tests, the debug gallery and design-lint.
|
||||
# lto off: with cargo's default rustc runs thin-local LTO across every optimised crate's codegen units on each rebuild;
|
||||
# off, a one-line edit re-optimises only the changed units. Dependencies build at opt-level 2, once per target dir.
|
||||
# craft-theme, craft-behavior and craft-proof run in every screen-test frame or in dictionary-sized tests and are rarely
|
||||
# edited, so they build at opt-level 1; every other workspace crate stays at 0, where rustc shares generic
|
||||
# instantiations across crates and an edit to the runtime (craft-ui-contract) rebuilds in seconds.
|
||||
DEV_PROFILE_CONFIG = [
|
||||
'profile.dev.lto="off"',
|
||||
'profile.dev.package."*".opt-level=2',
|
||||
"profile.dev.package.craft-theme.opt-level=1",
|
||||
"profile.dev.package.craft-behavior.opt-level=1",
|
||||
"profile.dev.package.craft-proof.opt-level=1",
|
||||
]
|
||||
# What cl.log records about this command; filled in as it runs.
|
||||
RECORD = {"start": time.time(), "target": None, "build": None, "run": 0.0, "report": ""}
|
||||
# The manifest lines the one feature set rests on: (file, regex that must match, what its absence brings back).
|
||||
@@ -334,7 +349,9 @@ def cargo(top, cargo_args, json_out=False, timings=True):
|
||||
RECORD["target"] = target
|
||||
if timings:
|
||||
cargo_args = cargo_args[:1] + ["--timings"] + cargo_args[1:]
|
||||
cmd = shlex.split(env.get("CL_LAUNCHER", "")) + ["cargo"] + cargo_args
|
||||
# An app workspace keeps its own profile settings.
|
||||
config = [] if APP else [x for c in DEV_PROFILE_CONFIG for x in ("--config", c)]
|
||||
cmd = shlex.split(env.get("CL_LAUNCHER", "")) + ["cargo"] + config + cargo_args
|
||||
print("cl: " + " ".join(cmd) + f" (target {target})", file=sys.stderr)
|
||||
sys.stdout.flush()
|
||||
if DRY_RUN:
|
||||
|
||||
Reference in new issue
Block a user