Skip to content

toml 0.4.9 to 0.5.3 compile for a long time on 2021-10-02 nightly #89524

Closed

Description

@saethlin
[dependencies]
config = "=0.9.3"

[profile.release]
panic = "abort"
codegen-units = 1

It seems like both the panic setting and codegen-units setting are required.

I don't know what is going on, but LLVM seems to think it's doing something, but it's been doing the same something for the past 30 minutes. perf top says:

  41.22%  libLLVM-13-rust-1.57.0-nightly.so  [.] llvm::getUniqueExitBlocksHelper<llvm::BasicBlock, llvm::LoopBase<llvm::BasicBlock, llvm::Loop>, llvm::LoopBase<llvm::BasicBlock, llvm::Loop>::getUniq
  36.17%  libLLVM-13-rust-1.57.0-nightly.so  [.] llvm::ScalarEvolution::forgetMemoizedResults
   7.01%  libLLVM-13-rust-1.57.0-nightly.so  [.] llvm::Instruction::getSuccessor
   5.58%  libLLVM-13-rust-1.57.0-nightly.so  [.] llvm::ScalarEvolution::getLoopDisposition
   2.63%  libLLVM-13-rust-1.57.0-nightly.so  [.] llvm::ScalarEvolution::getSCEVAtScope

rustc --version --verbose:

rustc 1.57.0-nightly (f03eb6bef 2021-10-02)
binary: rustc
commit-hash: f03eb6bef8ced8a243858b819e013b9caf83d757
commit-date: 2021-10-02
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0

Activity

  1. added
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.
    on Oct 4, 2021
  2. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Oct 4, 2021
  3. saethlin commented on Oct 4, 2021

    @saethlin
    MemberAuthor

    Update: Compilation finished after about 40 minutes.

  4. changed the title [-]config = "=0.9.3" compiles forever on 2021-10-02 nightly[/-] [+]config = "=0.9.3" compiles for a long time on 2021-10-02 nightly[/+] on Oct 4, 2021
  5. ehuss commented on Oct 5, 2021

    @ehuss
    Contributor

    Bisected to #88243, cc @nikic

  6. apiraino commented on Oct 6, 2021

    @apiraino
    Contributor

    @saethlin what's the command you use to reproduce this issue? Do you add some flags, such as -Znew-llvm-pass-manager?

  7. saethlin commented on Oct 7, 2021

    @saethlin
    MemberAuthor

    @apiraino No flags. Just cargo build --release with the dependencies and profile.release tables in Cargo.toml.

    Are you having trouble reproducing?

  8. apiraino commented on Oct 7, 2021

    @apiraino
    Contributor

    ah yes thank you @saethlin, I didn't read carefully your configuration. yes, I can now reproduce, I believe the issue is in one of the dependencies of config=0.9.3 (dated 2019, so all dependencies are equally old or even older). I've noticed that compiling config=0.11 doesn't reproduce anymore this issue.

    Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

    @rustbot label -I-prioritize +P-medium +T-compiler

  9. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Oct 7, 2021
  10. saethlin commented on Oct 7, 2021

    @saethlin
    MemberAuthor

    I'm poking at this. It's out of my expertise, but maybe I'll turn up something useful.

    I minimized config down to this function:

    pub fn parse(text: &str) -> toml::Value {
        toml::from_str(text).unwrap()
    }

    So the regression is reproduced just by something in toml. It appears first in commit
    f667495ae34395be9fc3e4bb8801cacf52c2253e and is removed by 7c9b0a39db0c4c235db372f88d725fae6e82889f

    The older commits compile in release within a few seconds, while the more recent commits need just over a minute. I suggest investigating this based on the older toml commits in that range.

  11. changed the title [-]config = "=0.9.3" compiles for a long time on 2021-10-02 nightly[/-] [+]toml 0.4.9 to 0.5.3 compile for a long time on 2021-10-02 nightly[/+] on Oct 7, 2021
  12. saethlin commented on Oct 7, 2021

    @saethlin
    MemberAuthor

    --debug-pass=Details tuns up an endless stream of loop passes, which seems cruelly ironic

    [2021-10-07 19:01:26.263184842] 0x7f138d061820       Executing Pass 'Canonicalize Freeze Instructions in Loops' on Loop ''...
    0x7f138d5546e0         Required Analyses: Natural Loop Information, Canonicalize natural loops, Scalar Evolution Analysis, Dominator Tree Construction
    0x7f138d5546e0         Preserved Analyses: Canonicalize natural loops, Natural Loop Information, Scalar Evolution Analysis, Dominator Tree Construction
     -*- 'Canonicalize Freeze Instructions in Loops' is the last user of following pass instances. Free these instances
    [2021-10-07 19:01:26.263400523] 0x7f138d061820        Freeing Pass 'Canonicalize Freeze Instructions in Loops' on Loop ''...
    [2021-10-07 19:01:26.263403573] 0x7f138d061820       Executing Pass 'Induction Variable Users' on Loop ''...
    0x7f138d407180         Required Analyses: Assumption Cache Tracker, Natural Loop Information, Dominator Tree Construction, Scalar Evolution Analysis
    [2021-10-07 19:01:26.330309621] 0x7f138d061820       Executing Pass 'Loop Strength Reduction' on Loop ''...
    0x7f138d554420         Required Analyses: Natural Loop Information, Canonicalize natural loops, Dominator Tree Construction, Scalar Evolution Analysis, Assumption Cache Tracker, Target Library Information, Induction Variable Users, Target Transform Information
    [2021-10-07 19:01:26.330791412] 0x7f138d061820       Made Modification 'Loop Strength Reduction' on Loop '<unnamed loop>'...
    0x7f138d554420         Preserved Analyses: Canonicalize natural loops, Natural Loop Information, Dominator Tree Construction, Scalar Evolution Analysis, Induction Variable Users, Memory SSA
     -*- 'Loop Strength Reduction' is the last user of following pass instances. Free these instances
    [2021-10-07 19:01:26.330804321] 0x7f138d061820        Freeing Pass 'Induction Variable Users' on Loop ''...
    [2021-10-07 19:01:26.330808321] 0x7f138d061820        Freeing Pass 'Loop Strength Reduction' on Loop ''...
    [2021-10-07 19:01:26.330812571] 0x7f138d061820       Executing Pass 'Canonicalize Freeze Instructions in Loops' on Loop ''...
    
  13. added this to the 1.57.0 milestone on Oct 8, 2021
  14. nikic commented on Oct 9, 2021

    @nikic
    Contributor

    Looks like LLVM manages to blow up _ZN126_$LT$$LT$toml..value..Value$u20$as$u20$serde..de..Deserialize$GT$..deserialize..ValueVisitor$u20$as$u20$serde..de..Visitor$GT$9visit_map17h0937f33df0be8d95E to approximately 750k instructions.

  15. nikic commented on Oct 9, 2021

    @nikic
    Contributor

    Adding some size instrumentation, we end up running the cgscc pipeline on this function four times, which includes inlining and the function simplification pipeline. On each inline, the size jumps from 325 originally to 16069 to 103390 to 778219 instructions. This is not due to devirt iteration. I can avoid the last one by dropping the UpdatedC reprocessing. Something is going catastrophically wrong here in the interaction between the CGSCC pass manager and the inliner.

  16. nikic commented on Oct 10, 2021

    @nikic
    Contributor

    I think the issue here is recursive drop glue that gets recursively inlined. This looks similar to the report at https://bugs.llvm.org/show_bug.cgi?id=45253.

  17. Mark-Simulacrum commented on Nov 19, 2021

    @Mark-Simulacrum
    Member

    @nikic do we think we can push the patch for fixing this forward on the LLVM side somehow? It seems desirable to fix this as soon as we can, though it likely won't make the next release given the short timeline...

  18. nikic commented on Nov 19, 2021

    @nikic
    Contributor

    @Mark-Simulacrum I don't have much hope for a timely upstream fix. We can cherry-pick https://reviews.llvm.org/D98481. It has minor perf impact per #89830.

  19. added
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    and removed on Dec 3, 2021
  20. adrian17 commented on Jan 5, 2022

    @adrian17

    For the record, this and #89647 still appear to hang and consume lots of memory. (I was quietly hoping #92110 would improve it)

    Is this still considered a NewPM blocker?

  21. saethlin commented on Feb 18, 2022

    @saethlin
    MemberAuthor

    Checking in, the problem documented in this issue no longer reproduces on nightly or stable (1.58.1).

    But the example documented in #89647 still seems to be a problem.

  22. nikic commented on Mar 9, 2022

    @nikic
    Contributor

    Closing this one as the specific case doesn't reproduce anymore, and we have other issues tracking similar problems.

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

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-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions