Closed Bug 1218091 Opened 10 years ago Closed 10 years ago

[Messages][Performance] Use optimized Bridge libraries

Categories

(Firefox OS Graveyard :: Gaia::SMS, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(b2g-v2.5 fixed)

RESOLVED FIXED
Tracking Status
b2g-v2.5 --- fixed

People

(Reporter: azasypkin, Assigned: azasypkin)

References

Details

(Keywords: perf, Whiteboard: [sms-sprint-FxOS-S9])

Attachments

(2 files)

Bridge library is huge, so we can reduce memory pressure if we use minimized flavor all over the place and use only "service"/"client" part where only this part is required. First, let's measure how much we can win.
Measurement results are really contradictory, per memory reports (taken with -m), memory occupied by MessagingService shared worker dropped 80kb, shim host iframe dropped (30kb) - this is consistently across all reports. Sometimes this improvement is totally vanished by increased gc/nursery-committed. Raptor results most of the time show that PR makes things worse :) So I tend to think that we should hold on these micro optimizations and wait for the Gecko investigation in bug 1162535. The most variable and unpredictable thing is GC related stuff. @mozilla/raptor@3.2.0 --app sms --runs 10, no workload, before patch | Metric | Mean | Median | Min | Max | StdDev | 95% Bound | | --------------------- | -------- | -------- | ------ | ------ | ------ | --------- | | navigationLoaded | 918.600 | 920 | 883 | 955 | 23.005 | 932.859 | | willRenderThreads | 962.500 | 962.500 | 926 | 1003 | 23.619 | 977.139 | | navigationInteractive | 965.700 | 965.500 | 928 | 1006 | 23.933 | 980.534 | | visuallyLoaded | 1050.600 | 1051.500 | 998 | 1092 | 25.559 | 1066.441 | | fullyLoaded | 1152.200 | 1152.500 | 1096 | 1197 | 27.239 | 1169.083 | | uss | 16.579 | 16.035 | 15.367 | 18.281 | 1.051 | 17.230 | | pss | 20.826 | 20.283 | 19.687 | 22.491 | 1.026 | 21.462 | | rss | 35.725 | 35.284 | 34.539 | 37.285 | 0.963 | 36.322 | @mozilla/raptor@3.2.0 --app sms --runs 10, no workload, after patch | Metric | Mean | Median | Min | Max | StdDev | 95% Bound | | --------------------- | -------- | ------- | ------ | ------ | ------ | --------- | | navigationLoaded | 952.700 | 946 | 902 | 1042 | 35.091 | 974.450 | | willRenderThreads | 994.100 | 989.500 | 944 | 1084 | 34.993 | 1015.789 | | navigationInteractive | 996.900 | 992.500 | 946 | 1087 | 35.132 | 1018.675 | | visuallyLoaded | 1073.900 | 1068 | 1033 | 1169 | 37.109 | 1096.900 | | fullyLoaded | 1168.100 | 1162 | 1121 | 1264 | 36.806 | 1190.913 | | uss | 16.275 | 15.723 | 15.367 | 18.805 | 1.262 | 17.057 | | pss | 20.545 | 20.005 | 19.671 | 23.007 | 1.234 | 21.310 | | rss | 35.423 | 34.898 | 34.535 | 37.809 | 1.194 | 36.164 | @mozilla/raptor@3.2.0 --app sms --runs 10, light workload, before patch | Metric | Mean | Median | Min | Max | StdDev | 95% Bound | | --------------------- | -------- | -------- | ------ | ------ | ------ | --------- | | navigationLoaded | 962.800 | 974.500 | 879 | 1025 | 46.741 | 991.771 | | willRenderThreads | 1013.300 | 1026 | 930 | 1073 | 47.272 | 1042.599 | | navigationInteractive | 1017.100 | 1028.500 | 932 | 1076 | 46.640 | 1046.008 | | visuallyLoaded | 1300.700 | 1306.500 | 1219 | 1366 | 47.191 | 1329.949 | | contentInteractive | 1905.600 | 1904.500 | 1834 | 1968 | 42.107 | 1931.698 | | objectsInitEnd | 1939.600 | 1937 | 1869 | 2005 | 42.554 | 1965.975 | | fullyLoaded | 3493.200 | 3506 | 3416 | 3576 | 51.005 | 3524.814 | | uss | 19.630 | 19.580 | 19.043 | 20.977 | 0.509 | 19.945 | | pss | 24.123 | 24.071 | 23.550 | 25.475 | 0.508 | 24.438 | | rss | 40.074 | 40.022 | 39.488 | 41.418 | 0.507 | 40.389 | @mozilla/raptor@3.2.0 --app sms --runs 10, light workload, after patch | Metric | Mean | Median | Min | Max | StdDev | 95% Bound | | --------------------- | -------- | -------- | ------ | ------ | ------- | --------- | | navigationLoaded | 1008.400 | 1005.500 | 924 | 1071 | 43.914 | 1035.618 | | willRenderThreads | 1059.700 | 1057.500 | 973 | 1124 | 45.409 | 1087.845 | | navigationInteractive | 1062.400 | 1060.500 | 976 | 1126 | 45.118 | 1090.364 | | visuallyLoaded | 1347.700 | 1352 | 1257 | 1407 | 42.797 | 1374.226 | | contentInteractive | 1945.600 | 1951 | 1843 | 2060 | 57.985 | 1981.539 | | objectsInitEnd | 1981.800 | 1985.500 | 1875 | 2096 | 57.986 | 2017.740 | | fullyLoaded | 3576.300 | 3516.500 | 3422 | 3760 | 123.087 | 3652.590 | | uss | 19.851 | 19.613 | 18.945 | 21.500 | 0.897 | 20.407 | | pss | 24.341 | 24.098 | 23.438 | 26.002 | 0.899 | 24.898 | | rss | 40.293 | 40.051 | 39.395 | 41.941 | 0.898 | 40.849 |
Comment on attachment 8678733 [details] [review] [gaia] azasypkin:bug-1218091-bridge-libs > mozilla-b2g:master Numbers are fluctuating, with todays build I see improvement with both about:memory reports and raptor, but looking at StdDev it maybe just a margin of an error. Anyway using smaller flavors of the bridge lib sounds like the right thing to do, Steve what do you think? @mozilla/raptor@3.2.0 --app sms --runs 10, light workload, before patch | Metric | Mean | Median | Min | Max | StdDev | 95% Bound | | --------------------- | -------- | -------- | ------ | ------ | ------ | --------- | | navigationLoaded | 963.600 | 968 | 892 | 1014 | 38.539 | 987.487 | | willRenderThreads | 1016.600 | 1020 | 939 | 1072 | 40.035 | 1041.414 | | navigationInteractive | 1019.600 | 1024 | 942 | 1076 | 40.210 | 1044.522 | | visuallyLoaded | 1315 | 1321 | 1259 | 1360 | 34.540 | 1336.408 | | contentInteractive | 1919.900 | 1918.500 | 1845 | 1972 | 37.112 | 1942.902 | | objectsInitEnd | 1954.200 | 1951 | 1878 | 2005 | 36.094 | 1976.571 | | fullyLoaded | 3586.500 | 3584.500 | 3458 | 3815 | 93.132 | 3644.224 | | uss | 19.732 | 19.576 | 19.359 | 21.035 | 0.485 | 20.033 | | pss | 24.257 | 24.101 | 23.879 | 25.568 | 0.487 | 24.558 | | rss | 40.267 | 40.108 | 39.891 | 41.582 | 0.488 | 40.569 | @mozilla/raptor@3.2.0 --app sms --runs 10 --memory-delay 10000, light workload, before patch | Metric | Mean | Median | Min | Max | StdDev | 95% Bound | | --------------------- | -------- | -------- | ------ | ------ | ------- | --------- | | navigationLoaded | 1015.300 | 1006.500 | 930 | 1148 | 60.721 | 1052.935 | | willRenderThreads | 1067.900 | 1058 | 973 | 1215 | 65.291 | 1108.368 | | navigationInteractive | 1070.900 | 1062.500 | 976 | 1217 | 65.081 | 1111.237 | | visuallyLoaded | 1367.600 | 1356.500 | 1283 | 1522 | 63.802 | 1407.145 | | contentInteractive | 1982.700 | 1963 | 1878 | 2203 | 84.562 | 2035.112 | | objectsInitEnd | 2021.200 | 1998 | 1923 | 2237 | 84.499 | 2073.573 | | fullyLoaded | 3677.300 | 3639.500 | 3506 | 4001 | 138.682 | 3763.256 | | uss | 19.310 | 19.260 | 19.043 | 20.387 | 0.376 | 19.543 | | pss | 23.587 | 23.539 | 23.320 | 24.670 | 0.378 | 23.821 | | rss | 39.845 | 39.793 | 39.586 | 40.926 | 0.377 | 40.079 | @mozilla/raptor@3.2.0 --app sms --runs 10, light workload, after patch | Metric | Mean | Median | Min | Max | StdDev | 95% Bound | | --------------------- | -------- | -------- | ------ | ------ | ------ | --------- | | navigationLoaded | 921.700 | 925.500 | 860 | 1017 | 44.277 | 949.143 | | willRenderThreads | 976.700 | 976 | 908 | 1094 | 49.685 | 1007.495 | | navigationInteractive | 979.500 | 979 | 911 | 1096 | 49.595 | 1010.239 | | visuallyLoaded | 1278.200 | 1267.500 | 1206 | 1373 | 49.091 | 1308.627 | | contentInteractive | 1870.900 | 1852.500 | 1755 | 2059 | 89.787 | 1926.551 | | objectsInitEnd | 1907.800 | 1886.500 | 1792 | 2093 | 90.760 | 1964.054 | | fullyLoaded | 3468.900 | 3465.500 | 3286 | 3623 | 92.358 | 3526.144 | | uss | 19.547 | 19.449 | 18.895 | 21.301 | 0.704 | 19.983 | | pss | 24.078 | 23.984 | 23.421 | 25.829 | 0.705 | 24.514 | | rss | 40.100 | 40.004 | 39.445 | 41.855 | 0.707 | 40.538 | @mozilla/raptor@3.2.0 --app sms --runs 10 --memory-delay 10000, light workload, after patch | Metric | Mean | Median | Min | Max | StdDev | 95% Bound | | --------------------- | -------- | -------- | ------ | ------ | ------ | --------- | | navigationLoaded | 988 | 999.500 | 893 | 1016 | 33.085 | 1008.506 | | willRenderThreads | 1041 | 1051.500 | 945 | 1068 | 33.544 | 1061.791 | | navigationInteractive | 1044.100 | 1054 | 949 | 1070 | 33.201 | 1064.678 | | visuallyLoaded | 1326.200 | 1336.500 | 1238 | 1373 | 33.677 | 1347.073 | | contentInteractive | 1919.500 | 1919 | 1842 | 2021 | 48.071 | 1949.295 | | objectsInitEnd | 1955.100 | 1951 | 1884 | 2057 | 46.522 | 1983.935 | | fullyLoaded | 3569.400 | 3530 | 3491 | 3753 | 82.411 | 3620.479 | | uss | 19.230 | 19.183 | 18.898 | 20.199 | 0.343 | 19.443 | | pss | 23.514 | 23.466 | 23.179 | 24.493 | 0.346 | 23.729 | | rss | 39.794 | 39.746 | 39.457 | 40.777 | 0.348 | 40.010 |
Attachment #8678733 - Flags: feedback?(schung)
Comment on attachment 8678733 [details] [review] [gaia] azasypkin:bug-1218091-bridge-libs > mozilla-b2g:master Although it didn't improve memory consumption a lot as expected, I think it's good move that we should use optimized libs eventually. Just a question about the window context: Maybe we can simply use client.js instead of bridge.js? It seems not possible to have service in window context, but maybe I'm wrong.
Attachment #8678733 - Flags: feedback?(schung) → feedback+
(In reply to Steve Chung [:steveck] from comment #4) > Comment on attachment 8678733 [details] [review] > [gaia] azasypkin:bug-1218091-bridge-libs > mozilla-b2g:master > > Although it didn't improve memory consumption a lot as expected, I think > it's good move that we should use optimized libs eventually. Thanks for the feedback > Just a question > about the window context: Maybe we can simply use client.js instead of > bridge.js? It seems not possible to have service in window context, but > maybe I'm wrong. There is one exception - ActivityShim that is hosted in window context, but anyway I'll check if I can do anything with it.
Depends on: 1219264
I'm holding on r? request until I get new raptor numbers considering bug 1219301
Comment on attachment 8678733 [details] [review] [gaia] azasypkin:bug-1218091-bridge-libs > mozilla-b2g:master Okay here is the data: raptor test coldlaunch --app sms --runs 30 (raptor@3.3.1) Base) Master | Metric | Mean | Median | Min | Max | StdDev | 95% Bound | | --------------------- | -------- | -------- | ------ | ------ | ------ | --------- | | navigationLoaded | 937.300 | 937.500 | 843 | 1027 | 42.597 | 952.543 | | willRenderThreads | 984.267 | 984 | 887 | 1086 | 45.226 | 1000.451 | | navigationInteractive | 987.067 | 986.500 | 889 | 1089 | 45.533 | 1003.360 | | visuallyLoaded | 1280.633 | 1284.500 | 1175 | 1372 | 45.812 | 1297.027 | | contentInteractive | 1845.667 | 1838.500 | 1713 | 1952 | 48.397 | 1862.985 | | objectsInitEnd | 1882 | 1874.500 | 1747 | 1987 | 47.573 | 1899.024 | | fullyLoaded | 3464.467 | 3445.500 | 3324 | 3777 | 88.698 | 3496.207 | | uss | 19.619 | 19.297 | 18.707 | 21.664 | 0.935 | 19.953 | | pss | 24.037 | 23.706 | 23.134 | 26.069 | 0.934 | 24.372 | | rss | 39.769 | 39.443 | 38.867 | 41.809 | 0.935 | 40.104 | 1) PR based on Master | Metric | Mean | Median | Min | Max | StdDev | 95% Bound | | --------------------- | -------- | -------- | ------ | ------ | ------ | --------- | | navigationLoaded | 964.500 | 963 | 855 | 1050 | 42.837 | 979.829 | | willRenderThreads | 1014 | 1015 | 903 | 1107 | 44.355 | 1029.872 | | navigationInteractive | 1016.833 | 1017.500 | 906 | 1111 | 44.592 | 1032.790 | | visuallyLoaded | 1304.700 | 1306 | 1201 | 1404 | 43.709 | 1320.341 | | contentInteractive | 1864.467 | 1859 | 1748 | 1978 | 41.113 | 1879.179 | | objectsInitEnd | 1900.933 | 1895.500 | 1780 | 2012 | 40.633 | 1915.474 | | fullyLoaded | 3484.433 | 3483.500 | 3280 | 3682 | 85.632 | 3515.077 | | uss | 19.288 | 19.072 | 18.680 | 21.234 | 0.767 | 19.563 | | pss | 23.701 | 23.486 | 23.101 | 25.638 | 0.766 | 23.975 | | rss | 39.435 | 39.221 | 38.832 | 41.379 | 0.766 | 39.709 | Raptor compare sms.gaiamobile.org base: mean 1: mean 1: delta 1: p-value --------------------- ---------- ------- -------- ---------- navigationLoaded 938 965 26 0.06 willRenderThreads 986 1014 28 0.05 navigationInteractive 989 1017 28 0.05 visuallyLoaded 1289 1305 15 0.29 contentInteractive 1858 1864 7 0.68 objectsInitEnd 1894 1901 7 0.67 fullyLoaded 3469 3484 15 0.52 uss 19.591 19.288 -0.303 0.17 pss 24.013 23.701 -0.312 0.16 rss 39.778 39.435 -0.342 0.12 Even that p-value is not that great, still I've tried to run raptor several times and always see ~180-300 KB improvement, so asking for review here :) Visually loaded and fullyLoaded times look like affected a bit, but p-value is even more bigger there so not sure if it makes any sense.
Attachment #8678733 - Flags: review?(schung)
(In reply to Oleg Zasypkin [:azasypkin][⏰UTC+1] from comment #7) > Comment on attachment 8678733 [details] [review] > Visually loaded and fullyLoaded times look like affected a bit, but p-value > is even more bigger there so not sure if it makes any sense. It's really weird because the only things that might affect visually loaded is replacing the bridge with optimized client. I will also profile this part as well.
The solution looks fine, just some thought: I think we might still need the original libs for debugging or something. I think we can have both version of libs and utilized the build.js to replace lib with optimized version only when GAIA_OPTIMIZE === 1, wdyt?
(In reply to Steve Chung [:steveck] from comment #9) > The solution looks fine, just some thought: I think we might still need the > original libs for debugging or something. I think we can have both version > of libs and utilized the build.js to replace lib with optimized version only > when GAIA_OPTIMIZE === 1, wdyt? Hmm, let me check if it's easy to swap files at the build step. We likely don't want to change paths to the bridge libs (as we have them in all index.html files + shim host + services).
Comment on attachment 8678733 [details] [review] [gaia] azasypkin:bug-1218091-bridge-libs > mozilla-b2g:master Thanks for the quick adding the both version and ability for switching between them. Just a small question about the Bug 1219264 but I think we can land this one first.
Attachment #8678733 - Flags: review?(schung) → review+
BTW there bunch of broken unit tests on treeherder. Maybe we need rebase first.
(In reply to Steve Chung [:steveck] from comment #12) > BTW there bunch of broken unit tests on treeherder. Maybe we need rebase > first. Thanks for review! Yep, just pushed rebased PR, waiting for the green Treeherder.
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Comment on attachment 8678733 [details] [review] [gaia] azasypkin:bug-1218091-bridge-libs > mozilla-b2g:master [Approval Request Comment] [Bug caused by] (feature/regressing bug #): n/a [User impact] if declined: +0.2MB of memory will be consumed on app startup [Testing completed]: yes, manual + we have integration test for the affected functionality. [Risk to taking this patch] (and alternatives if risky): low [String changes made]: n/a
Attachment #8678733 - Flags: approval-gaia-v2.5?
No longer depends on: 1219264
Comment on attachment 8678733 [details] [review] [gaia] azasypkin:bug-1218091-bridge-libs > mozilla-b2g:master Approved for 2.5 uplift. Thanks
Attachment #8678733 - Flags: approval-gaia-v2.5? → approval-gaia-v2.5+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: