mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8184765: Dynamically resize SystemDictionary
Implemented dynamic resizing, which triggers when load factor is too high Reviewed-by: coleenp, rehn
This commit is contained in:
parent
e878b3272b
commit
a043febf6f
14 changed files with 415 additions and 85 deletions
|
@ -604,40 +604,27 @@ ModuleEntryTable* ClassLoaderData::modules() {
|
|||
|
||||
const int _boot_loader_dictionary_size = 1009;
|
||||
const int _default_loader_dictionary_size = 107;
|
||||
const int _prime_array_size = 8; // array of primes for system dictionary size
|
||||
const int _average_depth_goal = 3; // goal for lookup length
|
||||
const int _primelist[_prime_array_size] = {107, 1009, 2017, 4049, 5051, 10103, 20201, 40423};
|
||||
|
||||
// Calculate a "good" dictionary size based
|
||||
// on predicted or current loaded classes count.
|
||||
static int calculate_dictionary_size(int classcount) {
|
||||
int newsize = _primelist[0];
|
||||
if (classcount > 0 && !DumpSharedSpaces) {
|
||||
int index = 0;
|
||||
int desiredsize = classcount/_average_depth_goal;
|
||||
for (newsize = _primelist[index]; index < _prime_array_size -1;
|
||||
newsize = _primelist[++index]) {
|
||||
if (desiredsize <= newsize) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return newsize;
|
||||
}
|
||||
|
||||
Dictionary* ClassLoaderData::create_dictionary() {
|
||||
assert(!is_anonymous(), "anonymous class loader data do not have a dictionary");
|
||||
int size;
|
||||
bool resizable = false;
|
||||
if (_the_null_class_loader_data == NULL) {
|
||||
size = _boot_loader_dictionary_size;
|
||||
resizable = true;
|
||||
} else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) {
|
||||
size = 1; // there's only one class in relection class loader and no initiated classes
|
||||
} else if (is_system_class_loader_data()) {
|
||||
size = calculate_dictionary_size(PredictedLoadedClassCount);
|
||||
size = _boot_loader_dictionary_size;
|
||||
resizable = true;
|
||||
} else {
|
||||
size = _default_loader_dictionary_size;
|
||||
resizable = true;
|
||||
}
|
||||
return new Dictionary(this, size);
|
||||
if (!DynamicallyResizeSystemDictionaries || DumpSharedSpaces || UseSharedSpaces) {
|
||||
resizable = false;
|
||||
}
|
||||
return new Dictionary(this, size, resizable);
|
||||
}
|
||||
|
||||
// Unloading support
|
||||
|
@ -1325,6 +1312,19 @@ void ClassLoaderDataGraph::purge() {
|
|||
}
|
||||
}
|
||||
|
||||
int ClassLoaderDataGraph::resize_if_needed() {
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
|
||||
int resized = 0;
|
||||
if (Dictionary::does_any_dictionary_needs_resizing()) {
|
||||
FOR_ALL_DICTIONARY(cld) {
|
||||
if (cld->dictionary()->resize_if_needed()) {
|
||||
resized++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return resized;
|
||||
}
|
||||
|
||||
void ClassLoaderDataGraph::post_class_unload_events() {
|
||||
#if INCLUDE_TRACE
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue