-
Notifications
You must be signed in to change notification settings - Fork 25
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
server.rb spinning on 100% CPU trying to create tempfiles #278
Comments
Is there some kind of mitigation for this? I cannot remove |
Hi there, I have a hunch on what this might be. Do you have a large folder inside the workspace directory (like from activestorage)? I ran into something similar at Shopify/ruby-lsp#1665. I would try to disable bootsnap with Hope that helps and gives you some pointers for additional troubleshooting. |
This may also be the bug fixed in v0.3.2. Could you please test the new version and let us know if your issue is fixed? |
0.3.2 did not fix the issue, unfortunately:
I will have a look at @Earlopain's suggestions today |
I think I know what the issue is. I work with dev containers. When I start the Rails web app in a dev container, it mounts the source code directory as a host volume and bootsnap writes to ll tmp/
total 12K
4.0K lrwxrwxrwx. 1 mk 24 Mar 4 10:10 cache -> /data/cache/gitlab/cache Here, If until File.directory?(path)
stack.push path
path = File.dirname(path)
end From I think this problem is just symptomatic for ruby-lsp-rails assuming that it can boot the Rails app cleanly on the host OS. Is that an OK assumption to make when using containers? |
As a mitigation, can you think of a way to disable bootsnap only when it's ruby-lsp-rails trying to launch the Rails server process? I would not want to disable bootsnap when running the app ordinarily in a container. |
You can try starting the runner with If that is too much a hassle, this command might get some extra info: Disabling bootsnap conditionally should also be possible by examining <% unless $PROGRAM_NAME.end_with?("ruby-lsp") %>
inherit_from: .rubocop_todo.yml
<% end %> Something similar can probably be done for bootsnap as well, though you'd have to check what |
I mean, I think we know what the problem is already, it's that write(5, "=== Scanning /home/mk/Projects/w"..., 3391) = 3391
close(5) = 0
getpid() = 211223
openat(AT_FDCWD, "/tmp/ruby-lsp.log", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 5
ioctl(5, TCGETS, 0x7ffc745af370) = -1 ENOTTY (Inappropriate ioctl for device)
newfstatat(AT_FDCWD, "/home/mk/Projects/work/gl-gck/gitlab-rails/tmp/cache/bootsnap", 0x7ffc745af240, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/home/mk/Projects/work/gl-gck/gitlab-rails/tmp/cache", 0x7ffc745af240, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/home/mk/Projects/work/gl-gck/gitlab-rails/tmp", {st_mode=S_IFDIR|0755, st_size=250, ...}, 0) = 0
mkdir("/home/mk/Projects/work/gl-gck/gitlab-rails/tmp/cache", 0777) = -1 EEXIST (File exists)
newfstatat(AT_FDCWD, "/home/mk/Projects/work/gl-gck/gitlab-rails/tmp/cache", 0x7ffc745aeee0, 0) = -1 ENOENT (No such file or directory) The log messages are mine (I patched the gem to write a log file into the system tmp dir). The problem is
Yeah. We would have to patch the application's bootsnap initializer to do this, right? Seems kinda dirty, but I'll propose this as an option, thanks. I will close this issue here because I confirmed it is not specific to Thanks for helping out, appreciate it! |
Since bootsnap happens so early in the boot cycle, a initializer is already too late, especially if your application currently follows recommendations for the bootsnap rails setup. Check out the usage section in the docs, that explains what you need to do https://github.com/Shopify/bootsnap?tab=readme-ov-file#usage This actually mentions that tmp cache MUST be writable, however I'd wager that CPU spinning is still a bug. I would expect it to just raise/crash somewhere. A bug report over there seems like a good idea. |
Ah yes, my bad -- I meant to say Filing an issue against bootsnap makes sense to me. I agree it should not get itself stuck like that. Will cross link here when done. |
Looking at the bootsnap code again, I find it very likely that the following code is responsible for this: https://github.com/Shopify/bootsnap/blob/8394834cd504548aae3b4651587abd823f0495d1/lib/bootsnap/load_path_cache/store.rb#L107-L108 Your strace output seems to back that up as well. |
I am running into a bug that I can consistently reproduce, where the ruby-lsp-server component will start up and not terminate, consuming an entire CPU:
I took a CPU profile and found that it seems to spend most of that time trying to create a temp dir in an
asdf
managed directory:I have to TERM the process every single time it starts up.
Gemfile:
I use VSCode with the
ruby-lsp
v0.5.11 extension.The text was updated successfully, but these errors were encountered: