-
Notifications
You must be signed in to change notification settings - Fork 31
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
Performance bug: Many OPA processes spawned during editing #81
Comments
Hey @Octogonapus ! And thanks for reporting this. That's interesting 🤔 The commands launched by this plug-in should generally be very short lived... can you see which commands (i.e |
For my test, I opened a rego file and copy-pasted a line a few times within the file. These processes were spawned:
I have had to redact folder/file names. I don't know why Treating the workspace as a bundle could be a useful feature if there was indexing in place to avoid searching it repeatedly. I tried setting |
Thank you! That's useful. That command indeed hangs "forever" unless input is provided: opa oracle find-definition --stdin-buffer --bundle . policy.rego:1 I suppose the thing to investigate in the scope of this plugin would be why there's no input passed to the command. |
I think the problem here is that OPA is trying to read the contents of all the files in the bundle. E.g. opa oracle find-definition --stdin-buffer --bundle=file:///home/salmon/Documents/a/b /home/salmon/Documents/a/c/d/e.rego:638
error: bundle /home/salmon/Documents/a/b: bundle file 'foo.mp4' exceeded max size (1073741824 bytes) There are many such files in that bundle location. It's not feasible to load everything each time I make a code change. Is there a way to:
|
Hmm, the "easy" way around it would probably be to just not load a workspace including lots of large binary files. Most OPA commands will allow you to specify an Is keeping the large files outside of the policy workspace ruled out as an alternative? |
For now, I can make edits in a new workspace containing just the Rego code, though it would be helpful if I could continue using one large workspace as I am always working in multiple projects. Some of these projects do require having these large files in the workspace. |
That makes sense. I know some work is being prepared for open-policy-agent/opa#4041 ... which would likely change a lot for the better, for VS Code integration and elsewhere... but it'll be a while, I'm sure. |
Chiming in to add my experience with a different use case. For context, I'm mainly using the OPA extension for code highlighting and use the OPA CLI for any testing, formatting, or evaluation so that I can specify the exact OPA version for those commands (using the OPA asdf plugin for version management). I've run into this performance issue recently after adding several hundred additional Rego files to a git repo, which I open as a workspace in VS Code. The performance issues cause VS Code to freeze for up to a couple minutes and also cause Mac OS to freeze during that time. In my case, the workaround of opening only a sub-folder of Rego files as a VS Code workspace would make working with the policy library overall more difficult. |
Some additional findings from the last few days after disabling the OPA extension. In the past few months I had been seeing Since disabling the OPA VSC extension, those errors are no longer occurring, which would make sense if the OPA VSC extension is creating many new processes. |
Try and fix errors issues reported here: open-policy-agent/vscode-opa#81 1. Only include .rego files in definition location checks 2. Don't hang if input not provided on stdin Signed-off-by: Anders Eknert <[email protected]>
Should probably be made more robust here, but some minor tweaks to the OPA command should help too: open-policy-agent/opa#5678 |
Try and fix errors issues reported here: open-policy-agent/vscode-opa#81 1. Only include .rego files in definition location checks 2. Don't hang if input not provided on stdin Signed-off-by: Anders Eknert <[email protected]>
Try and fix errors issues reported here: open-policy-agent/vscode-opa#81 1. Only include .rego files in definition location checks 2. Don't hang if input not provided on stdin Signed-off-by: Anders Eknert <[email protected]>
Try and fix errors issues reported here: open-policy-agent/vscode-opa#81 1. Only include .rego files in definition location checks 2. Don't hang if input not provided on stdin Signed-off-by: Anders Eknert <[email protected]>
Try and fix errors issues reported here: open-policy-agent/vscode-opa#81 1. Only include .rego files in definition location checks 2. Don't hang if input not provided on stdin Signed-off-by: Anders Eknert <[email protected]>
Try and fix errors issues reported here: open-policy-agent/vscode-opa#81 1. Only include .rego files in definition location checks 2. Don't hang if input not provided on stdin Signed-off-by: Anders Eknert <[email protected]>
Is anyone still seeing this with the latest version(s) of OPA? |
I was having issues until i came across this thread.. i've set |
@ikunduraci were you till seeing that using the latest version of OPA? That includes some fixes in the command called by this plugin which hopefully should remedy that issue. |
@pauly4it same question to you :) |
I was on 0.46.1, just updated to 0.52.0.. will post back if i see the same behavior. Thanks for your help |
Haven't heard back, so I'll assume this is no longer an issue unless someone tells me it is :) Closing for now. |
I'm actually seeing this behavior in 0.64.1 version and VS code extension version 0.13.4
|
Hi Dolev 👋 Could you bump the extension to v0.14.0? If you have Regal installed, and I assume you do ;) that is now being used as the provider for the find definition feature. (we might need to look into why this feature might hang though, but we'll do that in that project) |
Just did - issue hasn't returned! |
When editing a rego file and using operations like copy/pasting variable names around, or when using undo or redo, many opa processes are spawned (anywhere between 3 and 16 on my machine). This uses a large (or 100% depending) amount of CPU and a large amount of memory, lagging both vscode and my system. This occurs when editing small files (50 lines or less) in a small project (300 lines total).
I am not sure how to debug this further, please let me know if there is anything you want me to try.
linux 5.19.6-200.fc36.x86_64
vscode v1.71.0
vscode-opa v0.12.1
opa v0.43.0
The text was updated successfully, but these errors were encountered: