Mercurial > hg > graal-jvmci-8
comparison src/share/vm/memory/metaspaceShared.cpp @ 20389:622c6e0ad4d6
8048150: Allow easy configurations for large CDS archives
Summary: Estimate the size of shared archive based on the number of classes in the classlist file
Reviewed-by: iklam, jiangli, minqi, dholmes
author | ccheung |
---|---|
date | Mon, 25 Aug 2014 00:13:36 -0700 |
parents | 6e0cb14ce59b |
children | 8cb56c8cb30d |
comparison
equal
deleted
inserted
replaced
20386:edb5f3b38aab | 20389:622c6e0ad4d6 |
---|---|
813 class_count++; | 813 class_count++; |
814 } else { | 814 } else { |
815 //tty->print_cr("Preload failed: %s", class_name); | 815 //tty->print_cr("Preload failed: %s", class_name); |
816 } | 816 } |
817 } | 817 } |
818 fclose(file); | |
818 } else { | 819 } else { |
819 char errmsg[JVM_MAXPATHLEN]; | 820 char errmsg[JVM_MAXPATHLEN]; |
820 os::lasterror(errmsg, JVM_MAXPATHLEN); | 821 os::lasterror(errmsg, JVM_MAXPATHLEN); |
821 tty->print_cr("Loading classlist failed: %s", errmsg); | 822 tty->print_cr("Loading classlist failed: %s", errmsg); |
822 exit(1); | 823 exit(1); |
1083 return false; | 1084 return false; |
1084 } | 1085 } |
1085 } | 1086 } |
1086 return true; | 1087 return true; |
1087 } | 1088 } |
1089 | |
1090 int MetaspaceShared::count_class(const char* classlist_file) { | |
1091 if (classlist_file == NULL) { | |
1092 return 0; | |
1093 } | |
1094 char class_name[256]; | |
1095 int class_count = 0; | |
1096 FILE* file = fopen(classlist_file, "r"); | |
1097 if (file != NULL) { | |
1098 while ((fgets(class_name, sizeof class_name, file)) != NULL) { | |
1099 if (*class_name == '#') { // comment | |
1100 continue; | |
1101 } | |
1102 class_count++; | |
1103 } | |
1104 fclose(file); | |
1105 } else { | |
1106 char errmsg[JVM_MAXPATHLEN]; | |
1107 os::lasterror(errmsg, JVM_MAXPATHLEN); | |
1108 tty->print_cr("Loading classlist failed: %s", errmsg); | |
1109 exit(1); | |
1110 } | |
1111 | |
1112 return class_count; | |
1113 } | |
1114 | |
1115 // the sizes are good for typical large applications that have a lot of shared | |
1116 // classes | |
1117 void MetaspaceShared::estimate_regions_size() { | |
1118 int class_count = count_class(SharedClassListFile); | |
1119 class_count += count_class(ExtraSharedClassListFile); | |
1120 | |
1121 if (class_count > LargeThresholdClassCount) { | |
1122 if (class_count < HugeThresholdClassCount) { | |
1123 SET_ESTIMATED_SIZE(Large, ReadOnly); | |
1124 SET_ESTIMATED_SIZE(Large, ReadWrite); | |
1125 SET_ESTIMATED_SIZE(Large, MiscData); | |
1126 SET_ESTIMATED_SIZE(Large, MiscCode); | |
1127 } else { | |
1128 SET_ESTIMATED_SIZE(Huge, ReadOnly); | |
1129 SET_ESTIMATED_SIZE(Huge, ReadWrite); | |
1130 SET_ESTIMATED_SIZE(Huge, MiscData); | |
1131 SET_ESTIMATED_SIZE(Huge, MiscCode); | |
1132 } | |
1133 } | |
1134 } |