Skip to content

Commit b2ace31

Browse files
authored
doc: improve our ios perf docs (#375)
* doc: improve our ios perf docs * chore: add link to app store guidelines * chore: remove parenthetical
1 parent 7b5990d commit b2ace31

File tree

1 file changed

+36
-29
lines changed

1 file changed

+36
-29
lines changed

src/content/docs/code-push/performance.mdx

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,24 @@ Shorebird uses its own fork of Flutter.
1111
Our fork works exactly as Google's does, including passing all the same
1212
functionality and performance tests.
1313

14-
Using Shorebird's fork will result in no change in your App relative to
15-
Google's. If you believe there is an unintended change, please let us know and
16-
we'd love to work with you to diagnose.
14+
Using Shorebird's fork should not result in any change in your app. If you ever
15+
see any change, please let us know so we can work with you to diagnose!
1716

1817
### Patching
1918

2019
Updating a Flutter app in production is unique to Shorebird's fork.
2120

22-
Updating a Flutter app with a "patch" will result in the app working exactly as
23-
well as it does for a "release", just with new code.
21+
When using Shorebird your app has two different modes of running, un-patched
22+
("release") and patched ("patch"). Both release and patch builds of your app
23+
should function identically to as they would without Shorebird. The only caveat
24+
is on iOS where patched builds can sometimes run slower than release builds due
25+
to iOS restrictions.
2426

25-
However on iOS our patching mechanism is different from all of the other
26-
platforms. This is due to restrictions from the Apple App Store.
27-
28-
The Apple App Store requires all updates to use an interpreter. An interpreter
29-
is a software program that can run other programs (rather than running the
30-
program directly on the hardware). Interpreters are slow, including ours.
27+
The iOS App Store
28+
[requires](https://docs.shorebird.dev/faq/#does-shorebird-comply-with-app-store-guidelines)
29+
all app update systems (like Shorebird's) to use an interpreter. An interpreter
30+
is a software program that can run other programs rather than running the
31+
program directly on hardware. Interpreters are slow.
3132

3233
To work around the performance limitations of an interpreter, Shorebird's
3334
updating system is designed to avoid using the interpreter as much as possible.
@@ -38,15 +39,16 @@ the interpreter (slow), and thus leave all un-changed code running on the CPU
3839

3940
### Why iOS patches are sometimes slow
4041

41-
Unfortunately, compilers, including Dart's, tend to make many non-local changes
42-
to a program as a result of a local change.
43-
44-
This means that when you change one part of your program, sometimes as a result
45-
Dart might change how it builds an entirely separate part of your program.
42+
Most of the time when you make a change to a part of your program, only that
43+
part of the program is changed. However sometimes small changes to one part of
44+
the program can produce large changes in (seemingly) unrelated parts.
4645

47-
Imagine you have a part of your program:
46+
This is due to how compilers (programs that turn source code into machine code)
47+
optimize their output. Dart's compiler uses several tricks to optimize programs
48+
including "type flow analysis" and "inlining", both of which can cause these
49+
unexpected non-local changes.
4850

49-
before.dart
51+
As an example, imagine you have a part of your program:
5052

5153
```
5254
bool isEven<T extends int?>(T value) => value?.isEven ?? false;
@@ -68,6 +70,7 @@ void foo(int x) {
6870
+ void bar(int? x) {
6971
+ print(isEven(x));
7072
+ }
73+
```
7174

7275
In that example, `isEven` and `foo` didn't change. So you would expect Shorebird
7376
should be able to run both of those on the CPU (not have to use an interpreter).
@@ -88,16 +91,20 @@ your application to "un-link" and run in the interpreter.
8891
Unfortunately there is currently no good way to predict if a patch will cause a
8992
performance change to your application.
9093

91-
The good news is that this behavior is relatively rare. 9 out of 10 patches
92-
exhibit no difference after patching and when performance impacting changes
93-
occur, Shorebird's tooling and console will warn you. The bad news is that
94-
predicting when a change will trigger the Dart compiler to cause non-local
95-
changes to your program is very difficult.
94+
The good news is that this behavior is relatively rare. 9 out of 10 patches do
95+
not run into unexpected non-local changes like this and exhibit no difference
96+
after patching. Furthermore, when performance impacting changes occur,
97+
Shorebird's tooling and console will warn you. The bad news is that predicting
98+
when a change will trigger the Dart compiler to cause non-local changes to your
99+
program is very difficult.
96100

97-
When these non-local changes occur, the best thing to do is just try to make the
98-
diff smaller and patch again. For many kinds of patches the performance
99-
difference will be either not noticeable, or worth the trade-off as a stop-gap
100-
between now and when a user can update from the stores.
101+
When these non-local changes occur, the best recommendation we have at this time
102+
is to try to make a new, smaller diff, and patch again.
101103

102-
We have several ideas and will continue to improve this behavior in the future.
103-
```
104+
For the vast majority of patches there is no performance difference at all. For
105+
those which do see a difference, sometimes that difference may still be worth
106+
the trade-off as a stop-gap between now and when a user can get an update via
107+
the App Store.
108+
109+
We have several approaches to explore to remove this limitation on iOS and
110+
intend to continue to improve this behavior in the future.

0 commit comments

Comments
 (0)