Skip to content

Increase the open file soft limit to the hard limit#347

Merged
edolstra merged 1 commit into
mainfrom
bump-file-limit
Feb 12, 2026
Merged

Increase the open file soft limit to the hard limit#347
edolstra merged 1 commit into
mainfrom
bump-file-limit

Conversation

@edolstra
Copy link
Copy Markdown
Collaborator

@edolstra edolstra commented Feb 11, 2026

Motivation

On some platforms (macOS), the default soft limit is very low, but the hard limit is high. So let's just raise it the maximum permitted.

Context

Summary by CodeRabbit

  • Chores
    • Improved system-level file descriptor handling on non-Windows platforms to raise the soft limit up to the hard limit where possible.
    • Applied automatically during application initialization as a best-effort step; failures are ignored to avoid impacting startup.
    • Aims to support higher concurrent file operations without changing existing initialization behavior.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

A new non-Windows-only function bumpFileLimit() was added to raise the process soft limit for open file descriptors (RLIMIT_NOFILE) up to the hard limit using getrlimit/setrlimit; it is called at the end of initNix(bool loadConfig) during initialization. (46 words)

Changes

Cohort / File(s) Summary
File Descriptor Limit Configuration
src/libmain/shared.cc
Added bumpFileLimit() (non-Windows) which reads RLIMIT_NOFILE via getrlimit and, if needed, sets the soft limit to the hard limit with setrlimit (errors ignored). Invoked at end of initNix(bool loadConfig). Also added #include <sys/resource.h> guarded by platform.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I nudged the limits, soft to hard,

More files to open, working hard.
A tiny bump, a sysadmin's cheer,
Nix wakes up with room to steer.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Increase the open file soft limit to the hard limit' directly and specifically describes the main change made in the pull request, which adds a bumpFileLimit() function to increase the soft limit for open files (RLIMIT_NOFILE) to the hard limit.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bump-file-limit

No actionable comments were generated in the recent review. 🎉


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/libmain/shared.cc`:
- Around line 119-137: The build breaks on some platforms because
bumpFileLimit() uses struct rlimit and the getrlimit/setrlimit functions without
directly including the header that declares them; add a platform-guarded include
of <sys/resource.h> at the top of the file (guarded by `#ifndef` _WIN32 if needed)
so that struct rlimit, getrlimit, and setrlimit are declared where
bumpFileLimit() is defined.

Comment thread src/libmain/shared.cc
On some platforms (macOS), the default soft limit is very low, but the
hard limit is high. So let's just raise it the maximum permitted.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 11, 2026

@github-actions github-actions Bot temporarily deployed to pull request February 11, 2026 20:47 Inactive
@edolstra
Copy link
Copy Markdown
Collaborator Author

Upstream NixOS#15205.

@edolstra edolstra added this pull request to the merge queue Feb 12, 2026
Merged via the queue into main with commit 2ba1402 Feb 12, 2026
28 checks passed
@edolstra edolstra deleted the bump-file-limit branch February 12, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants