Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating pipe: Too many open files #182

Closed
ZelCloud opened this issue Apr 19, 2022 · 5 comments
Closed

Creating pipe: Too many open files #182

ZelCloud opened this issue Apr 19, 2022 · 5 comments

Comments

@ZelCloud
Copy link

I'm trying to use perspective state save, for about 20+ buffers and 3 named workspaces. For a very small number of buffers everything works fine, but when I cross this threshold I keep getting the error perspective create pipe too many open files. It will also mangle my perspective names into a random string of numbers and characters. I'm not sure if I'm doing something wrong, if there's an issue in my setup or what could be the problem. Any advice would be helpful.

System - Windows 10
Emacs - 28.1 (gnu emacs using runemacs.exe- zipped version not installer if that makes any difference)
perspective.el latest

(use-package perspective
  :ensure t
  :defer nil
  :demand t
  :config
  (persp-mode)

  (setq persp-state-default-file "C:/Users/%USERNAME%/.emacs.d/perspective-save-state-file")
  (persp-state-load "C:/Users/%USERNAME%/.emacs.d/perspective-save-state-file")

  (persp-switch "main")

  (add-hook 'kill-emacs-hook #'persp-state-save)
  )

Also an aside, I've also tried this out with persp-mode and had similar issues,
Bad-ptr/persp-mode.el#131

@gcv
Copy link
Collaborator

gcv commented Apr 19, 2022

20 buffers and 3 perspectives isn't very much. It's routine for me (though I don't use Windows), and should not cause problems. It's pretty unlikely that Perspective runs out of file descriptors.

I recently read something about this problem, and found a theory that Treemacs or LSP on a large repository could be responsible (https://old.reddit.com/r/emacs/comments/ty5i2l/emacs_28_29_watching_eln_files_and_causing_too/).

Do you use Treemacs, LSP, Eglot, or something else that might be causing Emacs to open a large number of file descriptors?

@ZelCloud
Copy link
Author

I do have treemacs as an installed package, but its very rarely used.

I also do use LSP sometimes, this might be just be the crux of the problem. I'll experiment running perspective-state-load while ensuring lsp won't startup automatically (and have treemacs completely disabled). I'll report back my findings when I finish testing all this out.

Thanks for the advice / link @gcv.

@ZelCloud
Copy link
Author

Hey @gcv I've finished doing a bit of testing and I can confirm this isn't a problem with perspective or persp-mode themselves.

persp-mode-ref Bad-ptr/persp-mode.el#131

Breakdown of issues on Windows and different cases

"perspective.eL" and "persp-mode.el" both have issues on windows with lsp or treemacs more so the former, when trying to state save or load.

The range of files that can be safely restored seems to be around 30, 32~ to 40 seems to be a very hit or miss zone for me, sometimes it works in this range sometimes it doesn't. More than 40 files will absolutely never work for me regardless of modes / packages running. The number of perspectives themselves don't seem to matter.

lsp

LSP even on very small projects will try to pull in around 20~ files making the safe range in this case 10 files or less (mostly less). For projects that have a lot of boilerplate or packages (npm projects, rust projects, etc...) lsp will try to pull close to 30 files basically always putting you within the failure zone even with only one buffer being saved. So in short LSP + any perspective save or load is basically guaranteed to fail on windows.

Lsp also doesn't seem to properly close itself and seems to re-start when your do a persp-state-load through the startup hook, so starting and closing lsp before closing emacs doesn't seem to be a viable solution at this point.

treemacs

Treemacs will also try to pull additional files (pipes) but at a significantly smaller amount than lsp. Having treemacs open will decrease how many buffers you can have saved but it doesn't seem to be an instant failure like having lsp running is. (5-10 additional pipes range)

Random oddities

While opening more than 32~ files sometimes fails, if you do another persp-state-load after the failed load you can actually load all the buffers and perspective names correctly, but any modes or hooks functions will be reset and wont restart automatically.

Possible solution (probably out of scope)

For this to (mostly) work on windows it seems like we'd need 2 things. A way to ensure LSP never starts itself automatically regardless of modes. Secondly persp-state-load to only load the buffers of one perspective at a time instead of all the buffers across all perspectives,

@gcv
Copy link
Collaborator

gcv commented Apr 25, 2022

Thank you for investigating the problem. It seems like the open file limit is crazy low. I don't really understand it.

The idea of lazily loading perspective state has come up before (#157). Patches welcome. :)

@gcv
Copy link
Collaborator

gcv commented May 15, 2022

Since there isn't much we can do about this problem in Perspective, I'll close this ticket.

@gcv gcv closed this as completed May 15, 2022
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

No branches or pull requests

2 participants