[SR-4937] DispatchQueue.sync much slower than dispatch_queue_sync due to unnecessary allocations #47514
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
performance
runtime
The Swift Runtime
Attachment: Download
Additional Detail from JIRA
md5: 397ee4b6ea34e12ee215e25032316bfa
Issue Description:
Swift program
This Swift program
compiled with
swiftc -O test_dispatch_sync_slow.swift
takes about 14s to run on my machine (with Swift 3.1 and swift-4.0-DEVELOPMENT-SNAPSHOT-2017-05-17)C program
This C program
however (which should be exactly the same) only takes about 2s to execute (compiled with
clang -O3 test_dispatch_sync_fast.c -o test_dispatch_sync_fast
).Difference
The difference is that the Swift program spends most of the time calling
Block_copy
andBlock_release
which aren't necessary for a synchronous dispatch... See screenshot.The text was updated successfully, but these errors were encountered: