Skip to content

bcs: clean deps, reduce CI clean build time#14

Open
phlip9 wants to merge 2 commits intozefchain:mainfrom
phlip9:phlip9/clean-deps
Open

bcs: clean deps, reduce CI clean build time#14
phlip9 wants to merge 2 commits intozefchain:mainfrom
phlip9:phlip9/clean-deps

Conversation

@phlip9
Copy link

@phlip9 phlip9 commented Mar 18, 2026

Hey!

I noticed bcs on the critical path of a build.rs script in CI, so I took a pass at fixing that. After some slight refactoring to (1) remove thiserror and (2) use serde_core traits directly, the "1 vCPU in CI" clean build time is down ~5.7x, without many downsides:

Before:

$ cargo tree --edges build,normal
bcs v0.1.6 (/home/phlip9/dev/bcs)
├── serde v1.0.228
│   ├── serde_core v1.0.228
│   └── serde_derive v1.0.228 (proc-macro)
│       ├── proc-macro2 v1.0.106
│       │   └── unicode-ident v1.0.24
│       ├── quote v1.0.45
│       │   └── proc-macro2 v1.0.106 (*)
│       └── syn v2.0.117
│           ├── proc-macro2 v1.0.106 (*)
│           ├── quote v1.0.45 (*)
│           └── unicode-ident v1.0.24
└── thiserror v1.0.69
    └── thiserror-impl v1.0.69 (proc-macro)
        ├── proc-macro2 v1.0.106 (*)
        ├── quote v1.0.45 (*)
        └── syn v2.0.117 (*)

$ rm -rf /tmp/cargo-target && taskset -c 3 cargo build --target-dir /tmp/cargo-target --lib
    Finished dev [unoptimized + debuginfo] target(s) in 7.89s

After:

$ cargo tree --edges build,normal
    Updating crates.io index
bcs v0.1.6 (/home/phlip9/dev/bcs)
└── serde_core v1.0.228

$ rm -rf /tmp/cargo-target && taskset -c 3 cargo build --target-dir /tmp/cargo-target --lib
   Compiling serde_core v1.0.228
   Compiling bcs v0.1.6 (/home/phlip9/dev/bcs)
    Finished dev [unoptimized + debuginfo] target(s) in 1.38s

phlip9 added 2 commits March 17, 2026 18:53
`bcs` only uses proc-macro serde derives in tests. We can reduce compile
times by using `serde_core` directly, which only exports the core serde
traits.
Before:

```
$ cargo tree --edges build,normal
bcs v0.1.6 (/home/phlip9/dev/bcs)
├── serde v1.0.228
│   ├── serde_core v1.0.228
│   └── serde_derive v1.0.228 (proc-macro)
│       ├── proc-macro2 v1.0.106
│       │   └── unicode-ident v1.0.24
│       ├── quote v1.0.45
│       │   └── proc-macro2 v1.0.106 (*)
│       └── syn v2.0.117
│           ├── proc-macro2 v1.0.106 (*)
│           ├── quote v1.0.45 (*)
│           └── unicode-ident v1.0.24
└── thiserror v1.0.69
    └── thiserror-impl v1.0.69 (proc-macro)
        ├── proc-macro2 v1.0.106 (*)
        ├── quote v1.0.45 (*)
        └── syn v2.0.117 (*)

$ rm -rf /tmp/cargo-target && taskset -c 3 cargo build --target-dir /tmp/cargo-target --lib
    Finished dev [unoptimized + debuginfo] target(s) in 7.89s
```

After:

```
$ cargo tree --edges build,normal
    Updating crates.io index
bcs v0.1.6 (/home/phlip9/dev/bcs)
└── serde_core v1.0.228

$ rm -rf /tmp/cargo-target && taskset -c 3 cargo build --target-dir /tmp/cargo-target --lib
   Compiling serde_core v1.0.228
   Compiling bcs v0.1.6 (/home/phlip9/dev/bcs)
    Finished dev [unoptimized + debuginfo] target(s) in 1.38s
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant