sdeleuze
12/30/2023, 8:12 AMStringFormat.encodeToString adds 442K (60K to 502K)
• Deserialization with decodeFromString adds 604K (60K to 664K)
Given Kotlin Serialization compile-time step and Bynarien Dead Code Elimination capabilities, I am a bit frustrated by this footprint which may be ok-ish for wasmWasi but not for wasmJs, and suspect there may be optimizaton to be made here that could be beneficial to both.
Any thoughts on if this is due to Kotlin/Wasm generating suboptimal bytecode that does not allow dead code elimination, or if there is more something to do on Kotlin Serialization side (potentialy in the plugin) to make some code unreachable and allow more aggressive optimizations?
I see some mentions of Coroutines in the .map file, and I know it has not a small cost in terms of footprint and wonder if we could get rid of it for such simple use case.
The related branch is available here.Arjan van Wieringen
12/30/2023, 11:04 AMSvyatoslav Kuzmich [JB]
12/30/2023, 12:49 PM$ ./gradlew :compileProductionExecutableKotlinWasmWasiOptimize
$ ls -lhS build/compileSync/wasmWasi/main/productionExecutable/optimized/add-wasm-wasi.wasm
As for coroutines, as far as I see it uses coroutines-based DeepRecursiveFunction from standard library to implement deep JSON generation using recursion. I don’t know how much footprint it brings in particular. It does not depend on kotlinx.coroutines library (you would see kotlinx.coroutines pacakges in .map files instead of small stdlib kotlin.coroutines )sdeleuze
12/30/2023, 12:55 PMSvyatoslav Kuzmich [JB]
12/30/2023, 12:59 PM*Distibution task in wasmJs, and it would include optimized version, but it is missing in wasmWasi. KGP for wasmWasi needs some love.sdeleuze
12/30/2023, 1:04 PMwasmJs and wasmWasi with the regular production/distribution tasks (without the additional optimized directory).Svyatoslav Kuzmich [JB]
12/30/2023, 1:07 PMwasmWasi problem is that :compileProductionExecutableKotlinWasmWasiOptimize and build/compileSync are designed to be internal, intermediate things, and not a part of developer UX.