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

Adjust JVM heap size for extremely large memory machine #31567

Merged
merged 8 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion sdks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// directory.
module github.com/apache/beam/sdks/v2

go 1.20
go 1.21
Copy link
Contributor Author

@Abacn Abacn Jun 11, 2024

Choose a reason for hiding this comment

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

this is required for builtin max.

go 1.20 has already eol so we should bump it anyways.

Last time it was July 2023 bumped go 1.19->1.20.

Copy link
Contributor

Choose a reason for hiding this comment

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

A single use of max isn't sufficient cause to bump the minimum SDK version IMO. I'd recommend just writing the standard if instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

While I don't think it'll be a problem to do it as a rule, there's just other work that might be good to do when bumping the minimum version as well, and that's very out of scope of this PR.

Basically, bumping the minimum version is a huge change just to avoid a single if statement, compared to writing the conditional.


require (
cloud.google.com/go/bigquery v1.60.0
Expand Down
16 changes: 8 additions & 8 deletions sdks/java/container/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,18 @@ func main() {
}

// heapSizeLimit returns 80% of the runner limit, if provided. If not provided,
// 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. 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.
// it returns max(70% M, M - 32GB) where M 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.
// 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 max(size - (32 << 30), (size * 70) / 100)
}
return 1 << 30
}
Expand Down
Loading