1 Star 0 Fork 81

lyn/openjdk-1.8.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
add-8191924-Adjust-DelegatingClassLoader-s-metadata-.patch 3.89 KB
一键复制 编辑 原始数据 按行查看 历史
DXwangg 提交于 2023-09-26 09:10 . Add feature and bug fix for 8u382
From 64123e7422fb9441c8999aaa1ddfdf639295fea1 Mon Sep 17 00:00:00 2001
Date: Thu, 21 Sep 2023 15:26:33 +0800
Subject: add 8191924-Adjust-DelegatingClassLoader-s-metadata-spac
---
hotspot/src/share/vm/memory/metaspace.cpp | 31 ++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/hotspot/src/share/vm/memory/metaspace.cpp b/hotspot/src/share/vm/memory/metaspace.cpp
index 07259e649..d65a81267 100644
--- a/hotspot/src/share/vm/memory/metaspace.cpp
+++ b/hotspot/src/share/vm/memory/metaspace.cpp
@@ -1206,7 +1206,10 @@ class SpaceManager : public CHeapObj<mtClass> {
Mutex* const _lock;
// Type of metadata allocated.
- Metaspace::MetadataType _mdtype;
+ const Metaspace::MetadataType _mdtype;
+
+ // Type of metaspace
+ const Metaspace::MetaspaceType _space_type;
// List of chunks in use by this SpaceManager. Allocations
// are done from the current chunk. The list is used for deallocating
@@ -1218,6 +1221,10 @@ class SpaceManager : public CHeapObj<mtClass> {
// If class space manager, small chunks are unlimited
static uint const _small_chunk_limit;
+ // Maximum number of specialize chunks to allocate for anonymous and delegating
+ // metadata space to a SpaceManager
+ static uint const _anon_and_delegating_metadata_specialize_chunk_limit;
+
// Sum of all space in allocated chunks
size_t _allocated_blocks_words;
@@ -1270,6 +1277,7 @@ class SpaceManager : public CHeapObj<mtClass> {
public:
SpaceManager(Metaspace::MetadataType mdtype,
+ Metaspace::MetaspaceType space_type,
Mutex* lock);
~SpaceManager();
@@ -1385,6 +1393,7 @@ class SpaceManager : public CHeapObj<mtClass> {
};
uint const SpaceManager::_small_chunk_limit = 4;
+uint const SpaceManager::_anon_and_delegating_metadata_specialize_chunk_limit = 4;
const char* SpaceManager::_expand_lock_name =
"SpaceManager chunk allocation lock";
@@ -3409,6 +3418,20 @@ size_t SpaceManager::calc_chunk_size(size_t word_size) {
// once a medium chunk has been allocated, no more small
// chunks will be allocated.
size_t chunk_word_size;
+
+ // Special case for anonymous metadata space.
+ // Anonymous metadata space is usually small, with majority within 1K - 2K range and
+ // rarely about 4K (64-bits JVM).
+ // Instead of jumping to SmallChunk after initial chunk exhausted, keeping allocation
+ // from SpecializeChunk up to _anon_or_delegating_metadata_specialize_chunk_limit (4)
+ // reduces space waste from 60+% to around 30%.
+ if ((_space_type == Metaspace::AnonymousMetaspaceType || _space_type == Metaspace::ReflectionMetaspaceType) &&
+ _mdtype == Metaspace::NonClassType &&
+ sum_count_in_chunks_in_use(SpecializedIndex) < _anon_and_delegating_metadata_specialize_chunk_limit &&
+ word_size + Metachunk::overhead() <= SpecializedChunk) {
+ return SpecializedChunk;
+ }
+
if (chunks_in_use(MediumIndex) == NULL &&
sum_count_in_chunks_in_use(SmallIndex) < _small_chunk_limit) {
chunk_word_size = (size_t) small_chunk_size();
@@ -3517,8 +3540,10 @@ void SpaceManager::print_on(outputStream* st) const {
}
SpaceManager::SpaceManager(Metaspace::MetadataType mdtype,
+ Metaspace::MetaspaceType space_type,
Mutex* lock) :
_mdtype(mdtype),
+ _space_type(space_type),
_allocated_blocks_words(0),
_allocated_chunks_words(0),
_allocated_chunks_count(0),
@@ -4926,11 +4951,11 @@ void Metaspace::initialize(Mutex* lock, MetaspaceType type) {
verify_global_initialization();
// Allocate SpaceManager for metadata objects.
- _vsm = new SpaceManager(NonClassType, lock);
+ _vsm = new SpaceManager(NonClassType, type, lock);
if (using_class_space()) {
// Allocate SpaceManager for classes.
- _class_vsm = new SpaceManager(ClassType, lock);
+ _class_vsm = new SpaceManager(ClassType, type, lock);
} else {
_class_vsm = NULL;
}
--
2.22.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lyn1001/openjdk-1.8.0.git
git@gitee.com:lyn1001/openjdk-1.8.0.git
lyn1001
openjdk-1.8.0
openjdk-1.8.0
master

搜索帮助