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

Increase file descriptor limit in NativeAOT app process #82719

Open
akoeplinger opened this issue Feb 27, 2023 · 12 comments
Open

Increase file descriptor limit in NativeAOT app process #82719

akoeplinger opened this issue Feb 27, 2023 · 12 comments

Comments

@akoeplinger
Copy link
Member

akoeplinger commented Feb 27, 2023

CoreCLR and soon Mono (after #82429) call a function that will increase the maximum open file descriptors via a function like this, should NativeAOT do the same?

/*++
Function:
INIT_IncreaseDescriptorLimit [internal]
Abstract:
Calls setrlimit(2) to increase the maximum number of file descriptors
this process can open.

/cc @dotnet/ilc-contrib

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Feb 27, 2023
@ghost
Copy link

ghost commented Feb 27, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Both CoreCLR and Mono call a function that will increase the maximum open file descriptors via a function like this, should NativeAOT do the same?

/*++
Function:
INIT_IncreaseDescriptorLimit [internal]
Abstract:
Calls setrlimit(2) to increase the maximum number of file descriptors
this process can open.

/cc @dotnet/ilc-contrib

Author: akoeplinger
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

@VSadov
Copy link
Member

VSadov commented Feb 27, 2023

It probably makes sense, just for parity purposes.
I am curious - are there specific reasons for this in CoreCLR/Mono or is it "just in case"? Any interesting history for why the call was introduced?

@jkotas
Copy link
Member

jkotas commented Feb 27, 2023

FWIW, this is disabled on Alpine and nobody ever complained about it there:

# Setting RLIMIT_NOFILE breaks debugging of coreclr on Alpine Linux for some reason
add_definitions(-DDONT_SET_RLIMIT_NOFILE)

@akoeplinger
Copy link
Member Author

akoeplinger commented Feb 27, 2023

I don't know about the historical context (the function was already part of the initial CoreCLR github commit) but we recently saw issues if this isn't done during NuGet restore: #82428

@jkotas
Copy link
Member

jkotas commented Feb 27, 2023

historical context

This was part of the original Rotor PAL: https://github.com/SSCLI/sscli_20021101/blob/77d46e0f04f52052a12ac40ce2cf96712c934b3c/pal/unix/init/pal.c#L629 .

@VSadov
Copy link
Member

VSadov commented Feb 27, 2023

I remember there was a bug fix for when we could temporarily have too many fd's. I'll try finding details.

@VSadov
Copy link
Member

VSadov commented Feb 27, 2023

Maybe it was to compensate for #47859 ?
(Assembly.Load opens /dev/zero in linux and does not close it)

It was fixed in #48140

@VSadov
Copy link
Member

VSadov commented Feb 27, 2023

At the time of Rotor using /dev/zero for anonymous memory mapping was likely the "right" way.

@akoeplinger
Copy link
Member Author

Given we're seeing #82428 when the limit is not increased I think it still makes sense to have it, though you could argue that with NativeAOT in library mode maybe the embedding application should have the final say.

@VSadov
Copy link
Member

VSadov commented Feb 27, 2023

The scenario with NuGet looks real. The app has a scenario that may open 1K+ files and gets away with that on CorCLR, making this a compat issue.

I think we should increase the limit on NativeAOT and perhaps on Alpine too, unless the reason (debugging is broken) is still there.

@VSadov
Copy link
Member

VSadov commented Feb 27, 2023

NativeAOT in library mode maybe the embedding application should have the final say.

No compat concerns in this case.
It might be strange if library does this, especially if dynamically loaded.

@agocke
Copy link
Member

agocke commented Feb 27, 2023

It seems reasonable to match the CoreCLR behavior here.

@agocke agocke added this to the Future milestone Feb 27, 2023
@agocke agocke removed the untriaged New issue has not been triaged by the area owner label Feb 27, 2023
@akoeplinger akoeplinger changed the title Investigate whether to increase file descriptor limit in NativeAOT process Increase file descriptor limit in NativeAOT app process Mar 1, 2023
DrewScoggins added a commit to DrewScoggins/runtime that referenced this issue Nov 6, 2023
Alpine does not automatically increase the file handle limit to the maximum. dotnet#82719 (comment)
As a result we need to increase the limit manually, as we are seeing "Too many files" errors.
DrewScoggins added a commit that referenced this issue Nov 7, 2023
* Add file handle limit setting for Alpine

Alpine does not automatically increase the file handle limit to the maximum. #82719 (comment)
As a result we need to increase the limit manually, as we are seeing "Too many files" errors.

* Bump limit to hard cap

* Remove space
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

4 participants