Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
dbcd7c00
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dbcd7c00
编写于
7月 06, 2018
作者:
P
poonam
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8146115: Improve docker container detection and resource configuration usage
Reviewed-by: bobv, dbuck
上级
3e1b3e30
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
1113 addition
and
105 deletion
+1113
-105
src/os/aix/vm/os_aix.cpp
src/os/aix/vm/os_aix.cpp
+10
-0
src/os/bsd/vm/os_bsd.cpp
src/os/bsd/vm/os_bsd.cpp
+10
-0
src/os/linux/vm/globals_linux.hpp
src/os/linux/vm/globals_linux.hpp
+8
-3
src/os/linux/vm/osContainer_linux.cpp
src/os/linux/vm/osContainer_linux.cpp
+680
-0
src/os/linux/vm/osContainer_linux.hpp
src/os/linux/vm/osContainer_linux.hpp
+68
-0
src/os/linux/vm/os_linux.cpp
src/os/linux/vm/os_linux.cpp
+150
-5
src/os/linux/vm/os_linux.hpp
src/os/linux/vm/os_linux.hpp
+5
-0
src/os/solaris/vm/os_solaris.cpp
src/os/solaris/vm/os_solaris.cpp
+10
-0
src/os/windows/vm/os_windows.cpp
src/os/windows/vm/os_windows.cpp
+10
-0
src/share/vm/runtime/arguments.cpp
src/share/vm/runtime/arguments.cpp
+125
-94
src/share/vm/runtime/arguments.hpp
src/share/vm/runtime/arguments.hpp
+3
-1
src/share/vm/runtime/globals.hpp
src/share/vm/runtime/globals.hpp
+25
-2
src/share/vm/runtime/os.hpp
src/share/vm/runtime/os.hpp
+8
-0
src/share/vm/runtime/thread.cpp
src/share/vm/runtime/thread.cpp
+1
-0
未找到文件。
src/os/aix/vm/os_aix.cpp
浏览文件 @
dbcd7c00
...
...
@@ -4008,6 +4008,16 @@ void os::make_polling_page_readable(void) {
};
int
os
::
active_processor_count
()
{
// User has overridden the number of active processors
if
(
ActiveProcessorCount
>
0
)
{
if
(
PrintActiveCpus
)
{
tty
->
print_cr
(
"active_processor_count: "
"active processor count set by user : %d"
,
ActiveProcessorCount
);
}
return
ActiveProcessorCount
;
}
int
online_cpus
=
::
sysconf
(
_SC_NPROCESSORS_ONLN
);
assert
(
online_cpus
>
0
&&
online_cpus
<=
processor_count
(),
"sanity check"
);
return
online_cpus
;
...
...
src/os/bsd/vm/os_bsd.cpp
浏览文件 @
dbcd7c00
...
...
@@ -3765,6 +3765,16 @@ void os::make_polling_page_readable(void) {
};
int
os
::
active_processor_count
()
{
// User has overridden the number of active processors
if
(
ActiveProcessorCount
>
0
)
{
if
(
PrintActiveCpus
)
{
tty
->
print_cr
(
"active_processor_count: "
"active processor count set by user : %d"
,
ActiveProcessorCount
);
}
return
ActiveProcessorCount
;
}
return
_processor_count
;
}
...
...
src/os/linux/vm/globals_linux.hpp
浏览文件 @
dbcd7c00
/*
* Copyright (c) 2005, 201
6
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
8
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -49,8 +49,13 @@
product(bool, UseSHM, false, \
"Use SYSV shared memory for large pages") \
\
diagnostic(bool, PrintActiveCpus, false, \
"Print the number of CPUs detected in os::active_processor_count")
product(bool, UseContainerSupport, true, \
"Enable detection and runtime container configuration support") \
\
product(bool, PreferContainerQuotaForCPUCount, true, \
"Calculate the container CPU availability based on the value" \
" of quotas (if set), when true. Otherwise, use the CPU" \
" shares value, provided it is less than quota.")
//
// Defines Linux-specific default values. The flags are available on all
...
...
src/os/linux/vm/osContainer_linux.cpp
0 → 100644
浏览文件 @
dbcd7c00
此差异已折叠。
点击以展开。
src/os/linux/vm/osContainer_linux.hpp
0 → 100644
浏览文件 @
dbcd7c00
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_LINUX_VM_OSCONTAINER_LINUX_HPP
#define OS_LINUX_VM_OSCONTAINER_LINUX_HPP
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include "memory/allocation.hpp"
#define OSCONTAINER_ERROR (-2)
class
OSContainer
:
AllStatic
{
private:
static
bool
_is_initialized
;
static
bool
_is_containerized
;
public:
static
void
init
();
static
inline
bool
is_containerized
();
static
const
char
*
container_type
();
static
jlong
memory_limit_in_bytes
();
static
jlong
memory_and_swap_limit_in_bytes
();
static
jlong
memory_soft_limit_in_bytes
();
static
jlong
memory_usage_in_bytes
();
static
jlong
memory_max_usage_in_bytes
();
static
int
active_processor_count
();
static
char
*
cpu_cpuset_cpus
();
static
char
*
cpu_cpuset_memory_nodes
();
static
int
cpu_quota
();
static
int
cpu_period
();
static
int
cpu_shares
();
};
inline
bool
OSContainer
::
is_containerized
()
{
assert
(
_is_initialized
,
"OSContainer not initialized"
);
return
_is_containerized
;
}
#endif // OS_LINUX_VM_OSCONTAINER_LINUX_HPP
src/os/linux/vm/os_linux.cpp
浏览文件 @
dbcd7c00
...
...
@@ -37,6 +37,7 @@
#include "mutex_linux.inline.hpp"
#include "oops/oop.inline.hpp"
#include "os_share_linux.hpp"
#include "osContainer_linux.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm.h"
#include "prims/jvm_misc.hpp"
...
...
@@ -179,13 +180,62 @@ julong os::available_memory() {
julong
os
::
Linux
::
available_memory
()
{
// values in struct sysinfo are "unsigned long"
struct
sysinfo
si
;
sysinfo
(
&
si
);
julong
avail_mem
;
if
(
OSContainer
::
is_containerized
())
{
jlong
mem_limit
,
mem_usage
;
if
((
mem_limit
=
OSContainer
::
memory_limit_in_bytes
())
<
1
)
{
if
(
PrintContainerInfo
)
{
tty
->
print_cr
(
"container memory limit %s: "
JLONG_FORMAT
", using host value"
,
mem_limit
==
OSCONTAINER_ERROR
?
"failed"
:
"unlimited"
,
mem_limit
);
}
}
if
(
mem_limit
>
0
&&
(
mem_usage
=
OSContainer
::
memory_usage_in_bytes
())
<
1
)
{
if
(
PrintContainerInfo
)
{
tty
->
print_cr
(
"container memory usage failed: "
JLONG_FORMAT
", using host value"
,
mem_usage
);
}
}
return
(
julong
)
si
.
freeram
*
si
.
mem_unit
;
if
(
mem_limit
>
0
&&
mem_usage
>
0
)
{
avail_mem
=
mem_limit
>
mem_usage
?
(
julong
)
mem_limit
-
(
julong
)
mem_usage
:
0
;
if
(
PrintContainerInfo
)
{
tty
->
print_cr
(
"available container memory: "
JULONG_FORMAT
,
avail_mem
);
}
return
avail_mem
;
}
}
sysinfo
(
&
si
);
avail_mem
=
(
julong
)
si
.
freeram
*
si
.
mem_unit
;
if
(
Verbose
)
{
tty
->
print_cr
(
"available memory: "
JULONG_FORMAT
,
avail_mem
);
}
return
avail_mem
;
}
julong
os
::
physical_memory
()
{
return
Linux
::
physical_memory
();
jlong
phys_mem
=
0
;
if
(
OSContainer
::
is_containerized
())
{
jlong
mem_limit
;
if
((
mem_limit
=
OSContainer
::
memory_limit_in_bytes
())
>
0
)
{
if
(
PrintContainerInfo
)
{
tty
->
print_cr
(
"total container memory: "
JLONG_FORMAT
,
mem_limit
);
}
return
mem_limit
;
}
if
(
PrintContainerInfo
)
{
tty
->
print_cr
(
"container memory limit %s: "
JLONG_FORMAT
", using host value"
,
mem_limit
==
OSCONTAINER_ERROR
?
"failed"
:
"unlimited"
,
mem_limit
);
}
}
phys_mem
=
Linux
::
physical_memory
();
if
(
Verbose
)
{
tty
->
print_cr
(
"total system memory: "
JLONG_FORMAT
,
phys_mem
);
}
return
phys_mem
;
}
////////////////////////////////////////////////////////////////////////////////
...
...
@@ -2120,6 +2170,8 @@ void os::print_os_info(outputStream* st) {
os
::
Posix
::
print_load_average
(
st
);
os
::
Linux
::
print_full_memory_info
(
st
);
os
::
Linux
::
print_container_info
(
st
);
}
// Try to identify popular distros.
...
...
@@ -2185,6 +2237,57 @@ void os::Linux::print_full_memory_info(outputStream* st) {
st
->
cr
();
}
void
os
::
Linux
::
print_container_info
(
outputStream
*
st
)
{
if
(
!
OSContainer
::
is_containerized
())
{
return
;
}
st
->
print
(
"container (cgroup) information:
\n
"
);
const
char
*
p_ct
=
OSContainer
::
container_type
();
st
->
print
(
"container_type: %s
\n
"
,
p_ct
!=
NULL
?
p_ct
:
"failed"
);
char
*
p
=
OSContainer
::
cpu_cpuset_cpus
();
st
->
print
(
"cpu_cpuset_cpus: %s
\n
"
,
p
!=
NULL
?
p
:
"failed"
);
free
(
p
);
p
=
OSContainer
::
cpu_cpuset_memory_nodes
();
st
->
print
(
"cpu_memory_nodes: %s
\n
"
,
p
!=
NULL
?
p
:
"failed"
);
free
(
p
);
int
i
=
OSContainer
::
active_processor_count
();
if
(
i
>
0
)
{
st
->
print
(
"active_processor_count: %d
\n
"
,
i
);
}
else
{
st
->
print
(
"active_processor_count: failed
\n
"
);
}
i
=
OSContainer
::
cpu_quota
();
st
->
print
(
"cpu_quota: %d
\n
"
,
i
);
i
=
OSContainer
::
cpu_period
();
st
->
print
(
"cpu_period: %d
\n
"
,
i
);
i
=
OSContainer
::
cpu_shares
();
st
->
print
(
"cpu_shares: %d
\n
"
,
i
);
jlong
j
=
OSContainer
::
memory_limit_in_bytes
();
st
->
print
(
"memory_limit_in_bytes: "
JLONG_FORMAT
"
\n
"
,
j
);
j
=
OSContainer
::
memory_and_swap_limit_in_bytes
();
st
->
print
(
"memory_and_swap_limit_in_bytes: "
JLONG_FORMAT
"
\n
"
,
j
);
j
=
OSContainer
::
memory_soft_limit_in_bytes
();
st
->
print
(
"memory_soft_limit_in_bytes: "
JLONG_FORMAT
"
\n
"
,
j
);
j
=
OSContainer
::
OSContainer
::
memory_usage_in_bytes
();
st
->
print
(
"memory_usage_in_bytes: "
JLONG_FORMAT
"
\n
"
,
j
);
j
=
OSContainer
::
OSContainer
::
memory_max_usage_in_bytes
();
st
->
print
(
"memory_max_usage_in_bytes: "
JLONG_FORMAT
"
\n
"
,
j
);
st
->
cr
();
}
void
os
::
print_memory_info
(
outputStream
*
st
)
{
st
->
print
(
"Memory:"
);
...
...
@@ -4956,6 +5059,10 @@ extern "C" {
}
}
void
os
::
pd_init_container_support
()
{
OSContainer
::
init
();
}
// this is called _after_ the global arguments have been parsed
jint
os
::
init_2
(
void
)
{
...
...
@@ -5136,7 +5243,7 @@ static int os_cpu_count(const cpu_set_t* cpus) {
// sched_getaffinity gives an accurate answer as it accounts for cpusets.
// If anything goes wrong we fallback to returning the number of online
// processors - which can be greater than the number available to the process.
int
os
::
active_processor_count
()
{
int
os
::
Linux
::
active_processor_count
()
{
cpu_set_t
cpus
;
// can represent at most 1024 (CPU_SETSIZE) processors
int
cpus_size
=
sizeof
(
cpu_set_t
);
int
cpu_count
=
0
;
...
...
@@ -5154,10 +5261,48 @@ int os::active_processor_count() {
"which may exceed available processors"
,
strerror
(
errno
),
cpu_count
);
}
assert
(
cpu_count
>
0
&&
cpu_count
<=
processor_count
(),
"sanity check"
);
assert
(
cpu_count
>
0
&&
cpu_count
<=
os
::
processor_count
(),
"sanity check"
);
return
cpu_count
;
}
// Determine the active processor count from one of
// three different sources:
//
// 1. User option -XX:ActiveProcessorCount
// 2. kernel os calls (sched_getaffinity or sysconf(_SC_NPROCESSORS_ONLN)
// 3. extracted from cgroup cpu subsystem (shares and quotas)
//
// Option 1, if specified, will always override.
// If the cgroup subsystem is active and configured, we
// will return the min of the cgroup and option 2 results.
// This is required since tools, such as numactl, that
// alter cpu affinity do not update cgroup subsystem
// cpuset configuration files.
int
os
::
active_processor_count
()
{
// User has overridden the number of active processors
if
(
ActiveProcessorCount
>
0
)
{
if
(
PrintActiveCpus
)
{
tty
->
print_cr
(
"active_processor_count: "
"active processor count set by user : %d"
,
ActiveProcessorCount
);
}
return
ActiveProcessorCount
;
}
int
active_cpus
;
if
(
OSContainer
::
is_containerized
())
{
active_cpus
=
OSContainer
::
active_processor_count
();
if
(
PrintActiveCpus
)
{
tty
->
print_cr
(
"active_processor_count: determined by OSContainer: %d"
,
active_cpus
);
}
}
else
{
active_cpus
=
os
::
Linux
::
active_processor_count
();
}
return
active_cpus
;
}
void
os
::
set_native_thread_name
(
const
char
*
name
)
{
// Not yet implemented.
return
;
...
...
src/os/linux/vm/os_linux.hpp
浏览文件 @
dbcd7c00
...
...
@@ -35,6 +35,7 @@ static bool zero_page_read_protected() { return true; }
class
Linux
{
friend
class
os
;
friend
class
OSContainer
;
friend
class
TestReserveMemorySpecial
;
// For signal-chaining
...
...
@@ -79,6 +80,9 @@ class Linux {
static
julong
available_memory
();
static
julong
physical_memory
()
{
return
_physical_memory
;
}
static
void
set_physical_memory
(
julong
phys_mem
)
{
_physical_memory
=
phys_mem
;
}
static
int
active_processor_count
();
static
void
initialize_system_info
();
static
int
commit_memory_impl
(
char
*
addr
,
size_t
bytes
,
bool
exec
);
...
...
@@ -116,6 +120,7 @@ class Linux {
static
bool
release_memory_special_huge_tlbfs
(
char
*
base
,
size_t
bytes
);
static
void
print_full_memory_info
(
outputStream
*
st
);
static
void
print_container_info
(
outputStream
*
st
);
static
void
print_distro_info
(
outputStream
*
st
);
static
void
print_libversion_info
(
outputStream
*
st
);
...
...
src/os/solaris/vm/os_solaris.cpp
浏览文件 @
dbcd7c00
...
...
@@ -359,6 +359,16 @@ void os::Solaris::initialize_system_info() {
}
int
os
::
active_processor_count
()
{
// User has overridden the number of active processors
if
(
ActiveProcessorCount
>
0
)
{
if
(
Verbose
)
{
tty
->
print_cr
(
"active_processor_count: "
"active processor count set by user : %d"
,
ActiveProcessorCount
);
}
return
ActiveProcessorCount
;
}
int
online_cpus
=
sysconf
(
_SC_NPROCESSORS_ONLN
);
pid_t
pid
=
getpid
();
psetid_t
pset
=
PS_NONE
;
...
...
src/os/windows/vm/os_windows.cpp
浏览文件 @
dbcd7c00
...
...
@@ -716,6 +716,16 @@ typedef UINT_PTR DWORD_PTR;
#endif
int
os
::
active_processor_count
()
{
// User has overridden the number of active processors
if
(
ActiveProcessorCount
>
0
)
{
if
(
PrintActiveCpus
)
{
tty
->
print_cr
(
"active_processor_count: "
"active processor count set by user : %d"
,
ActiveProcessorCount
);
}
return
ActiveProcessorCount
;
}
DWORD_PTR
lpProcessAffinityMask
=
0
;
DWORD_PTR
lpSystemAffinityMask
=
0
;
int
proc_count
=
processor_count
();
...
...
src/share/vm/runtime/arguments.cpp
浏览文件 @
dbcd7c00
/*
* Copyright (c) 1997, 201
7
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
8
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -1801,20 +1801,34 @@ void Arguments::set_heap_size() {
}
}
// Convert Fraction to Precentage values
if
(
FLAG_IS_DEFAULT
(
MaxRAMPercentage
)
&&
!
FLAG_IS_DEFAULT
(
MaxRAMFraction
))
MaxRAMPercentage
=
100.0
/
MaxRAMFraction
;
if
(
FLAG_IS_DEFAULT
(
MinRAMPercentage
)
&&
!
FLAG_IS_DEFAULT
(
MinRAMFraction
))
MinRAMPercentage
=
100.0
/
MinRAMFraction
;
if
(
FLAG_IS_DEFAULT
(
InitialRAMPercentage
)
&&
!
FLAG_IS_DEFAULT
(
InitialRAMFraction
))
InitialRAMPercentage
=
100.0
/
InitialRAMFraction
;
// If the maximum heap size has not been set with -Xmx,
// then set it as fraction of the size of physical memory,
// respecting the maximum and minimum sizes of the heap.
if
(
FLAG_IS_DEFAULT
(
MaxHeapSize
))
{
julong
reasonable_max
=
phys_mem
/
MaxRAMFraction
;
if
(
phys_mem
<=
MaxHeapSize
*
MinRAMFraction
)
{
julong
reasonable_max
=
(
julong
)((
phys_mem
*
MaxRAMPercentage
)
/
100
)
;
const
julong
reasonable_min
=
(
julong
)((
phys_mem
*
MinRAMPercentage
)
/
100
);
if
(
reasonable_min
<
MaxHeapSize
)
{
// Small physical memory, so use a minimum fraction of it for the heap
reasonable_max
=
phys_mem
/
MinRAMFractio
n
;
reasonable_max
=
reasonable_mi
n
;
}
else
{
// Not-small physical memory, so require a heap at least
// as large as MaxHeapSize
reasonable_max
=
MAX2
(
reasonable_max
,
(
julong
)
MaxHeapSize
);
}
if
(
!
FLAG_IS_DEFAULT
(
ErgoHeapSizeLimit
)
&&
ErgoHeapSizeLimit
!=
0
)
{
// Limit the heap size to ErgoHeapSizeLimit
reasonable_max
=
MIN2
(
reasonable_max
,
(
julong
)
ErgoHeapSizeLimit
);
...
...
@@ -1856,7 +1870,7 @@ void Arguments::set_heap_size() {
reasonable_minimum
=
limit_by_allocatable_memory
(
reasonable_minimum
);
if
(
InitialHeapSize
==
0
)
{
julong
reasonable_initial
=
phys_mem
/
InitialRAMFraction
;
julong
reasonable_initial
=
(
julong
)((
phys_mem
*
InitialRAMPercentage
)
/
100
)
;
reasonable_initial
=
MAX3
(
reasonable_initial
,
reasonable_minimum
,
(
julong
)
min_heap_size
());
reasonable_initial
=
MIN2
(
reasonable_initial
,
(
julong
)
MaxHeapSize
);
...
...
@@ -1881,6 +1895,94 @@ void Arguments::set_heap_size() {
}
}
// This option inspects the machine and attempts to set various
// parameters to be optimal for long-running, memory allocation
// intensive jobs. It is intended for machines with large
// amounts of cpu and memory.
jint
Arguments
::
set_aggressive_heap_flags
()
{
// initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
// VM, but we may not be able to represent the total physical memory
// available (like having 8gb of memory on a box but using a 32bit VM).
// Thus, we need to make sure we're using a julong for intermediate
// calculations.
julong
initHeapSize
;
julong
total_memory
=
os
::
physical_memory
();
if
(
total_memory
<
(
julong
)
256
*
M
)
{
jio_fprintf
(
defaultStream
::
error_stream
(),
"You need at least 256mb of memory to use -XX:+AggressiveHeap
\n
"
);
vm_exit
(
1
);
}
// The heap size is half of available memory, or (at most)
// all of possible memory less 160mb (leaving room for the OS
// when using ISM). This is the maximum; because adaptive sizing
// is turned on below, the actual space used may be smaller.
initHeapSize
=
MIN2
(
total_memory
/
(
julong
)
2
,
total_memory
-
(
julong
)
160
*
M
);
initHeapSize
=
limit_by_allocatable_memory
(
initHeapSize
);
if
(
FLAG_IS_DEFAULT
(
MaxHeapSize
))
{
FLAG_SET_CMDLINE
(
uintx
,
MaxHeapSize
,
initHeapSize
);
FLAG_SET_CMDLINE
(
uintx
,
InitialHeapSize
,
initHeapSize
);
// Currently the minimum size and the initial heap sizes are the same.
set_min_heap_size
(
initHeapSize
);
}
if
(
FLAG_IS_DEFAULT
(
NewSize
))
{
// Make the young generation 3/8ths of the total heap.
FLAG_SET_CMDLINE
(
uintx
,
NewSize
,
((
julong
)
MaxHeapSize
/
(
julong
)
8
)
*
(
julong
)
3
);
FLAG_SET_CMDLINE
(
uintx
,
MaxNewSize
,
NewSize
);
}
#ifndef _ALLBSD_SOURCE // UseLargePages is not yet supported on BSD.
FLAG_SET_DEFAULT
(
UseLargePages
,
true
);
#endif
// Increase some data structure sizes for efficiency
FLAG_SET_CMDLINE
(
uintx
,
BaseFootPrintEstimate
,
MaxHeapSize
);
FLAG_SET_CMDLINE
(
bool
,
ResizeTLAB
,
false
);
FLAG_SET_CMDLINE
(
uintx
,
TLABSize
,
256
*
K
);
// See the OldPLABSize comment below, but replace 'after promotion'
// with 'after copying'. YoungPLABSize is the size of the survivor
// space per-gc-thread buffers. The default is 4kw.
FLAG_SET_CMDLINE
(
uintx
,
YoungPLABSize
,
256
*
K
);
// Note: this is in words
// OldPLABSize is the size of the buffers in the old gen that
// UseParallelGC uses to promote live data that doesn't fit in the
// survivor spaces. At any given time, there's one for each gc thread.
// The default size is 1kw. These buffers are rarely used, since the
// survivor spaces are usually big enough. For specjbb, however, there
// are occasions when there's lots of live data in the young gen
// and we end up promoting some of it. We don't have a definite
// explanation for why bumping OldPLABSize helps, but the theory
// is that a bigger PLAB results in retaining something like the
// original allocation order after promotion, which improves mutator
// locality. A minor effect may be that larger PLABs reduce the
// number of PLAB allocation events during gc. The value of 8kw
// was arrived at by experimenting with specjbb.
FLAG_SET_CMDLINE
(
uintx
,
OldPLABSize
,
8
*
K
);
// Note: this is in words
// Enable parallel GC and adaptive generation sizing
FLAG_SET_CMDLINE
(
bool
,
UseParallelGC
,
true
);
// Encourage steady state memory management
FLAG_SET_CMDLINE
(
uintx
,
ThresholdTolerance
,
100
);
// This appears to improve mutator locality
FLAG_SET_CMDLINE
(
bool
,
ScavengeBeforeFullGC
,
false
);
// Get around early Solaris scheduling bug
// (affinity vs other jobs on system)
// but disallow DR and offlining (5008695).
FLAG_SET_CMDLINE
(
bool
,
BindGCTaskThreadsToCPUs
,
true
);
return
JNI_OK
;
}
// This must be called after ergonomics because we want bytecode rewriting
// if the server compiler is used, or if UseSharedSpaces is disabled.
void
Arguments
::
set_bytecode_flags
()
{
...
...
@@ -2644,6 +2746,14 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs* args) {
return
result
;
}
// We need to ensure processor and memory resources have been properly
// configured - which may rely on arguments we just processed - before
// doing the final argument processing. Any argument processing that
// needs to know about processor and memory resources must occur after
// this point.
os
::
init_container_support
();
// Do final processing now that all arguments have been parsed
result
=
finalize_vm_init_args
(
&
scp
,
scp_assembly_required
);
if
(
result
!=
JNI_OK
)
{
...
...
@@ -3117,94 +3227,6 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
_exit_hook
=
CAST_TO_FN_PTR
(
exit_hook_t
,
option
->
extraInfo
);
}
else
if
(
match_option
(
option
,
"abort"
,
&
tail
))
{
_abort_hook
=
CAST_TO_FN_PTR
(
abort_hook_t
,
option
->
extraInfo
);
// -XX:+AggressiveHeap
}
else
if
(
match_option
(
option
,
"-XX:+AggressiveHeap"
,
&
tail
))
{
// This option inspects the machine and attempts to set various
// parameters to be optimal for long-running, memory allocation
// intensive jobs. It is intended for machines with large
// amounts of cpu and memory.
// initHeapSize is needed since _initial_heap_size is 4 bytes on a 32 bit
// VM, but we may not be able to represent the total physical memory
// available (like having 8gb of memory on a box but using a 32bit VM).
// Thus, we need to make sure we're using a julong for intermediate
// calculations.
julong
initHeapSize
;
julong
total_memory
=
os
::
physical_memory
();
if
(
total_memory
<
(
julong
)
256
*
M
)
{
jio_fprintf
(
defaultStream
::
error_stream
(),
"You need at least 256mb of memory to use -XX:+AggressiveHeap
\n
"
);
vm_exit
(
1
);
}
// The heap size is half of available memory, or (at most)
// all of possible memory less 160mb (leaving room for the OS
// when using ISM). This is the maximum; because adaptive sizing
// is turned on below, the actual space used may be smaller.
initHeapSize
=
MIN2
(
total_memory
/
(
julong
)
2
,
total_memory
-
(
julong
)
160
*
M
);
initHeapSize
=
limit_by_allocatable_memory
(
initHeapSize
);
if
(
FLAG_IS_DEFAULT
(
MaxHeapSize
))
{
FLAG_SET_CMDLINE
(
uintx
,
MaxHeapSize
,
initHeapSize
);
FLAG_SET_CMDLINE
(
uintx
,
InitialHeapSize
,
initHeapSize
);
// Currently the minimum size and the initial heap sizes are the same.
set_min_heap_size
(
initHeapSize
);
}
if
(
FLAG_IS_DEFAULT
(
NewSize
))
{
// Make the young generation 3/8ths of the total heap.
FLAG_SET_CMDLINE
(
uintx
,
NewSize
,
((
julong
)
MaxHeapSize
/
(
julong
)
8
)
*
(
julong
)
3
);
FLAG_SET_CMDLINE
(
uintx
,
MaxNewSize
,
NewSize
);
}
#ifndef _ALLBSD_SOURCE // UseLargePages is not yet supported on BSD.
FLAG_SET_DEFAULT
(
UseLargePages
,
true
);
#endif
// Increase some data structure sizes for efficiency
FLAG_SET_CMDLINE
(
uintx
,
BaseFootPrintEstimate
,
MaxHeapSize
);
FLAG_SET_CMDLINE
(
bool
,
ResizeTLAB
,
false
);
FLAG_SET_CMDLINE
(
uintx
,
TLABSize
,
256
*
K
);
// See the OldPLABSize comment below, but replace 'after promotion'
// with 'after copying'. YoungPLABSize is the size of the survivor
// space per-gc-thread buffers. The default is 4kw.
FLAG_SET_CMDLINE
(
uintx
,
YoungPLABSize
,
256
*
K
);
// Note: this is in words
// OldPLABSize is the size of the buffers in the old gen that
// UseParallelGC uses to promote live data that doesn't fit in the
// survivor spaces. At any given time, there's one for each gc thread.
// The default size is 1kw. These buffers are rarely used, since the
// survivor spaces are usually big enough. For specjbb, however, there
// are occasions when there's lots of live data in the young gen
// and we end up promoting some of it. We don't have a definite
// explanation for why bumping OldPLABSize helps, but the theory
// is that a bigger PLAB results in retaining something like the
// original allocation order after promotion, which improves mutator
// locality. A minor effect may be that larger PLABs reduce the
// number of PLAB allocation events during gc. The value of 8kw
// was arrived at by experimenting with specjbb.
FLAG_SET_CMDLINE
(
uintx
,
OldPLABSize
,
8
*
K
);
// Note: this is in words
// Enable parallel GC and adaptive generation sizing
FLAG_SET_CMDLINE
(
bool
,
UseParallelGC
,
true
);
// Encourage steady state memory management
FLAG_SET_CMDLINE
(
uintx
,
ThresholdTolerance
,
100
);
// This appears to improve mutator locality
FLAG_SET_CMDLINE
(
bool
,
ScavengeBeforeFullGC
,
false
);
// Get around early Solaris scheduling bug
// (affinity vs other jobs on system)
// but disallow DR and offlining (5008695).
FLAG_SET_CMDLINE
(
bool
,
BindGCTaskThreadsToCPUs
,
true
);
}
else
if
(
match_option
(
option
,
"-XX:+NeverTenure"
,
&
tail
))
{
// The last option must always win.
FLAG_SET_CMDLINE
(
bool
,
AlwaysTenure
,
false
);
...
...
@@ -3605,6 +3627,15 @@ jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_req
return
JNI_ERR
;
}
// This must be done after all arguments have been processed
// and the container support has been initialized since AggressiveHeap
// relies on the amount of total memory available.
if
(
AggressiveHeap
)
{
jint
result
=
set_aggressive_heap_flags
();
if
(
result
!=
JNI_OK
)
{
return
result
;
}
}
// This must be done after all arguments have been processed.
// java_compiler() true means set to "NONE" or empty.
if
(
java_compiler
()
&&
!
xdebug_mode
())
{
...
...
src/share/vm/runtime/arguments.hpp
浏览文件 @
dbcd7c00
/*
* Copyright (c) 1997, 201
4
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
8
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -365,6 +365,8 @@ class Arguments : AllStatic {
// Aggressive optimization flags.
static
void
set_aggressive_opts_flags
();
static
jint
set_aggressive_heap_flags
();
// Argument parsing
static
void
do_pd_flag_adjustments
();
static
bool
parse_argument
(
const
char
*
arg
,
Flag
::
Flags
origin
);
...
...
src/share/vm/runtime/globals.hpp
浏览文件 @
dbcd7c00
...
...
@@ -2068,13 +2068,23 @@ class CommandLineFlags {
product_pd(uint64_t, MaxRAM, \
"Real memory size (in bytes) used to set maximum heap size") \
\
product(bool, AggressiveHeap, false, \
"Optimize heap options for long-running memory intensive apps") \
\
product(uintx, ErgoHeapSizeLimit, 0, \
"Maximum ergonomically set heap size (in bytes); zero means use " \
"MaxRAM
/ MaxRAMFraction")
\
"MaxRAM
* MaxRAMPercentage / 100")
\
\
experimental(bool, UseCGroupMemoryLimitForHeap, false, \
"Use CGroup memory limit as physical memory limit for heap " \
"sizing") \
"sizing" \
"Deprecated, replaced by container support") \
\
diagnostic(bool, PrintContainerInfo, false, \
"Print container related information") \
\
diagnostic(bool, PrintActiveCpus, false, \
"Print the number of CPUs detected in os::active_processor_count") \
\
product(uintx, MaxRAMFraction, 4, \
"Maximum fraction (1/n) of real memory used for maximum heap " \
...
...
@@ -2091,6 +2101,19 @@ class CommandLineFlags {
product(uintx, InitialRAMFraction, 64, \
"Fraction (1/n) of real memory used for initial heap size") \
\
product(double, MaxRAMPercentage, 25.0, \
"Maximum percentage of real memory used for maximum heap size") \
\
product(double, MinRAMPercentage, 50.0, \
"Minimum percentage of real memory used for maximum heap" \
"size on systems with small physical memory size") \
\
product(double, InitialRAMPercentage, 1.5625, \
"Percentage of real memory used for initial heap size") \
\
product(intx, ActiveProcessorCount, -1, \
"Specify the CPU count the VM should use and report as active") \
\
develop(uintx, MaxVirtMemFraction, 2, \
"Maximum fraction (1/n) of virtual memory used for ergonomically "\
"determining maximum heap size") \
...
...
src/share/vm/runtime/os.hpp
浏览文件 @
dbcd7c00
...
...
@@ -152,8 +152,16 @@ class os: AllStatic {
static
size_t
page_size_for_region
(
size_t
region_size
,
size_t
min_pages
,
bool
must_be_aligned
);
static
void
initialize_initial_active_processor_count
();
LINUX_ONLY
(
static
void
pd_init_container_support
();)
public:
static
void
init
(
void
);
// Called before command line parsing
static
void
init_container_support
()
{
// Called during command line parsing.
LINUX_ONLY
(
pd_init_container_support
();)
}
static
void
init_before_ergo
(
void
);
// Called after command line parsing
// before VM ergonomics processing.
static
jint
init_2
(
void
);
// Called after command line parsing
...
...
src/share/vm/runtime/thread.cpp
浏览文件 @
dbcd7c00
...
...
@@ -3343,6 +3343,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
Arguments
::
init_version_specific_system_properties
();
// Parse arguments
// Note: this internally calls os::init_container_support()
jint
parse_result
=
Arguments
::
parse
(
args
);
if
(
parse_result
!=
JNI_OK
)
return
parse_result
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录