Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-3173. Provide better default JVM options #710

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions hadoop-ozone/dist/src/shell/hdds/hadoop-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,21 @@ function hadoop_translate_cygwin_path
fi
}

## @description Adds default GC parameters
## @description Only for server components and only if no other -XX parameters
## @description are set
## @audience private
## @stability evolving
## @replaceable yes
function hadoop_add_default_gc_opts
{
if [[ "${HADOOP_SUBCMD_SUPPORTDAEMONIZATION}" == true ]]; then
if [[ ! "$HADOOP_OPTS" =~ "-XX" ]] ; then
hadoop_debug "Appending default GC parameter to the HADOOP_OPTS"
HADOOP_OPTS="${HADOOP_OPTS} -XX:ParallelGCThreads=8 -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UseConcMarkSweepGC was deprecated in JDK8.

-XX:+UseConcMarkSweepGC
Enables the use of the CMS garbage collector for the old generation. Oracle recommends that you use the CMS garbage collector when application latency requirements cannot be met by the throughput (-XX:+UseParallelGC) garbage collector. The G1 garbage collector (-XX:+UseG1GC) is another alternative.

By default, this option is disabled and the collector is chosen automatically based on the configuration of the machine and type of the JVM. When this option is enabled, the -XX:+UseParNewGC option is automatically set and you should not disable it, because the following combination of options has been deprecated in JDK 8: -XX:+UseConcMarkSweepGC -XX:-UseParNewGC.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but as I learned from @arp7 we have no better option, right now. As I know G1 doesn't provide the same performance (yet).

The idea here was provide some very basic default to avoid bad experience for the users who use Ozone out-of-the-box. And advanced users can set any smart default.

Or do you suggest G1 by default?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not sure which is better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which is better heavily depends on the workload, but as the main workload are RPC calls with mostly short lived objects in our server processes, CMS is better due to the easier newGen eviction and low number of tenuring/surviving objects. At least this is the experience from HDFS and our workload on the DN and OM/SCM is very similar to HDFS server roles and consist mainly RPC calls while handling large metadata structures. G1 can be tuned for this kind of workload, but it is not the best performing one for this due to the segmented heap structure.

fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we print a warning or message if any -XX options are set, that we are not overriding the GC parameters?

fi
}
## @description Adds the HADOOP_CLIENT_OPTS variable to
## @description HADOOP_OPTS if HADOOP_SUBCMD_SUPPORTDAEMONIZATION is false
## @audience public
Expand Down
2 changes: 2 additions & 0 deletions hadoop-ozone/dist/src/shell/ozone/ozone
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ IFS=$OIFS

hadoop_add_client_opts

hadoop_add_default_gc_opts

if [[ ${HADOOP_WORKER_MODE} = true ]]; then
hadoop_common_worker_mode_execute "${HADOOP_HDFS_HOME}/bin/ozone" "${HADOOP_USER_PARAMS[@]}"
exit $?
Expand Down
44 changes: 44 additions & 0 deletions hadoop-ozone/dist/src/test/shell/gc_opts.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.



#
# Can be executed with bats (https://github.com/bats-core/bats-core)
# bats gc_opts.bats (FROM THE CURRENT DIRECTORY)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my first experiment, will see how does it work and eventually we can make it part of the main tests.

The only problem what I have found until now that the test script is copied to /tmp by bats, I couldn't use any smart, relative path (like COMPOSE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"). Which means bats should be executed always from the same dir where the test is.

But I can live with it.

#

source ../../shell/hdds/hadoop-functions.sh
@test "Setting Hadoop GC parameters: add GC params for server" {
export HADOOP_SUBCMD_SUPPORTDAEMONIZATION=true
export HADOOP_OPTS="Test"
hadoop_add_default_gc_opts
[[ "$HADOOP_OPTS" =~ "UseConcMarkSweepGC" ]]
}

@test "Setting Hadoop GC parameters: disabled for client" {
export HADOOP_SUBCMD_SUPPORTDAEMONIZATION=false
export HADOOP_OPTS="Test"
hadoop_add_default_gc_opts
[[ ! "$HADOOP_OPTS" =~ "UseConcMarkSweepGC" ]]
}

@test "Setting Hadoop GC parameters: disabled if GC params are customized" {
export HADOOP_SUBCMD_SUPPORTDAEMONIZATION=true
export HADOOP_OPTS="-XX:++UseG1GC -Xmx512"
hadoop_add_default_gc_opts
[[ ! "$HADOOP_OPTS" =~ "UseConcMarkSweepGC" ]]
}