Skip to content

[SR-7691] Statically compiled Double Array with 50.000 elements takes 48 seconds to compile #50231

@swift-ci

Description

@swift-ci
Previous ID SR-7691
Radar rdar://problem/40258978
Original Reporter andreasw (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Dell Latitude Notebook, Ubuntu 17.10, latest Swift, non-assert, release build.

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Performance
Assignee @dcci
Priority Medium

md5: 4fef877da02a1c5917786d1ded1274a6

Issue Description:

I generate a 50.000 element Double Array (common when doing large matrix computations) with:

echo "let x: [Double] = [" > linear.swift; LANG=C seq -s, -f "%f" 50000 >> linear.swift; echo "]"

It looks like this:

let x:  [Double] = [1.0, 2.0, 3.0, ..., 50000.0]

Compiling on Ubuntu with a non-assert release swiftc with -Onone takes 48 seconds.

The offending functions:

+ 42,16% 0,00% ld.gold x86_64-linux-gnu-ld.gold [.] 0xffffaa380e486d69
+ 31,06% 30,96% swift swift [.] llvm::StringRef::find_last_of
+ 27,18% 0,00% ld.gold x86_64-linux-gnu-ld.gold [.] 0xffffaa380e48a472
+ 19,96% 0,00% ld.gold x86_64-linux-gnu-ld.gold [.] 0xffffaa380e347f20
+ 19,94% 0,00% ld.gold x86_64-linux-gnu-ld.gold [.] 0xffffaa380e486798
+ 19,53% 19,06% ld.gold libc-2.26.so [.] __memcmp_avx2_movbe
+ 18,10% 0,01% swift swift [.] llvm::FastISel::materializeRegForValue
+ 18,09% 0,02% swift swift [.] (anonymous namespace)::X86FastISel::fastMaterializeConstant
+ 18,07% 17,98% swift swift [.] llvm::MachineConstantPool::getConstantPoolIndex
+ 18,04% 0,01% swift swift [.] swift::Lowering::SILGenFunction::emitApply
+ 17,95% 0,00% swift swift [.] swift::SILLocation::decode
+ 17,94% 0,00% swift swift [.] llvm::SourceMgr::getLineAndColumn
+ 16,72% 0,00% ld.gold x86_64-linux-gnu-ld.gold [.] 0xffffaa380e48a3d0
+ 14,74% 14,74% ld.gold x86_64-linux-gnu-ld.gold [.] 0x000000000018545b
+ 7,27% 0,00% ld.gold x86_64-linux-gnu-ld.gold [.] 0xffffaa380e486760

Doing the same in C++ with clang or gcc takes 0.3 seconds.

Metadata

Metadata

Assignees

Labels

SILGenArea → compiler: The SIL generation stagebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdebug infoArea → compiler → IRGen: Debug information emissionexpressionsFeature: expressionsliteralsFeature → expressions: Literals such as an integer or string literalperformanceswift 4.2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions