-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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-6983] Unexpected drop in performance of (identity-)closure the second time it is used #49531
Comments
cc aschwaighofer@apple.com (JIRA User) |
Issue remains – and has gotten worse – with the default toolchain of Xcode 9.4 (9F1027a). The "2nd use of closure" is now 10 instead of 3 times slower than the others:
So “2nd use of closure” is now 0.66 seconds. It was 0.18 seconds when I reported the issue (see compiler version in the example run in the report). The other ones are still 0.06 seconds. BUT: When using a recent dev snapshot (2018-05-29) the "2nd use of closure" is back to 0.18 seconds again. |
@swift-ci create |
Ah! The same workaround as is discussed in SR-7023 can of course be used here too, so replacing the for-in loop with a while loop as follows will make all test cases equally fast:
|
Issue remains in Xcode 11.3 (11C29), and the work-around (while instead of for-in) in the comment above no longer works. |
Additional Detail from JIRA
md5: 19f6d1e506b16df7b9ecc2264c9326db
relates to:
Issue Description:
Reporting this issue as suggested by @dabrahams in this forum thread.
The following program measures the time it takes to process a hundred million random input values using an identity closure and an identity func. In the first measurement, both are equally fast (as expected). But in the second measurement (identical in code and context) the closure is slower for some reason.
Compiling and running it on my MBP:
(Note that “2nd use of closure” is 0.18 seconds while all the other measurements are 0.06 seconds.)
The text was updated successfully, but these errors were encountered: