-
Notifications
You must be signed in to change notification settings - Fork 206
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
Add -XX:-MaxFDLimit
to builder binaries to allow it use system open files limit
#811
Conversation
@oliviernotteghem is this the same fix that you mentioned using last week? |
Does this work with Java 8? The flags changed, which has been problematic. |
Based on a cursory look, it does according to here https://gist.github.com/ndimiduk/a6c2aa781c20fb8bb9c20abbcf5bac4f |
@Bencodes : this is actually the approach @nkoroste discussed. We worked around the issue at Uber by pruning transitives deps (which causes the # of file opened to decrease, since # of jar of the classpath is much smaller). Our initial fix was to limit the # of parallel jobs (it takes usually more than 1 compilation action to reach the 10k+ file opened at a given time), which obviously wasn't ideal IRT build time / parallelism. |
We are also pruning transitive deps in library targets and did not face issue there. This happens in the binary target so transitives are not avoidable. More specifically we get this error when Dagger tries to generate classes in the Kapt action. Bazel team prefers to adjust individual worker definitions instead of a global fix. |
@@ -43,6 +43,10 @@ java_binary( | |||
"@com_github_jetbrains_kotlin//:lib/jvm-abi-gen.jar", | |||
"@com_github_jetbrains_kotlin//:lib/kotlin-compiler.jar", | |||
], | |||
jvm_flags = [ | |||
"-XX:-MaxFDLimit", | |||
"-XX:+IgnoreUnrecognizedVMOptions", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially thought the flag was not supported in Java 8 so added this but it seems Java 8 is supported so this is not needed. #848 alone is fine I think.
For more context, there is a similar change in bazel core here: For us we needed this following change: Which allowed us to add the following
I think the cleanest fix would be to add this default on the low level toolchain and only apply it for macs/darwin |
When compiling large modules we noticed
KotlinKapt
would fail withToo many open files
on MacOS.We increased the shell limit manually from default 256 to 65536. Verified by running
ulimit -a
-t: cpu time (seconds) unlimited -f: file size (blocks) unlimited -d: data seg size (kbytes) unlimited -s: stack size (kbytes) 8176 -c: core file size (blocks) 0 -v: address space (kbytes) unlimited -l: locked-in-memory size (kbytes) unlimited -u: processes 5333 -n: file descriptors 65536
Even then the worker action failed, it seems that JVM has its own FD limit which can be changed to use the system/shell limits via
-XX:-MaxFDLimit
arg. Adding these tojava_binary
targets worked for us.References: