Opened 2 years ago

Last modified 17 months ago

#25269 needs_information enhancement

Set codegen-units to 1 in src/rust/Cargo.toml to eke out every last drop of performance

Reported by: cypherpunks Owned by: Backxwash
Priority: Medium Milestone: Tor: unspecified
Component: Core Tor/Tor Version:
Severity: Normal Keywords: rust, easy, 034-triage-20180328, 034-removed-20180328, fast-fix, 035-triaged-in-20180711, 040-deferred-201915
Cc: chelseakomlo Actual Points:
Parent ID: Points: .1
Reviewer: nickm Sponsor:

Description

Rust 1.24 now sets codegen-units to 16 by default to speed up compilation time but it makes the final binary slower https://blog.rust-lang.org/2018/02/15/Rust-1.24

For maximum speed, setting codegen-units to 1 in your Cargo.toml is needed to eke out every last drop of performance.

So src/rust/Cargo.toml should be changed with that to squeeze the most perf.

Child Tickets

Change History (20)

comment:1 Changed 2 years ago by cypherpunks

Milestone: Tor: 0.3.3.x-final

comment:2 Changed 2 years ago by nickm

Will this break with older versions of rust?

comment:3 in reply to:  2 Changed 2 years ago by cypherpunks

Replying to nickm:

Will this break with older versions of rust?

codegen-units apparently exists since 2014 https://internals.rust-lang.org/t/default-settings-for-parallel-codegen/519

comment:4 Changed 2 years ago by nickm

Do we have to do this in all of our Cargo.toml files, or is it enough to do it in the toplevel one?

comment:5 Changed 2 years ago by nickm

Milestone: Tor: 0.3.3.x-finalTor: 0.3.4.x-final

comment:6 Changed 2 years ago by nickm

Keywords: 034-triage-20180328 added

comment:7 Changed 2 years ago by nickm

Keywords: 034-removed-20180328 added

Per our triage process, these tickets are pending removal from 0.3.4.

comment:8 Changed 2 years ago by nickm

Milestone: Tor: 0.3.4.x-finalTor: unspecified

These tickets, tagged with 034-removed-*, are no longer in-scope for 0.3.4. We can reconsider any of them, if time permits.

comment:9 Changed 2 years ago by isis

Keywords: fast-fix added
Milestone: Tor: unspecifiedTor: 0.3.5.x-final
Owner: set to isis
Points: .1
Status: newaccepted
Type: defectenhancement

comment:10 Changed 2 years ago by isis

Status: acceptedneeds_review

See my bug25269 branch.

comment:11 Changed 2 years ago by dgoulet

Reviewer: nickm

comment:12 Changed 2 years ago by Backxwash

Owner: changed from isis to Backxwash
Status: needs_reviewassigned

comment:13 Changed 2 years ago by nickm

Status: assignedneeds_information

Hm. How badly does this affect build performance and how much does it help binary performance? If the binary savings aren't significant, I say we shouldn't worry about this. If the build cost is huge, we should probably stick it behind a configure option.

comment:14 Changed 2 years ago by isis

Totally hand-wavey measurement in a Qubes VM on a x220 with an i5 using turboboost doing like a million other things, running configure --enable-rust --enable-cargo-online-mode --enable-fatal-warnings --disable-asciidoc && time make -j4:

With codegen-units = 1:

real    5m15.728s
user    14m29.903s
sys     3m55.476s

Without:

real    5m18.433s
user    15m15.399s
sys     4m12.781s

So it seems to have a negligible effect on build times if it randomly ended up being longer without it? I don't know how much faster it makes the binaries.

comment:15 Changed 2 years ago by isis

This could possibly because we don't have all that much Rust code at the present moment? Perhaps it will make more of an impact later?

comment:16 Changed 2 years ago by nickm

Keywords: 035-triaged-in-20180711 added

comment:17 Changed 22 months ago by chelseakomlo

Cc: chelseakomlo added

comment:18 Changed 21 months ago by nickm

Milestone: Tor: 0.3.5.x-finalTor: 0.3.6.x-final

Deferring various feature-y things to 0.3.6. If one of these is actually happening in 0.3.5, please let me know!

comment:19 Changed 19 months ago by nickm

Milestone: Tor: 0.3.6.x-finalTor: 0.4.0.x-final

Tor 0.3.6.x has been renamed to 0.4.0.x.

comment:20 Changed 17 months ago by nickm

Keywords: 040-deferred-201915 added
Milestone: Tor: 0.4.0.x-finalTor: unspecified

Deferring some tickets from 0.4.0 without proposing them for later. Please tag with 041-proposed if you want to do them.

Note: See TracTickets for help on using tickets.