Skip to content

Commit

Permalink
Use serde_derive instead of the derive feature
Browse files Browse the repository at this point in the history
I noticed recently that `wit-component` was relatively slow to compile
and it's going to be an introductory requirement for any Rust crates so
I wanted to optimize its build a little bit. This is the first
optimization which is to disable the `derive` feature of the `serde`
crate to enable build build pipelining opportunities.

This is the same as bytecodealliance/wasmtime#6917
  • Loading branch information
alexcrichton committed Oct 6, 2023
1 parent 30cc3ae commit 7f34ce4
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 16 deletions.
13 changes: 8 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ log = "0.4.17"
num_cpus = "1.13"
rand = { version = "0.8.4", features = ["small_rng"] }
rayon = "1.3"
serde = { version = "1.0.166", features = ["derive"] }
serde = "1.0.166"
serde_derive = "1.0.166"
serde_json = { version = "1" }
wasmtime = { version = "12.0.0", default-features = false, features = ['cranelift', 'component-model'] }
url = "2.0.0"
Expand Down Expand Up @@ -77,6 +78,7 @@ wasmprinter = { workspace = true }
# Dependencies of `smith`
arbitrary = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
serde_derive = { workspace = true, optional = true }
serde_json = { workspace = true, optional = true }
wasm-smith = { workspace = true, features = ["_internal_cli"], optional = true }

Expand Down Expand Up @@ -156,7 +158,7 @@ default = [
validate = ['dep:wasmparser', 'rayon']
print = []
parse = []
smith = ['wasm-smith', 'arbitrary', 'serde', 'serde_json']
smith = ['wasm-smith', 'arbitrary', 'serde', 'serde_derive', 'serde_json']
shrink = ['wasm-shrink', 'is_executable']
mutate = ['wasm-mutate']
dump = ['dep:wasmparser']
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-compose/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ wasmparser = { workspace = true }
indexmap = { workspace = true, features = ["serde"] }
anyhow = { workspace = true }
serde = { workspace = true }
serde_derive = { workspace = true }
petgraph = "0.6.2"
log = { workspace = true }
serde_yaml = "0.9.22"
Expand Down
2 changes: 1 addition & 1 deletion crates/wasm-compose/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use anyhow::{Context, Result};
use indexmap::IndexMap;
use serde::Deserialize;
use serde_derive::Deserialize;
use std::{
fs,
path::{Path, PathBuf},
Expand Down
1 change: 1 addition & 0 deletions crates/wasm-metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ wasmparser = { workspace = true }
wasm-encoder = { workspace = true }
indexmap = { workspace = true, features = ["serde"] }
serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = { version = "1" }
spdx = "0.10.1"

Expand Down
2 changes: 1 addition & 1 deletion crates/wasm-metadata/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;
use indexmap::{map::Entry, IndexMap};
use serde::{Deserialize, Serialize};
use serde_derive::{Deserialize, Serialize};
use spdx::Expression;
use std::borrow::Cow;
use std::fmt;
Expand Down
3 changes: 2 additions & 1 deletion crates/wasm-smith/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ flagset = "0.4"
indexmap = { workspace = true }
leb128 = { workspace = true }
serde = { workspace = true, optional = true }
serde_derive = { workspace = true, optional = true }
wasm-encoder = { workspace = true }
wasmparser = { workspace = true }

Expand All @@ -34,4 +35,4 @@ wat = { path = "../wat" }
libfuzzer-sys = { workspace = true }

[features]
_internal_cli = ["serde", "flagset/serde"]
_internal_cli = ["serde", "serde_derive"]
2 changes: 1 addition & 1 deletion crates/wasm-smith/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ flags! {
/// Enumerate the categories of instructions defined in the [WebAssembly
/// specification](https://webassembly.github.io/spec/core/syntax/instructions.html).
#[allow(missing_docs)]
#[cfg_attr(feature = "_internal_cli", derive(serde::Deserialize))]
#[cfg_attr(feature = "_internal_cli", derive(serde_derive::Deserialize))]
pub enum InstructionKind: u16 {
Numeric,
Vector,
Expand Down
1 change: 1 addition & 0 deletions crates/wit-component/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ indexmap = { workspace = true }
wast = { workspace = true }
wat = { workspace = true }
serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = { workspace = true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/wit-component/src/encoding/docs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{bail, Result};
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use serde_derive::{Deserialize, Serialize};
use wasm_encoder::{CustomSection, Encode};
use wit_parser::{Docs, InterfaceId, PackageId, Resolve, TypeId, WorldId, WorldItem, WorldKey};

Expand Down
3 changes: 2 additions & 1 deletion crates/wit-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ unicode-xid = "0.2.2"
log = { workspace = true }
url = { workspace = true }
semver = { workspace = true }
serde.workspace = true
serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = "1.0.105"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/wit-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{Context, Result};
use id_arena::{Arena, Id};
use indexmap::IndexMap;
use semver::Version;
use serde::Serialize;
use serde_derive::Serialize;
use std::borrow::Cow;
use std::fmt;
use std::path::Path;
Expand Down
2 changes: 1 addition & 1 deletion crates/wit-parser/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
use anyhow::{anyhow, bail, Context, Result};
use id_arena::{Arena, Id};
use indexmap::{IndexMap, IndexSet};
use serde::Serialize;
use serde_derive::Serialize;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::mem;
use std::path::{Path, PathBuf};
Expand Down
1 change: 1 addition & 0 deletions crates/wit-parser/src/serde_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use id_arena::{Arena, Id};
use indexmap::IndexMap;
use serde::ser::{SerializeMap, SerializeSeq, Serializer};
use serde::Serialize;
use serde_derive::Serialize;

pub fn serialize_none<S>(serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down
2 changes: 1 addition & 1 deletion src/bin/wasm-tools/smith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub struct Opts {
general: wasm_tools::GeneralOpts,
}

#[derive(Default, Debug, Parser, Clone, serde::Deserialize)]
#[derive(Default, Debug, Parser, Clone, serde_derive::Deserialize)]
#[serde(rename_all = "kebab-case")]
struct Config {
#[clap(long = "min-types")]
Expand Down

0 comments on commit 7f34ce4

Please sign in to comment.