[merlin] Cleanup leftover merlin files#4261
Conversation
|
I can confirm that:
|
|
@aalekseyev mind taking a look at this? |
649214f to
1df8e3b
Compare
|
Looking. |
src/dune_engine/build_system.ml
Outdated
| let merlin_in_src = Path.Source.(relative source_dir merlin_file) in | ||
| let source_files_to_ignore = | ||
| if | ||
| Path.Set.mem (Promoted_to_delete.load ()) (Path.source merlin_in_src) |
There was a problem hiding this comment.
Calling load once per directory sounds expensive. My understanding is that we expect this file to have size O(n) where n is the number of directories with .merlin files (eve without taking into account anything else the user happens to promote) and you're loading it n times, which makes for O(n^2) time complexity.
I think we should be able to change it so that load is only called once, and Promoted_to_delete.dump simply writes out the db without calling load again.
|
I just pushed a commit extracting the new code into a separate function and adding some comments. |
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
Signed-off-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
1608ce8 to
63d0a2f
Compare
|
Thanks for your review @aalekseyev. I modified the load function to read the database from disk only once. There are still checks that will run for each folder, do you think it is an issue ? dune/src/dune_engine/build_system.ml Lines 927 to 928 in 63d0a2f |
Signed-off-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
Signed-off-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
|
I pushed a commit simplifying the db management code in Please let me know if I'm not seeing a specific reason to avoid that change. |
|
Running a simple test membership check once per directory does not sound problematic to me. |
I considered doing it myself, I think it is a very reasonable change. |
I think doing a couple of extra map lookups per directory is fine. |
* Make Build_system delete left-over `.merlin` files * simplify code managing the Promoted_to_delete db * Add a test for merlin files cleanup Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com> Co-authored-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
* Make Build_system delete left-over `.merlin` files * simplify code managing the Promoted_to_delete db * Add a test for merlin files cleanup Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com> Co-authored-by: Arseniy Alekseyev <aalekseyev@janestreet.com>
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
…ne-action-plugin, dune-private-libs and dune-glob (2.8.3) CHANGES: - Make `patdiff` show refined diffs (ocaml/dune#4257, fixes ocaml/dune#4254, @hakuch) - Fixed a bug that could result in needless recompilation under Windows due to case differences in the result of `Sys.getcwd` (observed under `emacs`). (ocaml/dune#3966, @nojb). - Restore compatibility with Coq < 8.10 for coq-lang < 0.3 , document that `(using coq 0.3)` does require Coq 8.10 at least (ocaml/dune#4224, fixes ocaml/dune#4142, @ejgallego) - Add a META rule for 'compiler-libs.native-toplevel' (ocaml/dune#4175, @AltGr) - No longer call `chmod` on symbolic links (fixes ocaml/dune#4195, @dannywillems) - Dune no longer automatically create or edit `dune-project` files (ocaml/dune#4239, fixes ocaml/dune#4108, @jeremiedimino) - Have `dune` communicate the location of the standard library directory to `merlin` (ocaml/dune#4211, fixes ocaml/dune#4188, @nojb) - Workaround incorrect exception raised by Unix.utimes (OCaml PR#8857) in Path.touch on Windows (ocaml/dune#4223, @dra27) - `dune ocaml-merlin` is now able to provide configuration for source files in the `_build` directory. (ocaml/dune#4274, @voodoos) - Automatically delete left-over Merlin files when rebuilding for the first time a project previously built with Dune `<= 2.7`. (ocaml/dune#4261, @voodoos, @aalekseyev) - Fix `ppx.exe` being compiled for the wrong target when cross-compiling (ocaml/dune#3751, fixes ocaml/dune#3698, @toots) - `dune top` correctly escapes the generated toplevel directives, and make it easier for `dune top` to locate C stubs associated to concerned libraries. (ocaml/dune#4242, fixes ocaml/dune#4231, @nojb) - Do not pass include directories containing native objects when compiling bytecode (ocaml/dune#4200, @nojb)
|
Not all of my .merlin files were deleted after upgrading to dune.2.9.0, and would have loved a warning from dune that it was using a .merlin file instead of |
Was the leftover |
|
Yes it was by Dune, had a look at it before I deleted it manually. I'm pretty sure that I've never opened that file before, so I wouldn't have edited it accidentally. How does Dune determine if file was created by it? |
|
It keeps a database of promoted I don't see an easy way to distinguish between this kind of desynchronization and legit user-created |
|
No I can see the problem - though my thought was more in the direction of Dune informing the user after upgrading to a version that switches away from .merlin files, if there were still .merlin files present that it didn't delete. My primary problem was that I had to debug what was wrong with Merlin without any hints from Dune or Merlin |
Would fix #4168
This PR is a proposal to automatically get rid of
.merlinfiles that were promoted by earlier versions of Dune (mainly 2.7.1).The criteria is:
_build/.to-delete-in-source-treethat contains the list of promoteduntil-cleanfiles has a.merlinentry for the current directory..merlinin the current directory.This way, user that setup custom rules to generate custom
.merlinwon't see there promoted file disapear unexpectedly.I will test it in real upgrade conditions this afternoon.
I understand this may feel too hacky. If you feel deleting the files that way is too sketchy we always can raise a warning instead, asking for a
dune clean.