Add medium profile for daily work scenario (#34035)

- The standard `dev` mode is often too slow for daily work on servo
- Increasing the optimization level to 2 improves the performance noticably.
- Build time for opt-level = 1 is slightly higher than 2 on my machine
- Reducing debug info to `line-tables-only` improves link and build times,
  while still keeping relevant info for backtraces.

Also extend .servobuild to allow setting custom cargo profiles instead
of just release and dev.

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
This commit is contained in:
Jonathan Schwender 2024-11-21 12:28:15 +01:00 committed by GitHub
parent 527e2d426d
commit 80529ef358
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 0 deletions

View file

@ -162,6 +162,14 @@ xml5ever = "0.20"
opt-level = 3 opt-level = 3
debug-assertions = true debug-assertions = true
# A profile between `dev` and `release` which aims to offer a compromise between
# fast incremental rebuilds and runtime speed.
[profile.medium]
inherits = "release"
opt-level = 2
incremental = true
debug = "line-tables-only"
[profile.production] [profile.production]
inherits = "release" inherits = "release"
debug-assertions = false debug-assertions = false

View file

@ -678,6 +678,10 @@ class CommandBase(object):
elif self.config["build"]["mode"] == "release": elif self.config["build"]["mode"] == "release":
print("No build type specified, but .servobuild specified `--release`.") print("No build type specified, but .servobuild specified `--release`.")
return BuildType.release() return BuildType.release()
elif self.config["build"]["mode"] != "":
profile = self.config["build"]["mode"]
print(f"No build type specified, but .servobuild specified custom profile `{profile}`.")
return BuildType.custom(profile)
else: else:
print("No build type specified so assuming `--dev`.") print("No build type specified so assuming `--dev`.")
return BuildType.dev() return BuildType.dev()

View file

@ -14,6 +14,8 @@
[build] [build]
# Set "mode = dev" or use `mach build --dev` to build the project with warning. # Set "mode = dev" or use `mach build --dev` to build the project with warning.
# or Set "mode = release" or use `mach build --release` for optimized build. # or Set "mode = release" or use `mach build --release` for optimized build.
# Use `mode = <profile>` or `mach build --profile=<profile>` to build the given
# profile. Check the `Cargo.toml` manifest for a complete list of custom profiles.
# Defaults to prompting before building # Defaults to prompting before building
#mode = "dev" #mode = "dev"