Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): Optimize size of WASM library #12786

Open
ermshiperete opened this issue Dec 5, 2024 · 2 comments
Open

chore(core): Optimize size of WASM library #12786

ermshiperete opened this issue Dec 5, 2024 · 2 comments
Labels
chore core/ Keyman Core
Milestone

Comments

@ermshiperete
Copy link
Contributor

ermshiperete commented Dec 5, 2024

Related-to: #11293

@ermshiperete ermshiperete added this to the 19.0 milestone Dec 5, 2024
@keymanapp-test-bot keymanapp-test-bot bot added chore core/ Keyman Core labels Dec 5, 2024
@ermshiperete
Copy link
Contributor Author

ermshiperete commented Dec 5, 2024

From slack:

eberhard 4-DEC 2024
In standup you mentioned the .wasm file on master being 8M. Where do you see that? I don't see a Core API related .wasm file. The only file I see is util_normalize_table_generator.wasm which is 3.8M.

marc
It's the src/libkeymancore.a file that is generated -- a WASM library:

$ ls -l core/build/wasm/release/src/
total 11464
-rw-r--r-- 1 marc 197609 7532488 Dec  4 13:13 libkeymancore.a

Admittedly being a lib file it's bigger than the final linked wasm will be, but it's a sign of bloat 🙂

eberhard
Here's the content of the .a file:

==> (lesspipe 2.12) use archive_file:contained_file to view a file in the archive
rw-r--r-- 0/0  29425 Jan  1 01:00 1970 km_core_action_api.cpp.o
rw-r--r-- 0/0 157130 Jan  1 01:00 1970 km_core_context_api.cpp.o
rw-r--r-- 0/0 244289 Jan  1 01:00 1970 km_core_keyboard_api.cpp.o
rw-r--r-- 0/0 152073 Jan  1 01:00 1970 km_core_options_api.cpp.o
rw-r--r-- 0/0 369196 Jan  1 01:00 1970 km_core_state_api.cpp.o
rw-r--r-- 0/0  27306 Jan  1 01:00 1970 km_core_debug_api.cpp.o
rw-r--r-- 0/0  81443 Jan  1 01:00 1970 km_core_processevent_api.cpp.o
rw-r--r-- 0/0 179749 Jan  1 01:00 1970 action.cpp.o
rw-r--r-- 0/0  34705 Jan  1 01:00 1970 option.cpp.o
rw-r--r-- 0/0 182756 Jan  1 01:00 1970 keyboard.cpp.o
rw-r--r-- 0/0 265964 Jan  1 01:00 1970 state.cpp.o
rw-r--r-- 0/0 147831 Jan  1 01:00 1970 jsonpp.cpp.o
rw-r--r-- 0/0  21433 Jan  1 01:00 1970 .._.._common_cpp_utfcodec.cpp.o
rw-r--r-- 0/0 121405 Jan  1 01:00 1970 actions_normalize.cpp.o
rw-r--r-- 0/0  24686 Jan  1 01:00 1970 context_helpers.cpp.o
rw-r--r-- 0/0 144262 Jan  1 01:00 1970 debuglog.cpp.o
rw-r--r-- 0/0   1403 Jan  1 01:00 1970 vkey_to_contextreset.cpp.o
rw-r--r-- 0/0  79838 Jan  1 01:00 1970 km_core_state_context_set_if_needed.cpp.o
rw-r--r-- 0/0 250000 Jan  1 01:00 1970 util_normalize.cpp.o
rw-r--r-- 0/0 183323 Jan  1 01:00 1970 util_regex.cpp.o
rw-r--r-- 0/0    255 Jan  1 01:00 1970 core_icu.cpp.o
rw-r--r-- 0/0 544489 Jan  1 01:00 1970 ldml_ldml_processor.cpp.o
rw-r--r-- 0/0 1226703 Jan  1 01:00 1970 ldml_ldml_transforms.cpp.o
rw-r--r-- 0/0 368379 Jan  1 01:00 1970 ldml_ldml_markers.cpp.o
rw-r--r-- 0/0 193950 Jan  1 01:00 1970 ldml_ldml_vkeys.cpp.o
rw-r--r-- 0/0 492895 Jan  1 01:00 1970 mock_mock_processor.cpp.o
rw-r--r-- 0/0  22067 Jan  1 01:00 1970 kmx_kmx_consts.cpp.o
rw-r--r-- 0/0 167914 Jan  1 01:00 1970 kmx_kmx_processevent.cpp.o
rw-r--r-- 0/0  26050 Jan  1 01:00 1970 kmx_kmx_actions.cpp.o
rw-r--r-- 0/0  27591 Jan  1 01:00 1970 kmx_kmx_capslock.cpp.o
rw-r--r-- 0/0  92238 Jan  1 01:00 1970 kmx_kmx_context.cpp.o
rw-r--r-- 0/0  23064 Jan  1 01:00 1970 kmx_kmx_conversion.cpp.o
rw-r--r-- 0/0  65865 Jan  1 01:00 1970 kmx_kmx_debugger.cpp.o
rw-r--r-- 0/0 118212 Jan  1 01:00 1970 kmx_kmx_environment.cpp.o
rw-r--r-- 0/0  34092 Jan  1 01:00 1970 kmx_kmx_file.cpp.o
rw-r--r-- 0/0  24702 Jan  1 01:00 1970 kmx_kmx_modifiers.cpp.o
rw-r--r-- 0/0 181526 Jan  1 01:00 1970 kmx_kmx_options.cpp.o
rw-r--r-- 0/0 413633 Jan  1 01:00 1970 kmx_kmx_plus.cpp.o
rw-r--r-- 0/0 548484 Jan  1 01:00 1970 kmx_kmx_processor.cpp.o
rw-r--r-- 0/0 161687 Jan  1 01:00 1970 kmx_kmx_xstring.cpp.o

The biggest chunk is ldml_ldml_transforms.cpp.o with 1.2M, followed by kmx_kmx_processor.cpp.o and ldml_ldml_processor.cpp.o with 540k each.
We probably don't need mock_mock_processor.cpp.o (490k) to be included.
We might want to split this into 3 (or 4) libraries: Core, KMX, LDML (and Mock). That way we can load only what's needed.

@mcdurdin
Copy link
Member

mcdurdin commented Dec 6, 2024

Good start on analysis! This will be helpful when we come to the tree-shaking and optimization of the core wasm work, multiple libraries may well be the best way forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore core/ Keyman Core
Projects
Status: No status
Development

No branches or pull requests

2 participants