Skip to content

Commit fc5b14c

Browse files
CryZemstange
authored andcommitted
Decouple serde from its derive crate
By not activating the `derive` feature on `serde`, the compilation speed can be improved by a lot. This is because `serde` can then compile in parallel to `serde_derive`, allowing it to finish compilation possibly even before `serde_derive`, unblocking all the crates waiting for `serde` to start compiling much sooner. As it turns out the main deciding factor for how long the compile time of a project is, is primarly determined by the depth of dependencies rather than the width. In other words, a crate's compile times aren't affected by how many crates it depends on, but rather by the longest chain of dependencies that it needs to wait on. In many cases `serde` is part of that long chain, as it is part of a long chain if the `derive` feature is active: `proc-macro2` compile build script > `proc-macro2` run build script > `proc-macro2` > `quote` > `syn` > `serde_derive` > `serde` > `serde_json` (or any crate that depends on serde) By decoupling it from `serde_derive`, the chain is shortened and compile times get much better. Check this issue for a deeper elaboration: serde-rs/serde#2584 For `samply` I'm seeing a reduction from 5.43s to 3.70s when compiling `fxprof-processed-profile` in `release` mode.
1 parent c847f95 commit fc5b14c

File tree

10 files changed

+25
-19
lines changed

10 files changed

+25
-19
lines changed

Cargo.lock

Lines changed: 13 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fxprof-processed-profile/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ readme = "README.md"
1212
[dependencies]
1313
bitflags = "2.0"
1414
serde_json = "1.0"
15-
serde = { version = "1.0", features = ["derive"] }
15+
serde = "1.0.188"
16+
serde_derive = "1.0.188"
1617
debugid = "0.8.0"
1718
fxhash = "0.2.1"
1819

fxprof-processed-profile/src/markers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
33
* You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
use serde::Serialize;
5+
use serde_derive::Serialize;
66
use serde_json::Value;
77

88
use super::timestamp::Timestamp;

gecko_profile/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ readme = "README.md"
1111

1212
[dependencies]
1313
serde_json = "1.0"
14-
serde = { version = "1.0", features = ["derive"] }
14+
serde = "1.0.188"
15+
serde_derive = "1.0.188"
1516
debugid = "0.8.0"
1617

1718
[dev-dependencies]

gecko_profile/src/markers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
33
* You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
use serde::Serialize;
5+
use serde_derive::Serialize;
66
use serde_json::{json, Value};
77
use std::time::Instant;
88

samply-api/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ send_futures = ["samply-symbols/send_futures"]
1616
[dependencies]
1717
samply-symbols = { version = "0.20.0", path = "../samply-symbols" }
1818
thiserror = "1.0.26"
19-
serde = { version = "1.0.126", features = ["derive"] }
19+
serde = "1.0.188"
20+
serde_derive = "1.0.188"
2021
serde_json = "1.0.64"
2122
serde_tuple = "0.5.0"
2223
yaxpeax-arch = { version = "0.2.7", default-features = false }

samply-api/src/asm/request_json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use serde::Deserialize;
1+
use serde_derive::Deserialize;
22

33
#[derive(Deserialize, Debug)]
44
#[serde(rename_all = "camelCase")]

samply-api/src/source/request_json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use serde::Deserialize;
1+
use serde_derive::Deserialize;
22

33
#[derive(Deserialize, Debug)]
44
#[serde(rename_all = "camelCase")]

samply-api/src/symbolicate/request_json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use serde::Deserialize;
1+
use serde_derive::Deserialize;
22

33
#[derive(Deserialize, Debug)]
44
#[serde(untagged)]

samply-api/src/symbolicate/response_json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::HashMap;
22

3-
use serde::Serialize;
3+
use serde_derive::Serialize;
44

55
#[derive(Serialize, Debug)]
66
pub struct Response {

0 commit comments

Comments
 (0)