How to increase quantity of file descriptors on MacOS Mojave? - macos

Can't find a way to do this, every version of MacOS use a different version and Mojave still very recent, so can't find anything.

Programmatically, you can use getrlimit() and setrlimit() to adjust the number of file descriptors the process can open. The relevant resource identifier is RLIMIT_NOFILE.
As noted in the man page, RLIMIT_NOFILE works somewhat differently than other resources. getrlimit() might indicate that the hard limit is RLIM_INFINITY (unlimited), but the kernel actually imposes a limit of OPEN_MAX (currently 10240). So, treat that as the maximum that you can set using setrlimit().
To do this for a program whose code you don't control, you can adjust the limit in a shell before launching that program from that shell. In bash and other sh-derived shells, you can use the ulimit built-in command for that. For example, ulimit -Sn 10240.

Related

What is `kern.num_files` in `sysctl`?

I'm trying to find out total number of currently open file descriptors (or any file related objects) on current OS.
My current betting is sysctl(3), and I think kern.num_files does the job. But I'm not actually sure what it means, and I can't find any manual page entry or standard spec for kern.num_files. This makes me nervous.
kern.num_files is listed on man 3 sysctl, but only names are listed and says nothing about what it actually means.
Command line sysctl -a(2) lists and report some value for kern.num_files.
sysctl.h does not define a name looks like kern.num_files
although it even contains names like KERN_FILE that are considers private/deprecated.
Is this actually the count of system-wide open FD? Where can I find any spec for this?
If kern.num_files is not the number, what is recommended way to get the total open FD count?

how increase the maximum number of simultaneously existing ports in erlang using windows

i am using windows and i want to Set the maximum number of simultaneously existing ports to 65536. in Erlang docs it says:
ERLAG doc here , visit for syntax
+Q Number|legacy
Sets the maximum number of simultaneously existing ports for this system if a Number is passed as value. Valid range for
Number is [1024-134217727]
On Windows the default value is set to 8196 because the normal OS
limitations are set higher than most machines can handle.
If legacy is passed as value, the legacy algorithm for allocation of
port identifiers will be used. Using the legacy algorithm, identifiers
will be allocated in a strictly increasing fashion until largest
possible identifier has been reached. Note that this algorithm suffers
from performance issues and can under certain circumstances be
extremely expensive. The legacy algoritm is deprecated, and the legacy
option is scheduled for removal in OTP-R18.
i used below syntax but it gives me syntax error, whats wrong ?
Since my reputation doesnt allow me to just comment, I'll just answer...
If you dont like to start the erlang VM through a batch script or the command window, you can create a link to the werl.exe and edit the Command it executes by right clicking and changing the Properties of said link. For example:
Default link Target: "C:\Program Files (x86)\erl5.10.4\bin\werl.exe"
Would become: "C:\Program Files (x86)\erl5.10.4\bin\werl.exe" +Q 65536
This also allows for different configurations for different projects/applications.
Another way would be, to use .bat scripts instead of a link.

block a command in ubuntu(in shell)

I am working on ubuntu server with 10 users at any point of time. We usually keep our code there and use the server to make builds. The build usually takes 30 to 50 minutes based on concurrency defined. The build command is make -jX where X can be anything from 1 to 24.
My problem starts when many users start giving make command with higher X value. Is there any way to block these commands or to put any limit.
For example, if someone gives make -jX (X>4), I should be able to override the command as make -j4.
I know one way is to use alias but I have no idea how to interpret the argument value through alias (like alias ll='ls -la' in .bashrc file is ok but how to interpret ll -lha through bashrc).
Also is there any way to make the alias work for all the users without editing the bashrc files of all the users?
Thanks in advance.
Although limiting the parameters to a particular command (in this case make) in a way that cannot be circumvented is generally hard, you can configure system-level process limits on each user using /etc/security/limits.conf.
If you open this file on your system, you will see in the comments that you can limits various user resources such as nproc and memory. If you play with these limits, you may be able to get something reasonable to get fair resource sharing among your developers.

does vim read the whole file into memory

When I open a file, does vim read it all into memory? I experienced significant slowdowns when I open large files. Or is it busy computing something (e.g., line number)?
Disabling features like syntax highlighting, cursorline, line numbers and so on will greatly reduce the load and make Vim snappier in these cases.
There's even a plugin to handle that for you and a Vim tip for some background info.
Yes, Vim loads the whole file into memory.
If you run htop in another pane you can watch it happen in real time.
If you don't have enough memory available, it will start hitting the swap which makes it take even longer.
You can disable plugins and heavy features (like syntax highlighting) to get improved performance (the -u effectively tells vim not to load your ~/.vimrc):
vim -u NONE mysqldump.sql
However, unless you really need to edit the file, I prefer to just use a different tool. I typically use less. I mostly search the files in vim with / and less supports that just fine.
less mysqldump.sql

Windows equivalent of ulimit -n

What is the windows equivalent of the unix command " ulimit -n" ?
Basically, i want to set the maximum fd limit via command prompt.
I don't believe that current Windows O/S have a limit on the total number of file descriptors, but the MS runtime library (msvcrt.dll) has a per process limit of 2048, albeit as far as I know that's not enforced by the O/S.
It can allegedly be increased only by building your own version of the MS runtime library from source.
hmm... I may have been wrong before - setmaxstdio (see here) - but it is per-process, not system wide.
I may be wrong, but I didn't think there was a limit to set in Windows... but unless you can say how this relates to programming, I expect this answer will be closed soon.
If you are in the "IT Pro" area (rather than development), then there is a sister-site, serverfault.com - coming soon for this type of question.

Resources