jimeh / build-emacs-for-macos

Somewhat hacky script to automate building of Emac.app on macOS.
484 stars 50 forks source link

feat: Add option for max file descriptors #107

Closed jesse-c closed 2 weeks ago

jesse-c commented 5 months ago

People usually change the macOS system-level max file descriptors limits. Unfortunately, this doesn't change the value of FD_SETSIZE which is compiled into Emacs, which is used over the system-level size(s).

This options lets users specify an integer value for the CFLAGS option FD_SETSIZE.

This was based on the helpful work by Jiacai Liu [1].

I built Emacs with ./build-emacs-for-macos --native-full-aot --native-march --git-sha 9a2088b --no-archive emacs-30. That SHA was chosen from the current Homebrew recipe [2], that I'm using as my daily driver.

When I evaluated (message (shell-command-to-string "ulimit -n")), it printed 1024.

I then built it again, this time adding --fd-setsize 2048. When I evaluated that same Elisp, it printed 2048, as expected!

That I could actually open that many file descriptors was confirmed with the same test [1].

[1] https://en.liujiacai.net/2022/09/03/emacs-maxopenfiles/ [2] https://github.com/jimeh/homebrew-emacs-builds/blob/fc3103965c2e46665c7b085033ac6a40ee6a316d/Casks/emacs-app-monthly.rb#L12C115-L12C122

FIXES #106

jesse-c commented 5 months ago

update: I became wary of CFLAGS being constructed correctly as this added a 2 option where it was used. I've refactored it to build a list and then concat→join it once.

jimeh commented 2 weeks ago

This is superseded by #115.

Thanks for this submission @jesse-c. Apologies for not getting to this sooner, but I've ended up doing this as part of my work on adding Nix support (as an alternative to Homebrew), so I lifted #115 out of the early stages of that work.