Skip to content

Long Compile Time (with Optimization) with Large Arrays (2-3 hours) #49330

Open
@telboon

Description

@telboon

Summary

I have gotten very long compile time (2 hrs plus) when I tried to compile a code that has a large array inbuilt in the code when I turn optimization on. When the code is compiled without optimization, it has a acceptable compile time (10+ seconds).

The array contains 130,000 + strs.

Details

I tried this code:

$ cargo build
   Compiling alliteration-gen v0.1.0 (file:///<REDACTED>)
    Finished dev [unoptimized + debuginfo] target(s) in 11.23 secs
$ cargo build --release
   Compiling alliteration-gen v0.1.0 (file:///<REDACTED>)
^C

I expected to see this happen: With the non-optimized code running in 11 seconds, the optimized one shouldn't take more than a few minutes.

Instead, this happened: When i waited for it to compile, it took 10039.81 secs (2 hrs 47 mins).

I replicated the problem again on a different Cargo project path and different machines and faced the same issue (didn't fully compile them as it would take very long. I waited for 5 minutes for each machine).

Environment

Machines tested:

  1. Ubuntu 16.04 (Dell XPS 9360 Intel i5-7200U; 8GB RAM)
  2. Kali Linux 2018.01 (Old Laptop with i5)
  3. Windows 10 with msvc (Desktop Intel i5 4570 3.2GHz; 8GB RAM)

Cargo project files attached.
nolib.zip

Meta

rustc --version --verbose:
rustc 1.22.1
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.22.1
LLVM version: 4.0

rustc 1.24.1
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.24.1
LLVM version: 4.0

rustc 1.24.1 (d3ae9a9 2018-02-27)
binary: rustc
commit-hash: d3ae9a9
commit-date: 2018-02-27
host: x86_64-pc-windows-msvc
release: 1.24.1
LLVM version: 4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-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