This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
Set lower-than-default priority for language-server #166
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
Use Node's
os
module to set the priority of the external process spawned by this extension to be below normal. This means that Atom and other processes that the user is actively interacting with will not be adversely affected by the background process that this extension needs. This will in some cases mean that the features provided by this extension may not be available as quickly initially, as the language server reads files and generates an index. It's up to the operating system to determine which processes are allowed CPU time; setting the priority of this background process helps it decide which processes are important to the user and which can be delayed when resources are scarce.Quantitative Performance Benefits
When the language server starts, it consumes 100% of one CPU core on my computers. When the change here is applied, the same occurs, however the process is running with a lower priority (higher 'nice' number), so the operating system is able to suitably prioritise other processes instead of this. In my test cases, adjacent long-running processes (eg, encoding a video with
ffmpeg
, compiling programs withgcc
andclang
) completed sooner. The differences are more noticeable with larger projects and when the system is otherwise very busy / low on resources.Possible Drawbacks
The features provided by this extension may not be available to users as quickly as without this change. This will only be a problem for users whose system is already under stress / low on available resources. Normal operation of this extension after the language server has finished its initial processing and generated its internal index will not be adversely affected by this change.
Verification Process
I tested the following features within a known-working project with this change applied (when using
atom --dev --foreground /path/to/big-project
)SomeClass::CONSTANT_NAME
,$object->method()
)Given the changes involved in this pull request, only minimal testing was carried out.
Applicable Issues
Release Notes
Set background process at lower priority to improve CPU availability