-
Notifications
You must be signed in to change notification settings - Fork 471
Use Eio for parallelizing some analysis commands #7840
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
base: master
Are you sure you want to change the base?
Changes from all commits
8c01864
951b61d
efec169
ea3636f
4fc600e
63ceb38
2357c2e
58d1393
966836b
b956b14
0663fc5
b265377
1c1e299
97f9e2b
4d74fcc
4352708
8d9d7f0
a72edaf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,12 +58,6 @@ jobs: | |
node-target: win32-x64 | ||
rust-target: x86_64-pc-windows-gnu | ||
|
||
# Verify that the compiler still builds with the oldest OCaml version we support. | ||
- os: ubuntu-24.04 | ||
ocaml_compiler: ocaml-variants.4.14.2+options,ocaml-option-static | ||
node-target: linux-x64 | ||
rust-target: x86_64-unknown-linux-musl | ||
|
||
runs-on: ${{matrix.os}} | ||
|
||
env: | ||
|
@@ -102,7 +96,7 @@ jobs: | |
uses: awalsh128/[email protected] | ||
with: | ||
# See https://github.com/ocaml/setup-ocaml/blob/b2105f9/packages/setup-ocaml/src/unix.ts#L9 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The addition of Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you fix this Copilot? |
||
packages: bubblewrap darcs g++-multilib gcc-multilib mercurial musl-tools rsync | ||
packages: bubblewrap darcs g++-multilib gcc-multilib mercurial musl-tools rsync linux-libc-dev dpkg-dev | ||
version: v3 | ||
|
||
- name: Restore rewatch build cache | ||
|
@@ -179,6 +173,13 @@ jobs: | |
await fs.writeFile('.opam-path', opamPath, 'utf-8'); | ||
console.log('stored path to .opam-path'); | ||
|
||
- name: Configure Linux include paths | ||
if: runner.os == 'Linux' | ||
run: | | ||
arch=$(dpkg-architecture -qDEB_HOST_MULTIARCH) | ||
echo "C_INCLUDE_PATH=/usr/include:/usr/include/$arch" >> "$GITHUB_ENV" | ||
echo "CPATH=/usr/include:/usr/include/$arch" >> "$GITHUB_ENV" | ||
|
||
- name: Install OPAM dependencies | ||
if: steps.cache-opam-env.outputs.cache-hit != 'true' | ||
run: opam install . --deps-only --with-test | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ | |
(package analysis) | ||
(modes byte exe) | ||
(name main) | ||
(libraries analysis)) | ||
(libraries analysis eio eio_main)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,7 +119,7 @@ let main () = | |
| [_; "cache-delete"; rootPath] -> ( | ||
Cfg.readProjectConfigCache := false; | ||
let uri = Uri.fromPath rootPath in | ||
match Packages.findRoot ~uri (Hashtbl.create 0) with | ||
match Packages.findRoot ~uri with | ||
| Some (`Bs rootPath) -> ( | ||
match BuildSystem.getLibBs rootPath with | ||
| None -> print_endline "\"ERR\"" | ||
|
@@ -194,21 +194,23 @@ let main () = | |
Sys.argv.(len - 1) <- ""; | ||
Reanalyze.cli () | ||
| [_; "references"; path; line; col] -> | ||
Commands.references ~path | ||
~pos:(int_of_string line, int_of_string col) | ||
~debug | ||
Eio_main.run (fun env -> | ||
Commands.references ~env ~path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does references need to take an env now and not before? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because it's using Eio, and that requires the Eio env. |
||
~pos:(int_of_string line, int_of_string col) | ||
~debug) | ||
| [_; "rename"; path; line; col; newName] -> | ||
Commands.rename ~path | ||
~pos:(int_of_string line, int_of_string col) | ||
~newName ~debug | ||
Eio_main.run (fun env -> | ||
Commands.rename ~env ~path | ||
~pos:(int_of_string line, int_of_string col) | ||
~newName ~debug) | ||
| [_; "semanticTokens"; currentFile] -> | ||
SemanticTokens.semanticTokens ~currentFile | ||
| [_; "createInterface"; path; cmiFile] -> | ||
Printf.printf "\"%s\"" | ||
(Json.escape (CreateInterface.command ~path ~cmiFile)) | ||
| [_; "format"; path] -> | ||
Printf.printf "\"%s\"" (Json.escape (Commands.format ~path)) | ||
| [_; "test"; path] -> Commands.test ~path | ||
| [_; "test"; path] -> Eio_main.run (fun env -> Commands.test ~env ~path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is used because reference tests require the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The specific tests of commands that use Eio will still use it in the tests as well, but yeah, the tests themselves are sequential. |
||
| [_; "cmt"; rescript_json; cmt_path] -> CmtViewer.dump rescript_json cmt_path | ||
| args when List.mem "-h" args || List.mem "--help" args -> prerr_endline help | ||
| _ -> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(* Helpers for domain-local caches *) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any links to what a domain-local cache even is? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Domains in Eio are essentially threads but managed by Eio. So, a domain local cache is a cache that's valid just for a thread (domain). Previously, everything was sequential and within a single thread. We can now use multiple threads (domains) for parallelizing work, but that means interacting with the cache isn't safe if it's shared between all threads (races etc). So, by doing domain local caches, we dodge that issue. For the exact tasks in this PR (rename and find references), the cache doesn't matter that much I suspect. But since it was already in place, and it's used in a bunch of other places (where we don't use Eio yet, and maybe won't ever do), it made sense to make them domain specific. This should be "backwards compatible" too from what I understand, in that the cache will work the same way as it did before for the non-Eio stuff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks a bunch for explaining this! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Can you try something: create intentionally some shared mutable state and use domain local cache and check that they don't interfere. |
||
|
||
let make_hashtbl (size : int) : ('k, 'v) Hashtbl.t Domain.DLS.key = | ||
Domain.DLS.new_key (fun () -> Hashtbl.create size) | ||
|
||
let get_hashtbl (key : ('k, 'v) Hashtbl.t Domain.DLS.key) : ('k, 'v) Hashtbl.t = | ||
Domain.DLS.get key |
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 was discussed in Discord that it's OK for us to move to
5.3.0+
.