Skip to content

sgxs: reduce build time: less time features, no thiserror#910

Open
phlip9 wants to merge 2 commits intofortanix:masterfrom
phlip9:phlip9/sgxs-clean-deps
Open

sgxs: reduce build time: less time features, no thiserror#910
phlip9 wants to merge 2 commits intofortanix:masterfrom
phlip9:phlip9/sgxs-clean-deps

Conversation

@phlip9
Copy link
Copy Markdown
Contributor

@phlip9 phlip9 commented Mar 17, 2026

Hey all,

I noticed the sgxs crate is on the critical path in one of our build.rs scripts in CI, and so I took a pass at improving that. After some slight refactoring to remove thiserror and time crate's proc-macro usage, the build time for just sgxs is down ~3.4x, without many downsides:

Before:

$ cargo tree -p sgxs
sgxs v0.8.1 (/home/phlip9/dev/rust-sgx/intel-sgx/sgxs)
├── anyhow v1.0.100
├── byteorder v1.5.0
├── sgx-isa v0.4.1 (/home/phlip9/dev/rust-sgx/intel-sgx/sgx-isa)
│   └── bitflags v1.2.1
├── thiserror v1.0.59
│   └── thiserror-impl v1.0.59 (proc-macro)
│       ├── proc-macro2 v1.0.95
│       │   └── unicode-ident v1.0.12
│       ├── quote v1.0.41
│       │   └── proc-macro2 v1.0.95 (*)
│       └── syn v2.0.115
│           ├── proc-macro2 v1.0.95 (*)
│           ├── quote v1.0.41 (*)
│           └── unicode-ident v1.0.12
└── time v0.3.41
    ├── deranged v0.4.0
    │   └── powerfmt v0.2.0
    ├── itoa v1.0.1
    ├── libc v0.2.180
    ├── num-conv v0.1.0
    ├── num_threads v0.1.6
    ├── powerfmt v0.2.0
    ├── time-core v0.1.4
    └── time-macros v0.2.22 (proc-macro)
        ├── num-conv v0.1.0
        └── time-core v0.1.4

# force the build to run on one core, like in a GitHub Actions CI runner
$ taskset -c 0 cargo build --target-dir /tmp/cargo-target-1 -p sgxs --lib
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.36s

After:

$ cargo tree -p sgxs
sgxs v0.8.1 (/home/phlip9/dev/rust-sgx/intel-sgx/sgxs)
├── anyhow v1.0.100
├── byteorder v1.5.0
├── sgx-isa v0.4.1 (/home/phlip9/dev/rust-sgx/intel-sgx/sgx-isa)
│   └── bitflags v1.2.1
└── time v0.3.41
    ├── deranged v0.4.0
    │   └── powerfmt v0.2.0
    ├── num-conv v0.1.0
    ├── powerfmt v0.2.0
    └── time-core v0.1.4

# force the build to run on one core, like in a GitHub Actions CI runner
$ taskset -c 0 cargo build --target-dir /tmp/cargo-target-2 -p sgxs --lib
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.57s

Comment thread intel-sgx/sgxs/src/sgxs.rs Outdated
Before:

```bash
$ cargo tree -p sgxs
sgxs v0.8.1 (/home/phlip9/dev/rust-sgx/intel-sgx/sgxs)
├── anyhow v1.0.100
├── byteorder v1.5.0
├── sgx-isa v0.4.1 (/home/phlip9/dev/rust-sgx/intel-sgx/sgx-isa)
│   └── bitflags v1.2.1
├── thiserror v1.0.59
│   └── thiserror-impl v1.0.59 (proc-macro)
│       ├── proc-macro2 v1.0.95
│       │   └── unicode-ident v1.0.12
│       ├── quote v1.0.41
│       │   └── proc-macro2 v1.0.95 (*)
│       └── syn v2.0.115
│           ├── proc-macro2 v1.0.95 (*)
│           ├── quote v1.0.41 (*)
│           └── unicode-ident v1.0.12
└── time v0.3.41
    ├── deranged v0.4.0
    │   └── powerfmt v0.2.0
    ├── itoa v1.0.1
    ├── libc v0.2.180
    ├── num-conv v0.1.0
    ├── num_threads v0.1.6
    ├── powerfmt v0.2.0
    ├── time-core v0.1.4
    └── time-macros v0.2.22 (proc-macro)
        ├── num-conv v0.1.0
        └── time-core v0.1.4

$ taskset -c 3 cargo build --target-dir /tmp/cargo-target-1 -p sgxs --lib
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.36s
```

After:

```bash
$ cargo tree -p sgxs
sgxs v0.8.1 (/home/phlip9/dev/rust-sgx/intel-sgx/sgxs)
├── anyhow v1.0.100
├── byteorder v1.5.0
├── sgx-isa v0.4.1 (/home/phlip9/dev/rust-sgx/intel-sgx/sgx-isa)
│   └── bitflags v1.2.1
└── time v0.3.41
    ├── deranged v0.4.0
    │   └── powerfmt v0.2.0
    ├── num-conv v0.1.0
    ├── powerfmt v0.2.0
    └── time-core v0.1.4

$ taskset -c 3 cargo build --target-dir /tmp/cargo-target-2 -p sgxs --lib
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.57s
```
@phlip9 phlip9 force-pushed the phlip9/sgxs-clean-deps branch from fb80800 to c5066bd Compare March 18, 2026 00:43
@phlip9
Copy link
Copy Markdown
Contributor Author

phlip9 commented Mar 31, 2026

gentle ping @Taowyoo, is there anything else you'd like to see in this diff?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-sgxs Crate: sgxs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants