-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-7703] Creating an array with 10.000 elements is slow with optimization. #50243
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
Comments
cc: @eeckstein / @gottesmm |
Comment by Andreas Wendleder (JIRA) (Temporarily) Disabling the RedundantLoadElimination pass brings it down to 1.3 seconds. |
@swift-ci create |
Comment by Andreas Wendleder (JIRA) Xcode 7.1 is still unusable with this. |
Comment by Andreas Wendleder (JIRA) I put together a nice little diagram showing the quadratic complexity of RLE: https://docs.google.com/spreadsheets/d/16VakcOYvcwZbmPRLxO_1HcLUwCx0xEVT5mXWYsYnQjY/edit?usp=sharing It shows that RLE is the worst offender in compile times with large matrices. In effect, compiling an array with one million elements would take roughly 80 hours with Swift, whereas g++ with optimisation takes less than 4 seconds, and Python compiles and executes it within less than 2 seconds. I attached a new Makefile for C++ and Python. Inlining is also a problem but this is already addressed in #51712. |
Comment by Andreas Wendleder (JIRA) After #51712 was fixed this is the last remaining artefact that exhibits quadratic complexity with large arrays. Please have a look at https://docs.google.com/spreadsheets/d/16VakcOYvcwZbmPRLxO_1HcLUwCx0xEVT5mXWYsYnQjY/edit#gid=0 I will have more information the next days. cc @eeckstein @gottesmm trentxintong (JIRA User) @atrick |
Comment by Andreas Wendleder (JIRA) This is not a duplicate and not resolved with Swift 5. Compiling 10.000 elements with optimisation takes 68 seconds on macOS 10.14.3 and Xcode 10.2 with Swift 5.0 |
Comment by Andreas Wendleder (JIRA) Performance numbers with Xcode 10.2.1 and snapshot 2019-04-16 and 10.000 elements: Xcode 10.2.1: 35 seconds Snapshot: 30 seconds. Commits 4e9a9cc and 8f47439 from @eeckstein seem to help only a little bit. |
Comment by Andreas Wendleder (JIRA) Swift 5.0.1 on Linux: 10.000 elements: 14 seconds. |
Comment by Andreas Wendleder (JIRA) Swift 5.1 macOS: 10.000 elements: 20 seconds. |
Comment by Andreas Wendleder (JIRA) Swift 5.1.1 Linux: 5.000 elements: 6.9s Perf trace:
|
Comment by Andreas Wendleder (JIRA) Swift 5.2.4 Linux: 5.000 elements: 6.2s 10.000 elements: 25.4s |
Comment by Andreas Wendleder (JIRA) Swift 5.3.3 Linux: 10.000 elements: 16s C++ (gcc or clang): 0.04s Python: 0.04s |
Swift 5.7 Linux: 10.000 elements: Swift: 5s Related bugs: My collection of swift bugs (with only these remaining): https://github.com/gonsolo/swift_bugs |
perf report:
|
Swift 5.8 Linux, 10.000 elements: 5.3 seconds. |
Running perf:
It seems to be the same issue as in #51712. @AnthonyLatsis @eeckstein @atrick |
We should probably close that one as a duplicate and keep this one open until we actually land a timing regression test, or odds are we will keep opening issues just because the stats changed without much improvement in build times. |
Swift 5.9 Linux, 10.000 elements: 4.3 seconds.
|
@gonsolo can you remind me what's the source code for this test? |
Ah, you tested with swift 5.9. Can you try with a recent development snapshot? |
It seems the attachment at the top of this issue is corrupted. Here is it again, it's a Makefile:
|
Swift snapshot trunk January 15, 2024, Linux, 10.000 elements: 2.96 seconds. Better, still 60x slower. Perf report:
|
That's with "-O" for Swift and "-O3" for C++. Without optimization:
|
Thanks for doing the experiments! |
Swift version 5.11-dev (LLVM 48dba337c6a2104, Swift 823db1f) 10.000 elements: 2.9s Same stack trace as in #50243 (comment) I think this can be closed, @eeckstein. Thanks for all the work involved. |
Attachment: Download
Additional Detail from JIRA
md5: a9f53d8799e79775521d84b544cb5974
is duplicated by:
Issue Description:
After #50173 and #50231 were fixed, compiling large arrays works fine without optimization, in a non-asserting build where the SILVerifier is disabled (still waiting for #50242).
Switching on -O slows down compilation again. See the attached Makefile how I create an array of 10.000 Int elements. Compiling with -O takes 16 seconds.
Here are the offending functions from perf:
The text was updated successfully, but these errors were encountered: