Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-2519] Swift binary can be significantly larger than the source code #45124

Open
swift-ci opened this issue Aug 30, 2016 · 2 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself IRGen LLVM IR generation performance SILGen Area → compiler: The SIL generation stage

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-2519
Radar None
Original Reporter cezarywojcik (JIRA User)
Type Bug

Attachment: Download

Environment

Apple Swift version 3.0 (swiftlang-800.0.43.6 clang-800.0.38)

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, IRGen, Performance, SILGen
Assignee None
Priority Medium

md5: 8783b1f41b2388e7b855c162ac5af4b6

Issue Description:

In my exploration to profile what structure (class, struct, enum) is most efficient as a static function container with regards to both compilation time and binary size, I came upon something that I find quite puzzling.

I generated a ~1M Swift file, however, the compiled binary for this file is ~7.9M (running swiftc class.swift -o class). I attached my generated class.swift file.

@belkadan
Copy link
Contributor

The compile time for a 1MB file isn't very good either, especially with optimizations on.

On my machine, -Onone (the default) produces the 7.9MB binary you refer to; the optimized version is 2.1MB.

@swift-ci
Copy link
Collaborator Author

Comment by Cezary Wojcik (JIRA)

Unoptimized is a lot faster than it was in Swift 2.2 (~30s vs ~125s), but yeah, optimized is still pretty slow (though it has gotten better as well - ~130s in Swift 3 vs ~220s in Swift 2.2).

I got a 2.3MB binary with optimizations on (-O) in Swift 3, though both 2.1 and 2.3 are still 2x larger than the source code itself.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself IRGen LLVM IR generation performance SILGen Area → compiler: The SIL generation stage
Projects
None yet
Development

No branches or pull requests

2 participants