caldwell / build-emacs

Build scripts for www.emacsformacosx.com
http://www.emacsformacosx.com/about
GNU General Public License v3.0
364 stars 61 forks source link

Max open files #127

Closed jiacai2050 closed 1 year ago

jiacai2050 commented 1 year ago
(shell-command-to-string "ulimit -a")

Will return

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 9792
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4000
virtual memory          (kbytes, -v) unlimited

The max open files is hard-coded in Emacs as 1024, I write a blog post explaining how to fix this, would you mind adding them to default build options?

./configure "CFLAGS=-DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT"
aronatkins commented 1 year ago

Frequently see the same problem (too many open files) using lsp-mode with gopls in a large repository.

caldwell commented 1 year ago

I added this to the nightlies yesterday. There are 2 builds that have this enabled:

Running the ulimit in scratch buffer gets me:

(shell-command-to-string "ulimit -a")
"core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 7168
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 9792
cpu time               (seconds, -t) unlimited
max user processes              (-u) 10666
virtual memory          (kbytes, -v) unlimited
"

I'd like to know if this fixes the LSP problems (I haven't seen that but I tend to work on smaller codebases).

aronatkins commented 1 year ago

Thanks. I'll start using the 06-29 build now and report back. Unfortunately, it often takes a few days of use before it shows up. With the upcoming US holiday, that won't be quite so immediate.

aronatkins commented 1 year ago

Recording my ulimit after the update (macOS Monterey 12.6.6):

-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             9788
-c: core file size (blocks)         0
-v: address space (kbytes)          unlimited
-l: locked-in-memory size (kbytes)  unlimited
-u: processes                       5568
-n: file descriptors                7168
aronatkins commented 1 year ago

I've flipped back to 28.2, as something in the dailies kept making Emacs unresponsive.. I don't think it was the open-files change, but I was not able to narrow the problem.

noc0lour commented 1 year ago

I added this to the nightlies yesterday. There are 2 builds that have this enabled:

* https://emacsformacosx.com/emacs-builds/Emacs-2023-06-28_13-01-07-d6bcb39ba9d46f7dc29e01551a1d35fe250695a9-universal.dmg

* https://emacsformacosx.com/emacs-builds/Emacs-2023-06-29_00-09-24-d6bcb39ba9d46f7dc29e01551a1d35fe250695a9-universal.dmg

Running the ulimit in scratch buffer gets me:

(shell-command-to-string "ulimit -a")
"core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 7168
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 9792
cpu time               (seconds, -t) unlimited
max user processes              (-u) 10666
virtual memory          (kbytes, -v) unlimited
"

I'd like to know if this fixes the LSP problems (I haven't seen that but I tend to work on smaller codebases).

Would it be possible to get an image with Emacs 29.1 and these build flags, the nightly/30.x images have other issues and I'd like to test drive this change. I basically run into this issue a few hours after opening Emacs since I have multiple lsp servers running for independent projects.

aronatkins commented 1 year ago

@noc0lour - Have you checked the 29.1 build? I'm seeing 7168 file descriptors, similar to what I was seeing with the earlier dailies..