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

kotlinx-serialization-runtime-js.js from 0.11.0 is not processed correctly with DCE #430

Closed
rjaros opened this issue Apr 13, 2019 · 6 comments

Comments

@rjaros
Copy link

rjaros commented Apr 13, 2019

The kotlinx-serialization-runtime-js.js file from 0.11.0 is not reduced enough when DCE tool from Kotlin 1.3.30 is used, even when no serialization is used. The file is reduced from 420KB to 165KB. In 0.10.0 (with Kotlin 1.3.21) the same file is reduced from 374KB to 9KB. This has impact on the size of the output files for Kotlin/JS apps, if the kotlinx.serialization library is present in the sub dependencies, but no serialization features are used.
You can see the sample application here: https://github.com/rjaros/js-dce (this is the official js-dce example updated to the current Kotlin version). After running: ./gradlew build the file build/kotlin-js-min/main/kotlinx-serialization-runtime-js.js is 165KB. When downgrading to Kotlin 1.3.21 and serialization 0.10.0 the same file is 9KB.

@sandwwraith
Copy link
Member

Your comparison is not very fair since the attached project does not use the library at all, it only includes dependency on it. After adding to Hello.kt some meaningful code (serialization/deserialization of simple data class with Int and String fields), numbers become different:

1.3.21:

total 4080
6.6K kotlin-dce-example.js
243K kotlin.js
1.2M kotlin.js.map
201K kotlinx-serialization-runtime-js.js
302K kotlinx-serialization-runtime-js.js.map

1.3.30:

total 5296
6.6K kotlin-dce-example.js
251K kotlin.js
1.3M kotlin.js.map
254K kotlinx-serialization-runtime-js.js
806K kotlinx-serialization-runtime-js.js.map

The difference is about 50K on runtime + 10K on additional declarations from stdlib (kotlin.js)

However, this result can indeed be improved, and we'll continue working on library optimization for DCE.

@rjaros
Copy link
Author

rjaros commented Apr 29, 2019

Isn't the main purpose of DCE just to remove the unused code? :-)

@sandwwraith
Copy link
Member

There are some top-level declarations that would be used anyway

@rjaros
Copy link
Author

rjaros commented Apr 29, 2019

Obviously there must be some differences between 0.10.0 and 0.11.0, but of course it is up to you to decide if it's a bug or whether there is some justification.

@sandwwraith
Copy link
Member

Yes, of course, there are some differences – new functionality has been added, and it affected default json instances as well.

@qwwdfsad
Copy link
Contributor

qwwdfsad commented Jul 7, 2020

Closing as obsolete

@qwwdfsad qwwdfsad closed this as completed Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants