file_limit 0.0.2

utility functions to retrieve and set OS file limits
Documentation
  • Coverage
  • 0%
    0 out of 7 items documented0 out of 4 items with examples
  • Size
  • Source code size: 5.24 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.29 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • oh-its-jimjam/file_limit
    4 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jamperry

file_limit

A utility library to retrieve and set the file limits for the underlying process of Unix-based systems.

"Everything is a file"; thus a file can represent network sockets, pipes, files on a file-system, etc. Resource-intensive applications typically need to increase the default limit to the maximum. It is also beneficial for low-latency applications to increase the file limit to the maximum number and pre-allocate a data structure to hold the FDs to minimize memory allocations.

Get the current file limit

let cur_limit: usize = file_limit::get();

Get the number of maximum files that can be opened

let max_limit = file_limit::max();
match max_limit {
  Limit::Val(v) => ..., //v is the upper bound represented as a usize
  Limit::Inf => ..., //infinity repesents that there is no upper bound
}

Set the file limit to the maximum upper-bound

let new_lim = file_limit::set_to_max().unwrap();

If there is no upper-bound (set to infinity) then it will scale it by factor of 8.

To-do list

  1. Add support for Windows since it uses HANDLE as the equivalent of a unix file.

I welcome PRs to add support for Windows.