Skip to content

Commit

Permalink
Sets recommended max Xmx 32G when set_recommended_max_xmx experiment …
Browse files Browse the repository at this point in the history
…is enabled (#28442)

* Sets recommended max Xmx 32G when set_recommended_max_xmx experiment is enabled

* Fixing lint errors

* Adding comment to reason why 32G is recomemnded value
  • Loading branch information
arvindram03 authored Sep 19, 2023
1 parent d79f537 commit 08a9767
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sdks/java/container/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ func main() {
cp = append(cp, filepath.Join(dir, filepath.FromSlash(name)))
}

var setRecommendedMaxXmx = strings.Contains(options, "set_recommended_max_xmx")
args := []string{
"-Xmx" + strconv.FormatUint(heapSizeLimit(info), 10),
"-Xmx" + strconv.FormatUint(heapSizeLimit(info, setRecommendedMaxXmx), 10),
// ParallelGC the most adequate for high throughput and lower CPU utilization
// It is the default GC in Java 8, but not on newer versions
"-XX:+UseParallelGC",
Expand Down Expand Up @@ -266,9 +267,14 @@ func makePipelineOptionsFile(options string) error {
// it returns 70% of the physical memory on the machine. If it cannot determine
// that value, it returns 1GB. This is an imperfect heuristic. It aims to
// ensure there is memory for non-heap use and other overhead, while also not
// underutilizing the machine.
func heapSizeLimit(info *fnpb.ProvisionInfo) uint64 {
if size, err := syscallx.PhysicalMemorySize(); err == nil {
// underutilizing the machine. if set_recommended_max_xmx experiment is enabled,
// sets xmx to 32G. Under 32G JVM enables CompressedOops. CompressedOops
// utilizes memory more efficiently, and has positive impact on GC performance
// and cache hit rate.
func heapSizeLimit(info *fnpb.ProvisionInfo, setRecommendedMaxXmx bool) uint64 {
if setRecommendedMaxXmx {
return 32 << 30
} else if size, err := syscallx.PhysicalMemorySize(); err == nil {
return (size * 70) / 100
}
return 1 << 30
Expand Down

0 comments on commit 08a9767

Please sign in to comment.