Optimizing Swift Performance

김민종·2023년 3월 18일
0

WWDC

목록 보기
4/4

Swift is a Flexible, Safe programming language with ARC.

These features make swift to make less overhead
One of the way to compile optimizing is bounds check elimination.

How to optimize debugging unoptimized code?
There are two ways to do it.

First, improved swift runtime.
Second, improved swift standard library.

By showing comparsion, Swift is much faster than Objective-C.

Xcode compiles file independently, but with Whole Module Optimization optimizes module together at once.
Xcode provides WMO options at build setting option.

Reference Counting

Next shows how Swift Reference Counting works.

A Structure requires reference counting if its properties require reference counting
In Structure containing with string, array the properites reference count increase and when copying that struct the RC grows and when make wrapper class, the wrapper class itself can increase of rc 1 bu it can make overhead to get wrong data back.

Generics


This shows how generics work underneath program


By using whole module optimization File2 and File1 compiles together and knows the description of each file so it can minimize the overhead.

dynamic dispatch

When if the name never changes and overrides?

We can use Constraints
1. Inheritance
2. Access Control

This inheritance contraints can reduce the work of compiler to be faster.

So why Swift is faster than Objective-C?
OBJC the compiler cannot eliminate dynamic dispatch and so compiler thinks all can be possible.

Finally use swift and use Whole Module Optimizing!

profile
신입 ios개발자입니다!

0개의 댓글