-
Notifications
You must be signed in to change notification settings - Fork 138
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
state: Track module directory ModTime #989
Comments
@jpogran raised some valid concerns/questions yesterday:
I want to try to find answer to (2) in particular as that looks like a solution that would better align with LSP spec, where the client watches for changes and notifies the server. The only challenge is that we cannot easily treat pure existence of a module (as entry in memdb) as a guarantee that the module has all the data (i.e. that it was parsed, decoded etc.), so we'd likely need to do some deeper checking of the module - e.g. check the terraform-ls/internal/state/module.go Lines 84 to 121 in ca335f5
|
Closing in favour of #1002 |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Background
Currently, whenever we schedule
ParseModuleConfiguration
,ParseVariables
, orParseModuleManifest
from anywhere, we just parse these files without checking whether we have already parsed the exact same file (with the same content) previously.The scheduler already de-duplicates jobs, such that we never run the same job for the same folder more than once, if it's already in the queue. This is a good barrier, but we anticipate the following features to put more pressure on the scheduler and create more situations of duplicate work (same job for the same folder) scheduled more sparsely, which the scheduler itself has no chance of catching.
To avoid wasting CPU on these unnecessary jobs we need some way of checking what files we have processed and whether they changed since.
The simplest way to do it would be reading, storing and comparing
ModTime()
(modification time) of the module folder.Proposal
DirModTime time.Time
tostate.Module
state
: AddlastModTime time.Time
as a 2nd argument toModuleStore.Add(modPath string)
state
: IntroduceModuleStore.HasChangedSince(modPath string, t time.Time) (bool, error)
walker
: CheckModTime()
of every dir and pass it toHasChangedSince()
before scheduling any jobstextDocument/didOpen
handler: CheckModTime()
of every dir and pass it toHasChangedSince()
before scheduling any jobsterraform-ls/internal/langserver/handlers/did_open.go
Lines 59 to 66 in 81b49a1
workspace/didChangeWorkspaceFolders
handler: CheckModTime()
of every dir and pass it toHasChangedSince()
before scheduling any jobsThe text was updated successfully, but these errors were encountered: