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

Feature request: Allow disabling file handle limit warning #20923

Open
Taytay opened this issue May 14, 2024 · 2 comments
Open

Feature request: Allow disabling file handle limit warning #20923

Taytay opened this issue May 14, 2024 · 2 comments

Comments

@Taytay
Copy link

Taytay commented May 14, 2024

** Problem **
I am running in a linux environment that doesn't allow me to bump the file limit above 8192. As a result, every invocation of pants gives me the warning:

File handle limit is capped to: 8192. To avoid 'too many open file handle' errors, we recommend a limit of at least 10000: please see https://www.pantsbuild.org/docs/troubleshooting#too-many-open-files-error for more information.

Describe the solution you'd like
I looked at the source code to see if there was an env variable or setting to disable it, but I couldn't find it. I'm too new to pants to know what the convention is for this sort of thing, but it would be great to be able to acknowledge/suppress this.

@huonw
Copy link
Contributor

huonw commented May 15, 2024

Ah, yes, this would be annoying.

It sounds like you might've found where this is defined:

pub fn increase_limits() -> Result<String, String> {
loop {
let (cur, max) = rlimit::Resource::NOFILE
.get()
.map_err(|e| format!("Could not validate file handle limits: {e}"))?;
// If the limit is less than our target.
if cur < TARGET_NOFILE_LIMIT {
let err_suffix = format!(
"To avoid 'too many open file handle' errors, we recommend a limit of at least {TARGET_NOFILE_LIMIT}: \
please see https://www.pantsbuild.org/docs/troubleshooting#too-many-open-files-error \
for more information."
);
// If we might be able to increase the soft limit, try to.
if cur < max {
let target_soft_limit = std::cmp::min(max, TARGET_NOFILE_LIMIT);
rlimit::Resource::NOFILE
.set(target_soft_limit, max)
.map_err(|e| {
format!("Could not raise soft file handle limit above {cur}: `{e}`. {err_suffix}")
})?;
} else {
return Err(format!(
"File handle limit is capped to: {cur}. {err_suffix}"
));
}
} else {
return Ok(format!("File handle limit is: {cur}"));
};
}
}

That's called from

match fs::increase_limits() {

Which is called from

self._py_scheduler = native_engine.scheduler_create(

Three options to address this might be:

  1. use [GLOBAL].ignore_warnings: https://www.pantsbuild.org/2.20/reference/global-options#ignore_warnings to silence this (although I'm not 100% sure this'll work...)
  2. convert TARGET_NOFILE_LIMIT into a global option (with default 10000) that's passed down, so it can be customised when the env has a lower limit, e.g. target_file_handle_limit = 8192
  3. add a boolean option to silence this warning specific, e.g. allow_file_handle_limit_below_target = true or something.

I'm not sure what's best. Can you make 1 work?

@Taytay
Copy link
Author

Taytay commented May 17, 2024

Ah cool - I can give one of these a shot and see if they work. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants