Skip to content

Compilation of curve25519-dalek is extremely slow with certain flags used by cargo-fuzz #95240

@ruuda

Description

@ruuda

Compare these two, a normal --release compile of curve25519-dalek 3.2.0:

$ cargo clean
$ perf stat cargo +nightly-2022-03-22 build --release
(...)
 Performance counter stats for 'cargo +nightly-2022-03-22 build --release':

         13,532.26 msec task-clock:u              #    2.244 CPUs utilized          
                 0      context-switches:u        #    0.000 /sec                   
                 0      cpu-migrations:u          #    0.000 /sec                   
           396,009      page-faults:u             #   29.264 K/sec                  
    44,391,387,755      cycles:u                  #    3.280 GHz                    
    73,252,531,349      instructions:u            #    1.65  insn per cycle         
    15,267,527,160      branches:u                #    1.128 G/sec                  
       252,263,876      branch-misses:u           #    1.65% of all branches        

       6.030274305 seconds time elapsed

      12.564481000 seconds user
       0.965248000 seconds sys

And now with some particular flags (these are some of the flags that cargo-fuzz adds):

$ cargo clean
$ perf stat cargo +nightly-2022-03-22 rustc -- --cfg fuzzing -Cpasses=sancov-module -Clink-dead-code -Zsanitizer=address -Cllvm-args=-sanitizer-coverage-trace-compares -C codegen-units=1 -C opt-level=3
(...)
 Performance counter stats for 'cargo +nightly-2022-03-22 rustc -- --cfg fuzzing -Cpasses=sancov-module -Clink-dead-code -Zsanitizer=address -Cllvm-args=-sanitizer-coverage-trace-compares -C codegen-units=1 -C opt-level=3':

        637,839.23 msec task-clock:u              #    1.007 CPUs utilized          
                 0      context-switches:u        #    0.000 /sec                   
                 0      cpu-migrations:u          #    0.000 /sec                   
           644,865      page-faults:u             #    1.011 K/sec                  
 2,219,950,777,451      cycles:u                  #    3.480 GHz                    
 3,692,455,090,375      instructions:u            #    1.66  insn per cycle         
   789,078,921,069      branches:u                #    1.237 G/sec                  
     2,231,900,259      branch-misses:u           #    0.28% of all branches        

     633.489309090 seconds time elapsed

     635.494820000 seconds user
       1.518585000 seconds sys

It takes more than 100× as long as a regular release build. This time is spent compiling curve25519-dalek itself, the dependencies compile within seconds. I initially discovered this when trying to fuzz a package that transitively depends on curve25519-dalek. I haven’t yet tried to minimize the set of flags to see if there is one in particular that is the culprit.

To reproduce, clone https://github.com/dalek-cryptography/curve25519-dalek and check out tag 3.2.0. I’m running this on x86_64 Linux.

Meta

rustc +nightly-2022-03-22 --version --verbose:

rustc 1.61.0-nightly (3c17c84a3 2022-03-21)
binary: rustc
commit-hash: 3c17c84a386e7badf6b2c6018d172496b3a28a04
commit-date: 2022-03-21
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0

I can also reproduce with nightly 2022-03-15. I haven’t tried any others so far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-incr-compArea: Incremental compilationC-bugCategory: This is a bug.E-needs-investigationCall for participation: This issues needs some investigation to determine current statusE-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleI-compiletimeIssue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions