perf: use beam metadata for dependencies#670
Conversation
1f4f5da to
453246a
Compare
f25e9af to
7826847
Compare
453246a to
14f0eaa
Compare
14f0eaa to
9b2019a
Compare
a820e27 to
49ae40b
Compare
49ae40b to
eb1fdcd
Compare
katafrakt
left a comment
There was a problem hiding this comment.
I mostly tested it from the usage site. Seems nice for our large codebase. Good one. I left two comments of things I noticed.
Additional worry is that this is quite large change that would make backporting potentailly hard (unless we backport this too?)
| defp dependency_app_names(%Project{} = project) do | ||
| project | ||
| |> mix_dependency_app_names() | ||
| |> MapSet.union(configured_dependency_app_names(project)) |
There was a problem hiding this comment.
Wouldn't that effectively eliminate dependencies with app: false? I'm not sure how big of an edge case this is, but feels like a regression from previous approach.
| with {:ok, entries} <- Search.Indexer.create_index(project) do | ||
| Search.Store.replace(entries) | ||
| end | ||
| Search.Store.refresh_index(project) |
There was a problem hiding this comment.
Will this actually force reindex when nothing is changed in the filesystem?
There was a problem hiding this comment.
It did not, fixed!
This is true, though at the same time I'm not sure this belongs to 0.1, there's also the SQLite backend PR and upcoming compiler tracer PR that also significantly change the indexer and those don't belong to 0.1 either but to 0.2. |
eb1fdcd to
4f0b12a
Compare
4f0b12a to
de934ef
Compare
|
I agree this does not belong in 0.1. One solution would be to try to get through with all the large changes you mentioned (+ perhaps Hex intelligence) and try to cut out 0.2 RC soon. However, I don't know if this would meet the goal of NextLS feature-completeness. |
|
@katafrakt it would meet the main goals of 0.2, the rest of the milestone are bugfixes, so that strikes me as a good solution |
BEAM metadata provide all the information we need to index definitions, but not references. We only index deps definitions, so it makes sense to index from BEAM files for them.
This reduces a lot of work by skipping most of the work Extractors do for source files, only requiring to scan a few lines of code from the source file to refine the definition range(this is a bit hacky, but it seems to work well for most code, metaprogramming would be where we need to be more careful).
It also adds a new
Manifestfor incremental indexing. We were previously relying on theEntry.pathto get the file path to compare mtime against, but.beamfile paths are not stored in the Entry structs(nor should they be) which required me to rethink how we do incremental indexing. I added a Manifest(and a ManifestStore module to handle its lifecycle) which holds a mapping of file -> source files + file stats and all the metadata needed to determine if a file should be reindexed, and which entries are stale and need to be removed.Expert indexes in ~1.8 seconds for me without this change, and goes down to ~800ms with this change.
Another reason this change is interesting is that if we decide to use compiler tracers we will need a beam extractor(since compiler tracers provide us with the compile code's debug_info), and this sets the foundation for that.
This does not replace indexing of source files for the user project though, for two reasons:
.exsfiles like configuration and test, those don't produce .beam artifacts and therefore can't be indexed with this approach