-
Notifications
You must be signed in to change notification settings - Fork 57
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
Cache project config on demand #1000
Conversation
server/src/server.ts
Outdated
if (changedPath.includes("build.ninja")) { | ||
let projectRoot = utils.findProjectRootOfFile(changedPath); | ||
if (projectRoot != null) { | ||
syncProjectConfigCache(projectRoot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe make this conditional on the setting, so potential issues of writing this file would be contained to having the setting on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the watch wouldn't be set up unless the setting is on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point :)
analysis/src/Packages.ml
Outdated
| None -> [] | ||
| Some namespace -> | ||
let cmt = Filename.concat libBs namespace ^ ".cmt" in | ||
Hashtbl.add pathsForModule namespace (Namespace {cmt}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the cache file is read, pathsForModule
will already have been populated when this line was executed when creating the cache, and here it is added again.
No consequence I can think of, but good practice to make sure things are not mutated after caching them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Let me think about how to make that better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's fine to leave in for now. I can't think of a consequence either. Maybe doing a Hashtbl.replace instead of add makes sense though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to go for people to try as an experimental feature.
Perhaps I'd add a short description in the PR's description that this watches build.ninja
and uses it to update a cache of files in the project sources and dependencies.
analysis/bin/main.ml
Outdated
| Some package -> Cache.cacheProject package | ||
| None -> print_endline "\"ERR\"") | ||
| [_; "cache-delete"; rootPath] -> ( | ||
Cfg.useProjectConfigCache := false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem to be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I meant to say the line Cfg.useProjectConfigCache := false
does not seem to be necessary in the delete command, as none of the code below is affected by it.
This reverts commit bc71f76.
* cache project config on demand * e2e for the new cache mode * only look up project files etc when needed * comment * Revert "only look up project files etc when needed" This reverts commit bc71f76. * remove now irrelevant comment * changelog * conditionally * rename * replace instead of add
Experimental support for caching the project config to speed up analysis.
It should be good enough to merge and get started testing, and we can then polish before making it the default.
You enable it via the
rescript.settings.cache.projectConfig.enabled
extension config option. It'll then watchbuild.ninja
and build a cache of (some of) the project config, that the analysis can then read as needed and avoid doing a bunch of work.In larger repos this has shown latency improvements of +8-9x. So a massive improvement.
Running it as experimental for a while to get some feedback, and then hopefully something that'll be easy and risk free to enable for everyone.