-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
CMP-5906 Add option to enable Class data sharing (CDS) #2080
base: master
Are you sure you want to change the base?
Conversation
6e98378
to
b43a7c0
Compare
It will be great to have this feature. @AlexeyTsvetkov, could you look at the PR? |
AppCDS makes starting up Compose Desktop applications muuuuuch faster. |
For readers who want to enable CDS Today, here's a dirty workaround: afterEvaluate {
tasks.named<AbstractJLinkTask>("createRuntimeImage") {
freeArgs.addAll("--generate-cds-archive")
val stripNativeCommands = this::class.java.methods
.single { it.name.startsWith("getStripNativeCommands") }
.invoke(this) as Property<Boolean>
stripNativeCommands.set(false)
doLast {
destinationDir.get().dir("bin").asFile
.walkBottomUp()
// Windows JVM has its .ddl files in bin/
.filter { it.isFile && it.extension != "dll" }
.forEach { check(it.delete()) { "Unable to delete $it" } }
}
}
} |
Nice, I am curious what AppCDS could do for a compose app in addition to CDS. |
I got AppCDS working on top of CDS. I did not measure precisely but it feels snappier. compose.desktop {
application {
nativeDistributions {
jvmArgs += "-Xlog:cds=error" // change to 'debug' to get more info
jvmArgs += "-Xshare:auto"
jvmArgs += "-XX:+AutoCreateSharedArchive"
jvmArgs += "-XX:SharedArchiveFile=path/to/app-cds.jsa"
}
}
} One painful thing is that you need to provide a path relative the the JVM working directory for the jsa file. |
I just gave it a try, and it seems to generate the app-cds.jsa as expected. However, the first startup is now very slow, so that is pretty bad. I guess it would be better to somehow generate this file in the gradle plugin automatically and include it at build time. (see PR description for more info) |
Hi @igordmn, could you please review this or assign it to the correct person? |
CMP-5906 Add option to enable Class data sharing (CDS)
Alternatively this could be enabled by default, what do you think?
This PR adds an option for CDS, not for AppCDS.
AppCDS is probably not worth it. Generating it at first startup slows down the startup. So it should probably be generated at install time somehow (not sure if even possible, and would take too much time). Generating it at build time in this gradle plugin would be another option (which I think is best), but that would increase app size. AppCDS would require more investigation before adding it. I think what would be ideal, is that the gradle plugin would launch the app in the background when building, and maybe run some sort of compose test to warm up code. Then exit and include the generated file in the archive. Does this make sense?