Skip to content

Commit

Permalink
更新 对app包体影响,新增旗舰版本数据
Browse files Browse the repository at this point in the history
  • Loading branch information
pirunxi committed Dec 2, 2024
1 parent 7967e57 commit 982206c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 21 deletions.
34 changes: 23 additions & 11 deletions docs/basic/impactonappsize.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@

编译后的HotUpdate.dll为1216k。为了公平起见,接入HybridCLR的项目会将热更新dll压缩后放入StreamingAssets承包携带。

我们对比了以下6种情况的包体
我们对比了以下8种情况的包体

- NotHybridCLR-NotHotUpdateCode 未接入HybridCLR、未包含HotUpdate代码(即未将HotUpdate包含到AOT中)
- HybridCLR-NotHotUpdateCode-NotMethodBridge 接入HybridCLR、不包含HotUpdate代码,桥接函数文件为空
- HybridCLR-NotHotUpdateCode-MethodBridge 接入HybridCLR、不包含HotUpdate代码,正常生成桥接函数文件
- NotHybridCLR-HotUpdateCode 未接入HybridCLR、包含HotUpdate代码(即将HotUpdate包含到AOT中)
- HybridCLR-HotUpdateCode-NotMethodBridge 接入HybridCLR、包含HotUpdate代码(将HotUpdate.dll压缩后放到StreamingAssets承包携带),桥接函数文件为空
- HybridCLR-HotUpdateCode-MethodBridge 接入HybridCLR、包含HotUpdate代码,正常生成桥接函数文件
- NotHybridCLR-NotHotUpdateCode 未接入HybridCLR,未包含HotUpdate代码(即未将HotUpdate包含到AOT中)
- HybridCLR-NotHotUpdateCode-NotMethodBridge 接入HybridCLR,不包含HotUpdate代码,桥接函数文件为空
- HybridCLR-NotHotUpdateCode-MethodBridge 接入HybridCLR,不包含HotUpdate代码,正常生成桥接函数文件
- NotHybridCLR-HotUpdateCode 未接入HybridCLR,包含HotUpdate代码(即将HotUpdate包含到AOT中)
- HybridCLR-HotUpdateCode-NotMethodBridge 接入HybridCLR,包含HotUpdate代码(将HotUpdate.dll压缩后放到StreamingAssets随包携带),桥接函数文件为空
- HybridCLR-HotUpdateCode-MethodBridge 接入HybridCLR,包含HotUpdate代码,正常生成桥接函数文件
- **HybridCLR旗舰版**-NotHotUpdateCode-MethodBridge 接入旗舰版HybridCLR,不包含HotUpdate代码,正常生成桥接函数
- **HybridCLR旗舰版**-HotUpdateCode-MethodBridge 接入旗舰版HybridCLR,包含HotUpdate代码,正常生成桥接函数

测试数据如下:

Expand All @@ -51,8 +53,10 @@
|HybridCLR-NotHotUpdateCode-NotMethodBridge|30262|10075360|2904652|74026488|19158769|0|0|
|HybridCLR-NotHotUpdateCode-MethodBridge|30900|10075360|2904652|78450168|19905020|0|15082|
|NotHybridCLR-HotUpdateCode|31718|10893056|3103289|79670208|20387018|1206|0|
|HybridCLR-HotUpdateCode-NotMethodBridge|30531|10081232|29006522|74158928|19177165|1206|0|
|HybridCLR-HotUpdateCode-MethodBridge|31259|10081232|29006522|78492496|19920506|1206|14861|
|HybridCLR-HotUpdateCode-NotMethodBridge|30531|10081232|2906522|74158928|19177165|1206|0|
|HybridCLR-HotUpdateCode-MethodBridge|31259|10081232|2906522|78492496|19920506|1206|14861|
|**HybridCLR旗舰版**-NotUserCode-MethodBridge|31022|10078796|2905605|78643792|19935716|0|14837|
|**HybridCLR旗舰版**-UserCode-MethodBridge|32910|10893080|3103310|85964616|21622297|1206|15179|

> `未压缩` 指在apk内该文件的原始大小,`压缩` 指在apk内该文件压缩后的大小
Expand All @@ -64,12 +68,20 @@
- 桥接函数文件增加了大约 `{MethodBridge.cpp大小} * 0.049` 包体大小
- 每新增大小为S的游戏代码,对于没接入HybridCLR的App,增加了`S * 1.37`包体大小
- 每增加大小为S的游戏代码,对于接入HybridCLR的App,增加了`S * 0.2`包体大小
- 每新增大小为S的游戏代码,旗舰版新增了`S * 1.56`包体大小
- 未包含任何更新程序集时,旗舰版相比社区版增加了32K包体

## 总结

接入HybridCLR增加了`196k + {桥接函数文件大小}*0.049` 大小的包体,但将游戏代码从AOT中移到热更新后能减少`{热更新dll大小}*1.17`倍包体。
### 社区版、专业版、热重载版本

接入HybridCLR增加了`196k + {MethodBridge.cpp 大小}*0.049` 大小的包体,但将游戏代码从AOT中移到热更新后能减少`{热更新dll大小}*1.17`倍包体。

这意味着,如果一个项目热更新代码超过800K-1500K,接入HybridCLR后最终包体会比未接入HybridCLR小。最终减少的包体可以简略地使用 `热更新dll大小*1.05`近似计算。

对于社区版、专业版、热重载版本以上结论均适用,对于旗舰版本,由于DHE程序集也被编译到AOT中,所以旗舰版本会导致包体整体增加,相比于未接入增加了2-5M包体。
### 旗舰版本

接入HybridCLR增加了`228k + {MethodBridge.cpp 大小}*0.049` 大小的包体。DHE程序集中新增代码会导致新增`{新增DHE程序集大小}*1.56`大小的包体。
将游戏代码从AOT移到DHE程序集后,将会增加`{新增DHE程序集大小}*0.19`大小的包体。


Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ The hot-update portion of the test project includes the following:

The compiled HotUpdate.dll is 1216KB. To ensure fairness, the hot-update DLLs in projects integrated with HybridCLR are compressed and included in the StreamingAssets package.

We compared the package size across the following six scenarios:
We compared the package size across the following eight scenarios:

- NotHybridCLR-NotHotUpdateCode: Without HybridCLR integration and without including HotUpdate code (HotUpdate is not part of AOT).
- HybridCLR-NotHotUpdateCode-NotMethodBridge: Integrated with HybridCLR, without HotUpdate code, and with an empty bridge function file.
- HybridCLR-NotHotUpdateCode-MethodBridge: Integrated with HybridCLR, without HotUpdate code, and with a normal bridge function file.
- NotHybridCLR-HotUpdateCode: Without HybridCLR integration and with HotUpdate code included (HotUpdate is part of AOT).
- HybridCLR-HotUpdateCode-NotMethodBridge: Integrated with HybridCLR, with HotUpdate code included (compressed HotUpdate.dll in the StreamingAssets package), and with an empty bridge function file.
- HybridCLR-HotUpdateCode-MethodBridge: Integrated with HybridCLR, with HotUpdate code included, and with a normal bridge function file.
- **HybridCLR Ultimate Edition**-NotHotUpdateCode-MethodBridge Integrated with HybridCLR Ultimate Edition, without HotUpdate code, and with a normal bridge function file.
- **HybridCLR Ultimate Edition**-HotUpdateCode-MethodBridge Integrated with HybridCLR Ultimate Edition, with HotUpdate code included, and with a normal bridge function file.

The test data is as follows:

Expand All @@ -50,24 +52,37 @@ The test data is as follows:
| HybridCLR-NotHotUpdateCode-NotMethodBridge| 30262 | 10075360 | 2904652 | 74026488 | 19158769 | 0 | 0 |
| HybridCLR-NotHotUpdateCode-MethodBridge | 30900 | 10075360 | 2904652 | 78450168 | 19905020 | 0 | 15082 |
| NotHybridCLR-HotUpdateCode | 31718 | 10893056 | 3103289 | 79670208 | 20387018 | 1206 | 0 |
| HybridCLR-HotUpdateCode-NotMethodBridge| 30531 | 10081232 | 29006522 | 74158928 | 19177165 | 1206 | 0 |
| HybridCLR-HotUpdateCode-MethodBridge | 31259 | 10081232 | 29006522 | 78492496 | 19920506 | 1206 | 14861 |
| HybridCLR-HotUpdateCode-NotMethodBridge| 30531 | 10081232 | 2906522 | 74158928 | 19177165 | 1206 | 0 |
| HybridCLR-HotUpdateCode-MethodBridge | 31259 | 10081232 | 2906522 | 78492496 | 19920506 | 1206 |

|**HybridCLR_UltimateEdition-NotUserCode-MethodBridge**|31022|10078796|2905605|78643792|19935716|0|14837|
|**HybridCLR_UltimateEdition-UserCode-MethodBridge**|32910|10893080|3103310|85964616|21622297|1206|15179|14861 |

> `Uncompressed` indicates the original size of the file within the APK, and `Compressed` indicates the compressed size within the APK.
The original size of the hot-update code HotUpdate.dll is 1216KB, which is compressed to 200KB.

Based on the above test project, we can draw the following conclusions:

- The core part of HybridCLR, excluding MethodBridge.cpp, increases the package size by 196KB.
- The bridge function file increases the package size by approximately `{MethodBridge.cpp Size} * 0.049`.
- For every additional size `S` of game code, an app without HybridCLR integration increases in size by `S * 1.37`.
- For every additional size `S` of game code, an app with HybridCLR integration increases in size by `S * 0.2`.
- The core part of HybridCLR, excluding MethodBridge.cpp, increases the package size by 196KB.
- The bridge function file increases the package size by approximately `{MethodBridge.cpp Size} * 0.049`.
- For every additional size `S` of game code, an app without HybridCLR integration increases in size by `S * 1.37`.
- For every additional size `S` of game code, an app with HybridCLR integration increases in size by `S * 0.2`.
- For every additional size `S` of game code, the Ultimate Edition increases the package size by `S * 1.56`.
- When no update assemblies are included, the Ultimate Edition increases the package size by 32KB compared to the Community version.


## Summary

Integrating HybridCLR increases the package size by `196KB + {MethodBridge.cpp Size} * 0.049`. However, moving game code from AOT to hot updates can reduce the package size by `{HotUpdate.dll Size} * 1.17`.
### Community, Professional, and Hot Reload Edition

Integrating HybridCLR increases the package size by `196k + {MethodBridge.cpp File Size} * 0.049`, but moving game code from AOT to hot updates can reduce the package size by `{HotUpdate.dll Size} * 1.17`.

This means that if the hot-update code in a project exceeds 800KB-1500KB, integrating HybridCLR will result in a smaller final package size compared to not integrating it. The total package size reduction can be approximately calculated as `HotUpdate.dll Size * 1.05`.

### Ultimate Editionn

This means that if the hot-update code in a project exceeds 800KB-1500KB, integrating HybridCLR results in a smaller final package size than without it. The total package size reduction can be approximately calculated as `HotUpdate.dll Size * 1.05`.
Integrating HybridCLR increases the package size by `228k + {MethodBridge.cpp File Size} * 0.049`.
Newly added code in the DHE assemblies will increase the package size by `{New DHE Assembly Size} * 1.56`.
Moving game code from AOT to the DHE assemblies will increase the package size by `{New DHE Assembly Size} * 0.19`.

The above conclusions apply to the Community, Professional, and Hot Reload versions. For the Flagship version, since DHE assemblies are also compiled into AOT, the Flagship version increases the overall package size by 2-5MB compared to not integrating HybridCLR.

0 comments on commit 982206c

Please sign in to comment.