chore: Merge zed lib with zed binary.

TL;DR:
- shaves off about 0.5 seconds from most of our debug builds.
- It would've slightly regressed release build due to preventing build pipelining, but as a tradeoff I've bumped up codegen-units for zed.

\# What did you come up with this time Piotr
In our zed repository I've noticed that merely *loading dependencies* in each crate takes non-trivial amount of time (~800ms in case of editor).
That is to say, the moment you \`use editor\`, your build time increases by 800ms - this happens just once in crate though, as it looks like compiler has to load .rlibs of all of the referenced dependencies.
This is visible under rustc's self-profile. Repro steps on twitter: https://twitter.com/PiotrOsiewicz/status/1762845413072101567

\# How does this commit alleviate this?
zed lib + zed bin are on critical path of every build and cumulatively take about 3s to build. This commit bundles all of this up into ~2.2s of bin build time instead.

\# Wait, splitting binary targets is good, no?
Splitting up a binary target into lib + bin is generally considered to be a good practice, as you can then reuse the lib part elsewhere if needed.
It also allows the build to kick off the moment metadata for all of the dependencies is available (thus, you don't need to wait for codegen).

However, we do not really use zed as a lib, so the first benefit is not really a thing for us.
The latter *is* indeed something we lose out on in release mode (in dev codegen phase of leaf-ish crates is insignificant, as we use shared generics - thus we don't spend much time codegening).
That's why I've bumped codegen units for zed crate to 16 in release mode to keep build times in tact.
This commit is contained in:
Piotr Osiewicz 2024-03-19 01:11:36 +01:00
parent 79a424f28f
commit 080e25dd45
6 changed files with 9 additions and 9 deletions

View File

@ -389,6 +389,9 @@ debug = "limited"
lto = "thin"
codegen-units = 1
[profile.release.package]
zed = { codegen-units = 16 }
[workspace.lints.clippy]
dbg_macro = "deny"
todo = "deny"

View File

@ -10,11 +10,6 @@ authors = ["Zed Team <hi@zed.dev>"]
[lints]
workspace = true
[lib]
name = "zed"
path = "src/zed.rs"
doctest = false
[[bin]]
name = "Zed"
path = "src/main.rs"

View File

@ -1,6 +1,8 @@
// Allow binary to be called Zed for a nice application menu when running executable directly
#![allow(non_snake_case)]
mod zed;
use anyhow::{anyhow, Context as _, Result};
use backtrace::Backtrace;
use chrono::Utc;

View File

@ -165,20 +165,20 @@ pub fn app_menus() -> Vec<Menu<'static>> {
Menu {
name: "Help",
items: vec![
MenuItem::action("View Telemetry", crate::OpenTelemetryLog),
MenuItem::action("View Dependency Licenses", crate::OpenLicenses),
MenuItem::action("View Telemetry", super::OpenTelemetryLog),
MenuItem::action("View Dependency Licenses", super::OpenLicenses),
MenuItem::action("Show Welcome", workspace::Welcome),
MenuItem::action("Give Feedback...", feedback::GiveFeedback),
MenuItem::separator(),
MenuItem::action(
"Documentation",
crate::OpenBrowser {
super::OpenBrowser {
url: "https://zed.dev/docs".into(),
},
),
MenuItem::action(
"Zed Twitter",
crate::OpenBrowser {
super::OpenBrowser {
url: "https://twitter.com/zeddotdev".into(),
},
),