Java 10 ã® Class Data Sharing ã§ãSpring Boot ã®èµ·åãéããã¦ã¿ã¾ãã
Class Data Sharing ã¯ç°ãªãJVMä¸ã§åä¸ã®ã¯ã©ã¹ã®æ å ±ãå ±æããä»çµã¿ã§ãã Java 8 ã®æç¹ã§ãã§ã«çµã¿è¾¼ã¾ãã¦ãã¾ããããã³ãã¼ã·ã£ã«ãªæ©è½ã§ãã£ãããã 使ã£ã¦ãã人ã¯å°ãªãã¨æãã¾ãã Java 10 ããã¯ãã®æ©è½ã OpenJDK ã§ãå©ç¨ã§ããããã«ãªã£ããããæ©é試ãã¦ã¿ããã¨æãã¾ãã
SpringãBoot ã¢ããªã±ã¼ã·ã§ã³
å®è¡å¯¾è±¡ã¨ããã¢ããªã±ã¼ã·ã§ã³ãä½ãããã«æ¬¡ã®ã³ãã³ãã§ããã¸ã§ã¯ããä½ãã¾ã
gradle init --type=java-library curl https://start.spring.io/build.gradle \ -d dependencies=webflux,actuator,data-jpa,thymeleaf,\ validation,data-redis-reactive,flyway,retry,\ statemachine,mail,h2 > build.gradle
次ã«æ¬¡ã®ãããªã¡ã¤ã³ã¯ã©ã¹ãä½ãã¾ãã
@SpringBootApplication public class App { public static void main(String... args) { SpringApplication.run(App.class, args); } @Bean CommandLineRunner commandLineRunner() { return args -> {}; } private final Foo foo; App(final Foo foo) { this.foo = foo; } public static class Foo {} }
JVMã®èµ·åæéã ããä»ã¯å¿ è¦ãªã®ã§ãSpringã®Beanèªã¿è¾¼ã¿ãå§ã¾ã£ããããã«è½ã¡ãã¡ã¤ã³ã¯ã©ã¹ã«ãªã£ã¦ãã¾ãã
Spring Boot ã¢ããªã±ã¼ã·ã§ã³ã®èµ·å
Spring Boot ã¢ããªã±ã¼ã·ã§ã³ãèµ·åãããã®ã§ããã gradle ã®Â bootRun
ã¿ã¹ã¯ã« jvm ãã©ã¡ã¼ã¿ã¼ãæå®ããæ¹æ³ã§ããã¨ã Class Data ã®ã¢ã¼ã«ã¤ããã£ã¬ã¯ããªã¼ããã¾ãèªèãããªãã£ãã®ã§ã bootJar
ã§ä½æãã jar ãã¡ã¤ã«ã JavaExec
ã¿ã¹ã¯ã§èµ·åãã¾ãã
task createCdsDirectory { outputs.dir(cdsDirectory) doLast { if (!cdsDirectory.exists()) { cdsDirectory.mkdirs() } } } task runBootJar(type: JavaExec) { main = 'org.springframework.boot.loader.JarLauncher' dependsOn bootJar classpath bootJar def create = false if (project.hasProperty('listApp')) { jvmArgs = ['-XX:+UnlockCommercialFeatures', '-Xshare:off', "-XX:DumpLoadedClassList=${classList}", '-XX:+UseAppCDS'] create = true } else if (project.hasProperty('dumpApp')) { jvmArgs = ['-XX:+UnlockCommercialFeatures', '-Xshare:dump', "-XX:SharedClassListFile=${classList}", '-XX:+UseAppCDS', "-XX:SharedArchiveFile=${archiveFile}"] create = true } else if (project.hasProperty('runApp')) { jvmArgs = ['-XX:+UnlockCommercialFeatures', '-Xshare:on', '-XX:+UseAppCDS', "-XX:SharedArchiveFile=${archiveFile}"] } if (create) { dependsOn createCdsDirectory, showStartTime } else { dependsOn showStartTime } finalizedBy showEndTime }
Class Data Sharing ã使ãå ´åã次ã®3ã¤ã®ãã§ã¼ãºããããããããã§å¥ã®ãã©ã¡ã¼ã¿ã¼ãå¿ è¦ã¨ãã¾ãã
ã¢ã¼ã«ã¤ã対象ãªã¹ããåå¾
-XX:+UnlockCommercialFeatures
-XX:+UseAppCDS
-Xshare:off
-XX:DumpLoadedClassList=${classList}
ã¢ã¼ã«ã¤ããã¡ã¤ã«ãåå¾
-XX:+UnlockCommercialFeatures
-XX:+UseAppCDS
-Xshare:dump
-XX:SharedClassListFile=${classList}
-XX:SharedArchiveFile=${archiveFile}
ã¢ã¼ã«ã¤ããã¡ã¤ã«ãèªã¿ããã§ã¢ããªã±ã¼ã·ã§ã³ãèµ·åãã
-XX:+UnlockCommercialFeatures
-XX:+UseAppCDS
-Xshare:on
-XX:SharedArchiveFile=${archiveFile}
ããã§ã¯ã gradle ã®ããããã£å¤ã®æç¡ã§èµ·åãªãã·ã§ã³ãå¤æ´ããå½¢ã§èµ·åãã¾ãã
ã¾ããå®è¡æéãè¨æ¸¬ããç¨éã¨ãã¦æ¬¡ã®äºã¤ã®ã¿ã¹ã¯ãä½ãã¾ãã
task showStartTime(group: 'show-time') { doLast { def now = LocalDateTime.now() startTime << now logger.lifecycle('start {}', now.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)) } } task showEndTime(group: 'show-time') { doLast { def now = LocalDateTime.now() if (!startTime.empty) { LocalDateTime start = startTime[0] logger.lifecycle('start {}', start.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)) logger.lifecycle('end {}', now.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)) def duration = Duration.between(start, now) logger.lifecycle('time: {} ms', duration.toMillis()) } } }
Class Data Sharing ã使ããªãå ´å
Class Data Sharing ã使ããªãå ´åã®èµ·åæéã確èªãã¾ãã
$ ./gradlew clean runBootJar > Task :showStartTime start 2018-04-01T19:41:48.800745 > Task :runBootJar . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.0.RELEASE) 2018-04-01 19:41:55.441 INFO 8454 --- [ main] com.example.App : Starting App on mac.local with PID 8454 (/path/to/project/build/libs/spring-app-cds-sample-0.0.1-SNAPSHOT.jar started by mike in /path/to/project) 2018-04-01 19:41:55.447 INFO 8454 --- [ main] com.example.App : No active profile set, falling back to default profiles: default ... ä¸ç¥ *************************** APPLICATION FAILED TO START *************************** Description: Parameter 0 of constructor in com.example.App required a bean of type 'com.example.App$Foo' that could not be found. Action: Consider defining a bean of type 'com.example.App$Foo' in your configuration. > Task :showEndTime start 2018-04-01T19:41:48.800745 end 2018-04-01T19:41:59.122787 time: 10322 ms ... 以ä¸çç¥
JVMèµ·åéå§ â ã¯ã©ã¹ãã¼ãå®äº â Spring Boot ã¢ããªã±ã¼ã·ã§ã³ã®èµ·å â Spring Boot ã¢ããªã±ã¼ã·ã§ã³ã®çµäº ã®ä¸é£ã®æµã㧠10322
ms ã»ã©ãããã¾ããã
Class Data Sharing ã使ãå ´å
ã¯ã©ã¹ãªã¹ãã®åå¾
æåã«ã¢ã¼ã«ã¤ã対象ã®ã¯ã©ã¹ããªã¹ãåãã¾ãã
$ ./gradlew runBootJar -PlistApp > Task :showStartTime start 2018-04-01T19:32:34.882318 > Task :runBootJar skip writing class com/sun/proxy/$Proxy0 from source __JVM_DefineClass__ to classlist file skip writing class com/sun/proxy/$Proxy1 from source __JVM_DefineClass__ to classlist file skip writing class com/sun/proxy/$Proxy2 from source __JVM_DefineClass__ to classlist file skip writing class com/sun/proxy/$Proxy3 from source __JVM_DefineClass__ to classlist file skip writing class com/sun/proxy/$Proxy9 from source __JVM_DefineClass__ to classlist file skip writing class com/sun/proxy/jdk/proxy1/$Proxy11 from source __JVM_DefineClass__ to classlist file skip writing class java/lang/invoke/BoundMethodHandle$Species_LII from source __JVM_DefineClass__ to classlist file skip writing class java/lang/invoke/BoundMethodHandle$Species_LIIL from source __JVM_DefineClass__ to classlist file skip writing class java/lang/invoke/BoundMethodHandle$Species_LIILL from source __JVM_DefineClass__ to classlist file skip writing class java/lang/invoke/BoundMethodHandle$Species_LIILLL from source __JVM_DefineClass__ to classlist file . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.0.RELEASE) 2018-04-01 19:32:41.717 INFO 8413 --- [ main] com.example.App : Starting App on mac.local with PID 8413 (/path/to/paroject/build/libs/spring-app-cds-sample-0.0.1-SNAPSHOT.jar started by mike in /path/to/project) 2018-04-01 19:32:41.725 INFO 8413 --- [ main] com.example.App : No active profile set, falling back to default profiles: default skip writing class com/sun/proxy/$Proxy13 from source __JVM_DefineClass__ to classlist file skip writing class com/sun/proxy/$Proxy24 from source __JVM_DefineClass__ to classlist file 2018-04-01 19:32:41.853 INFO 8413 --- [ main] onfigReactiveWebServerApplicationContext : Refreshing org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext@1139b2f3: startup date [Sun Apr 01 19:32:41 JST 2018]; root of context hierarchy skip writing class java/lang/invoke/BoundMethodHandle$Species_LLLII from source __JVM_DefineClass__ to classlist file skip writing class java/lang/invoke/BoundMethodHandle$Species_LLLIIL from source __JVM_DefineClass__ to classlist file skip writing class java/lang/invoke/BoundMethodHandle$Species_LLLIILL from source __JVM_DefineClass__ to classlist file skip writing class java/lang/invoke/BoundMethodHandle$Species_LLLIILLL from source __JVM_DefineClass__ to classlist file skip writing class java/lang/invoke/BoundMethodHandle$Species_LLLIILLLL from source __JVM_DefineClass__ to classlist file ... ä¸ç¥ > Task :showEndTime start 2018-04-01T19:32:34.882318 end 2018-04-01T19:32:45.295433 time: 10413 ms ... 以ä¸çç¥
ããã«ãã£ã¦ã次ã®ãããªããã¹ããã¡ã¤ã«ãä½æããã¾ãã(ãã®ãµã³ãã«ã§ã¯ build/cds/list.txt
ãä½æããã)
$ head -10 build/cds/list.txt java/lang/Object java/lang/String java/io/Serializable java/lang/Comparable java/lang/CharSequence java/lang/Class java/lang/reflect/GenericDeclaration java/lang/reflect/AnnotatedElement java/lang/reflect/Type java/lang/Cloneable $ grep spring build/cds/list.txt | head -10 org/springframework/boot/loader/JarLauncher org/springframework/boot/loader/ExecutableArchiveLauncher org/springframework/boot/loader/Launcher org/springframework/boot/loader/LaunchedURLClassLoader org/springframework/boot/loader/archive/Archive org/springframework/boot/loader/archive/JarFileArchive org/springframework/boot/loader/jar/JarFile org/springframework/boot/loader/jar/CentralDirectoryVisitor org/springframework/boot/loader/data/RandomAccessData org/springframework/boot/loader/jar/FileHeader
ããããã¼ããããããªããããªã¯ã©ã¹ãããå ´åã¯ããã®ãªã¹ãããåãé¤ãã¾ãã
ãªã¹ããåå¾ããå¦çãå ¥ãå ´åã¯ããã¼ããããã¯ã©ã¹ã®ã¹ãã£ã³ãã³ã°ãå ¥ããããè¥å¹²å¦çãé ããªãã¾ãã
ã¢ã¼ã«ã¤ããã¡ã¤ã«ã®åå¾
次ã«ã¢ã¼ã«ã¤ããã¡ã¤ã«ãåå¾ãã¾ãããã®ã¨ãã® java
ãã³ãã³ãã¯ã¢ããªã±ã¼ã·ã§ã³ãèµ·åãã¾ããã
$ ./gradlew runBootJar -PdumpApp > Task :showStartTime start 2018-04-01T20:08:10.186895 > Task :runBootJar narrow_klass_base = 0x0000000800000000, narrow_klass_shift = 3 Allocated temporary class space: 1073741824 bytes at 0x00000008c0000000 Allocated shared space: 3221225472 bytes at 0x0000000800000000 Loading classes to share ... Loading classes to share: done. Rewriting and linking classes ... Rewriting and linking classes: done Number of classes 2131 instance classes = 2053 obj array classes = 70 type array classes = 8 Updating ConstMethods ... done. Removing unshareable information ... done. Scanning all metaspace objects ... Allocating RW objects ... Allocating RO objects ... Relocating embedded pointers ... Relocating external roots ... Dumping symbol table ... Dumping String objects to closed archive heap region ... Dumping objects to open archive heap region ... Relocating SystemDictionary::_well_known_klasses[] ... Removing java_mirror ... done. mc space: 8536 [ 0.0% of total] out of 12288 bytes [ 69.5% used] at 0x0000000800000000 rw space: 5943264 [ 19.0% of total] out of 5943296 bytes [100.0% used] at 0x0000000800003000 ro space: 11971160 [ 38.4% of total] out of 11972608 bytes [100.0% used] at 0x00000008005ae000 md space: 6160 [ 0.0% of total] out of 8192 bytes [ 75.2% used] at 0x0000000801119000 od space: 11275744 [ 36.1% of total] out of 11276288 bytes [100.0% used] at 0x000000080111b000 st0 space: 835584 [ 2.7% of total] out of 835584 bytes [100.0% used] at 0x00000007bfe00000 st1 space: 1048576 [ 3.4% of total] out of 1048576 bytes [100.0% used] at 0x00000007bff00000 oa0 space: 102400 [ 0.3% of total] out of 102400 bytes [100.0% used] at 0x00000007bfd00000 total : 31191424 [100.0% of total] out of 31199232 bytes [100.0% used] > Task :showEndTime start 2018-04-01T20:08:10.186895 end 2018-04-01T20:08:11.906736 time: 1719 ms BUILD SUCCESSFUL in 4s 6 actionable tasks: 3 executed, 3 up-to-date
ããã«ãã£ã¦ãã¢ã¼ã«ã¤ããã¡ã¤ã«ãä½ããã¾ã(ãã®ä¾ã§ã¯ build/cds/app.jsa
)ãã¾ãããã°ã®æå³ãæåéãã«è§£éãããªãã 2131
åã®ã¯ã©ã¹ãã¢ã¼ã«ã¤ããããããã§ããå®éã«ãã¡ã¤ã«ã確èªãã¦ã¿ã¾ãã
$ ls -l build/cds/ total 61080 -r--r--r--+ 1 mike staff 31203328 4 1 20:08 app.jsa -rw-r--r--+ 1 mike staff 69515 4 1 19:54 list.txt
ã¢ã¼ã«ã¤ããã¡ã¤ã«ãèªã¿è¾¼ãã§ã¢ããªã±ã¼ã·ã§ã³ãèµ·åãã
ã§ã¯ãä½æããã¢ã¼ã«ã¤ããã¡ã¤ã«ã使ã£ã¦ã Spring Boot ã¢ããªã±ã¼ã·ã§ã³ãèµ·åãã¦ã¿ã¾ãã
$ ./gradlew runBootJar -PrunApp Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8 > Task :showStartTime start 2018-04-01T20:11:56.633207 > Task :runBootJar . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.0.RELEASE) 2018-04-01 20:12:03.401 INFO 8564 --- [ main] com.example.App : Starting App on mac.local with PID 8564 (/path/to/project/build/libs/spring-app-cds-sample-0.0.1-SNAPSHOT.jar started by mike in /path/to/project) 2018-04-01 20:12:03.409 INFO 8564 --- [ main] com.example.App : No active profile set, falling back to default profiles: default ... ä¸ç¥ > Task :showEndTime start 2018-04-01T20:11:56.633207 end 2018-04-01T20:12:06.830557 time: 10197 ms ... 以ä¸çç¥
å
¨ä½ã®æé㯠10197
ms ã¨ãªããæå®ããªãã£ãã¨ã(10322
ms)ã«æ¯ã¹ã¦ã 125
ms ã»ã©éããªãã¾ããï¼â¦ãããããããã誤差ã§ãããâ¦ï¼ï¼ï¼ï¼ï¼
åé¡ã¨è§£æ±º
ãã¦ãèµ·åæéãã»ã¨ãã©å¤ãããªãçç±ãèãã¾ããå
ã»ã©ã® list.txt
ãããè¦ã¦ã¿ã¾ãã
org/springframework/boot/loader/JarLauncher org/springframework/boot/loader/ExecutableArchiveLauncher org/springframework/boot/loader/Launcher
ã¨ãã£ãã¯ã©ã¹ãã¢ã¼ã«ã¤ãããã¦ãã¾ãããããããè¦ã¦ãããããããã¾ãããã bootJar
ã«ãã£ã¦çæããã jar ãã¡ã¤ã«ã¯ä¸è¬ç㪠fat jar ã¨ã¯ç°ãªããã¢ããªã±ã¼ã·ã§ã³ã®ã¯ã©ã¹ããã®ã¾ã¾å
¥ã£ã¦ããã®ã§ã¯ãªãã ã¢ããªã±ã¼ã·ã§ã³ã® jar ãä¸ã«å
¥ã£ã¦ãã¾ãã確èªãã¦ã¿ã¾ãã
$ unzip -Z1 build/libs/spring-app-cds-sample-0.0.1-SNAPSHOT.jar org/ org/springframework/ org/springframework/boot/ org/springframework/boot/loader/ org/springframework/boot/loader/data/ org/springframework/boot/loader/util/ org/springframework/boot/loader/archive/ org/springframework/boot/loader/jar/ org/springframework/boot/loader/data/RandomAccessDataFile.class org/springframework/boot/loader/util/SystemPropertyUtils.class org/springframework/boot/loader/archive/Archive$EntryFilter.class org/springframework/boot/loader/archive/ExplodedArchive$FileEntry.class org/springframework/boot/loader/archive/Archive.class org/springframework/boot/loader/archive/Archive$Entry.class org/springframework/boot/loader/Launcher.class ... ä¸ç¥ BOOT-INF/classes/com/example/App$Foo.class BOOT-INF/classes/com/example/App.class ... ä¸ç¥ BOOT-INF/lib/spring-boot-starter-webflux-2.0.0.RELEASE.jar BOOT-INF/lib/spring-boot-starter-actuator-2.0.0.RELEASE.jar BOOT-INF/lib/spring-boot-starter-data-jpa-2.0.0.RELEASE.jar BOOT-INF/lib/spring-boot-starter-thymeleaf-2.0.0.RELEASE.jar BOOT-INF/lib/spring-boot-starter-validation-2.0.0.RELEASE.jar BOOT-INF/lib/spring-boot-starter-data-redis-reactive-2.0.0.RELEASE.jar ... 以ä¸çç¥
ã¤ã¾ããã©ããªã«ããããä¾åã©ã¤ãã©ãªã¼ã使ã£ã¦ã bootJar
ã¿ã¹ã¯ã§ä½æãã jar ãã¡ã¤ã«ã Class Data Sharing ã§èµ·åãã¦ããã¾ãå¹æããªããã¨ããããã¾ãã
ããã§ã bootRun
ã®ãããªã©ã¦ã³ãã£ã¼çµç±ã§èµ·åããããã§ã¯ãªã形㧠Spring Boot ã¢ããªã±ã¼ã·ã§ã³ãèµ·åãããã®ã§ãããåè¿°ã®éã bootRun
ã« Class Data Sharing ã®ãªãã·ã§ã³ãã¤ãã¦èµ·åããã¨ãã©ããã¦ãã¢ã¼ã«ã¤ããã¡ã¤ã«ã®ãã¹ããã¾ãèªèããã¾ãããæ£ç¢ºã«ã¯æ¬¡ã®ãããªã³ãã³ã㧠bootRun
ã¯èµ·åãããã®ã§ãããã¢ããªã±ã¼ã·ã§ã³ã®ã¯ã©ã¹ããããã£ã¬ã¯ããªã¼ãã¢ã¼ã«ã¤ããã¡ã¤ã«ã®ãã£ã¬ã¯ããªã¼ã¨èªèãã¦ãã¾ããã¢ã¼ã«ã¤ããã¡ã¤ã«ãåºåãã¦ããã¾ããã
java \ -XX:+UnlockCommercialFeatures \ -XX:+UseAppCDS \ -Xshare:dump \ -XX:SharedClassListFile=classes.txt \ -XX:SharedArchiveFile=archive.jsa \ -cp /path/to/project/build/classes/java/main:/path/to/.gradle/foo/bar/spring-foo-bar-1.0.0.jar \ com.sample.App
ãããã£ã¦ã bootRun
ã¨ã»ã¼åæ§ã®ã³ãã³ãã§ãã³ã³ãã¤ã«ãããã¢ããªã±ã¼ã·ã§ã³ãã¯ã©ã¹ãã¡ã¤ã«ã®ã¾ã¾ã§ã¯ãªããä¸åº¦ jar ã«åºãã¦èµ·åãããããªã¿ã¹ã¯ãä½ãå¿
è¦ãããã¾ã(ããã¡ãããæ®éã« jar ãã¡ã¤ã«ãä½ã£ã¦ããããèµ·åããã®ã§ãæ§ãã¾ãããã jar
ã¿ã¹ã¯ã¯ Spring Boot plugin ã«ãã£ã¦ä¸æ¸ãããã¦ããã®ã§ãããããã¦ä½ãå¿
è¦ãããã¾ã)ã
ã¨ããããã§ããã®ãããªã¿ã¹ã¯ãä½ãããã®ã¿ã¹ã¯åã cdsBootRun
(å®è£
ãã¹ã¯ãªããã¯çç¥) ã¨ãã¾ãã
å確èª
ã§ã¯ cdsBootRun
ã使ã£ã¦ãèµ·åãã¦ã¿ã¾ãã
ã¯ã©ã¹ãªã¹ãã®åå¾
$ ./gradlew cdsBotRun -PlistApp > Task :showStartTime start 2018-04-02T23:00:45.980764 > Task :cdsBootRun skip writing class com/sun/proxy/$Proxy0 from source __JVM_DefineClass__ to classlist file skip writing class com/sun/proxy/$Proxy1 from source __JVM_DefineClass__ to classlist file ... ä¸ç¥ Action: Consider defining a bean of type 'com.example.App$Foo' in your configuration. > Task :showEndTime start 2018-04-02T23:00:45.980764 end 2018-04-02T23:00:55.548887 time: 9568 ms
ã¯ã©ã¹ãªã¹ããåå¾ããããã«JVMãã©ã¡ã¼ã¿ã¼ã調æ´ãã¦å®è¡ããã¯ã©ã¹ãã¡ã¤ã«ãªã¹ã list.txt
ã®ä¸èº«ã確èªãã¾ãã
$ grep spring build/cds/list.txt | head -10 org/springframework/boot/SpringApplication org/springframework/boot/ApplicationArguments org/springframework/context/ApplicationContext org/springframework/core/env/EnvironmentCapable org/springframework/beans/factory/ListableBeanFactory org/springframework/beans/factory/BeanFactory org/springframework/beans/factory/HierarchicalBeanFactory org/springframework/context/MessageSource org/springframework/context/ApplicationEventPublisher org/springframework/core/io/support/ResourcePatternResolver
spring
ãå«ãã¯ã©ã¹ã®å
é 10è¡ãåå¾ãã¾ããããå
ã»ã©ã®ã¯ã©ã¹ãã¡ã¤ã«ãªã¹ãã¨ã¯ç°ãªã£ã¦ãããã¨ããããã¨æãã¾ããããã¯ããªãæå¾
ã§ãã¾ãï¼
ã¢ã¼ã«ã¤ããã¡ã¤ã«ã®åå¾
ã¢ã¼ã«ã¤ããã¡ã¤ã«ãåå¾ãã¾ãã
$ ./gradlew cdsBootRun -PdumpApp > Task :showStartTime start 2018-04-02T23:06:08.353299 > Task :cdsBootRun narrow_klass_base = 0x0000000800000000, narrow_klass_shift = 3 Allocated temporary class space: 1073741824 bytes at 0x00000008c0000000 Allocated shared space: 3221225472 bytes at 0x0000000800000000 Loading classes to share ... Preload Warning: Cannot find com/sun/proxy/$Proxy4 Preload Warning: Cannot find org/springframework/core/$Proxy5 Preload Warning: Cannot find org/springframework/core/$Proxy6 Preload Warning: Cannot find com/sun/proxy/$Proxy7 Preload Warning: Cannot find com/sun/proxy/$Proxy8 ... ä¸ç¥ Rewriting and linking classes: done Number of classes 6389 instance classes = 6297 obj array classes = 84 type array classes = 8 Updating ConstMethods ... done. Removing unshareable information ... done. Scanning all metaspace objects ... Allocating RW objects ... Allocating RO objects ... Relocating embedded pointers ... Relocating external roots ... Dumping symbol table ... Dumping String objects to closed archive heap region ... Dumping objects to open archive heap region ... Relocating SystemDictionary::_well_known_klasses[] ... Removing java_mirror ... done. mc space: 9544 [ 0.0% of total] out of 12288 bytes [ 77.7% used] at 0x0000000800000000 rw space: 15875096 [ 20.8% of total] out of 15876096 bytes [100.0% used] at 0x0000000800003000 ro space: 29298616 [ 38.4% of total] out of 29298688 bytes [100.0% used] at 0x0000000800f27000 md space: 6160 [ 0.0% of total] out of 8192 bytes [ 75.2% used] at 0x0000000802b18000 od space: 27230536 [ 35.7% of total] out of 27234304 bytes [100.0% used] at 0x0000000802b1a000 st0 space: 446464 [ 0.6% of total] out of 446464 bytes [100.0% used] at 0x00000007bfc00000 st1 space: 3145728 [ 4.1% of total] out of 3145728 bytes [100.0% used] at 0x00000007bfd00000 oa0 space: 221184 [ 0.3% of total] out of 221184 bytes [100.0% used] at 0x00000007bfb00000 total : 76233328 [100.0% of total] out of 76242944 bytes [100.0% used] > Task :showEndTime start 2018-04-02T23:06:08.353299 end 2018-04-02T23:06:28.96977 time: 20616 ms BUILD SUCCESSFUL in 22s 5 actionable tasks: 3 executed, 2 up-to-date
ãã¦ããã®ã³ãã³ãã®çµæã«ã大ããªå¤æ´ãããã¾ãããæåã«è©¦ããã¨ã㯠2131
åã®ãã¡ã¤ã«ãã¢ã¼ã«ã¤ããããã®ã«å¯¾ãã¦ãä»åº¦ã¯ 6389
åã®ãã¡ã¤ã«ãã¢ã¼ã«ã¤ããããããã§ãã
$ ls -l build/cds/ total 149600 -r--r--r--+ 1 mike staff 76271616 4 2 23:06 app.jsa -rw-r--r--+ 1 mike staff 323139 4 2 23:00 list.txt
ã¾ãããã¡ã¤ã«ã®å¤§ããã確èªãã¦ããæåã®ã¨ã㯠31,203,328
ã ã£ãã®ã«å¯¾ãã¦ã 76,271,616
ã«å¢ãã¦ãã¾ããããã¯æ¬å½ã«æå¾
ã§ãããã§ããï¼
ã¢ã¼ã«ã¤ããã¡ã¤ã«ãèªã¿è¾¼ãã§ã¢ããªã±ã¼ã·ã§ã³ãèµ·åãã
ã§ã¯ã¢ã¼ã«ã¤ããã¡ã¤ã«ãèªã¿è¾¼ãã§ã¢ããªã±ã¼ã·ã§ã³ãèµ·åãã¦ã¿ã¾ãã
$ ./gradlew cdsBootRun -PrunApp > Task :showStartTime start 2018-04-02T23:14:33.147381 > Task :cdsBootRun . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.0.RELEASE) 2018-04-02 23:14:39.305 INFO 10455 --- [ main] com.example.App : Starting App on mac.local with PID 10455 (/path/to/project/build/customJar/spring-app-cds-sample-0.0.1-SNAPSHOT.jar started by mike in /path/to/project) 2018-04-02 23:14:39.307 INFO 10455 --- [ main] com.example.App : No active profile set, falling back to default profiles: default ... ä¸ç¥ > Task :showEndTime start 2018-04-02T23:14:33.147381 end 2018-04-02T23:14:41.733068 time: 8585 ms ... 以ä¸ç¥
çµæã¨ãã¦ã¯æ¬¡ã®ããã«ãªãã¾ããã
- å
¨ä½ã®æé :
8585
ms
å ã»ã©ã¨æ¯ã¹ã¦â¦ã¨è¨ãããã¨ããã§ãããèµ·åãããã®ãå¤ãã£ãã®ã§æåã«CDSã使ããªãã£ããã®ãæ¯è¼å¯¾è±¡ã«ããã®ã¯ééã£ã¦ãã¾ãã®ã§ãããããã¦CDSã使ããªãå ´åã®èµ·åæéã調ã¹ã¦ã¿ã¾ãã
$ ./gradlew cdsBootRun > Task :showStartTime start 2018-04-02T23:22:34.634671 > Task :cdsBootRun . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.0.RELEASE) 2018-04-02 23:22:40.818 INFO 10507 --- [ main] com.example.App : Starting App on mac.local with PID 10507 (/path/to/project/build/customJar/spring-app-cds-sample-0.0.1-SNAPSHOT.jar started by mike in /path/to/project) 2018-04-02 23:22:40.822 INFO 10507 --- [ main] com.example.App : No active profile set, falling back to default profiles: default ... ä¸ç¥ > Task :showEndTime start 2018-04-02T23:22:34.634671 end 2018-04-02T23:22:43.906533 time: 9271 ms ... 以ä¸ç¥
CDSã使ããªãã£ãå ´åã®èµ·åæéã¯æ¬¡ã®ããã«ãªãã¾ããã
- å
¨ä½ã®æé :
9271
ms
æ¯è¼ãã¦ã¿ãã¨ã CDS ã使ã£ãå ´åã®æ¹ã 686
ms ã»ã©éããªãã¾ããï¼
æ¡ä»¶ | æé(ms) |
---|---|
CDS使ã£ãå ´å | 8585 |
CDS使ããªãå ´å | 9271 |