-
Notifications
You must be signed in to change notification settings - Fork 233
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
Merlin Pipeline PPX Cache is Broken when a pipeline is only used partially #1647
Comments
Here is a more detailed description of the issue as I understand it:
Is that what you described ? This is due to the ad-hoc coupling mechanism between the reader and the ppx cache.
Since there is a bug I think we should first fix it before envisaging a design change like 1. I am wondering what would be the cost of marshaling the parsetree everytime however. Another option could also be to have an integer instead of a boolean value to synchronize the two caches, when the reader result change the integer is bumped. I will have a look. |
Yes, that description sounds correct to me. The quick fix we’ve deployed internally so far is to just disable PPX caching entirely, so there is no particular rush for a quick fix from our end / we’d be happy to take time to come up with a new design. (Although I’m not sure how much this effects the regular merlin protocol / ie if it’s easy to get into that state for most users right now; which might make a quick fix more urgent 😅) |
Ok, I was able to reproduce in the test suite and made a fix based on the numbering idea in #1650. @dyedgreen could you check that is solves your issue ? |
This looks like it should fix the issue I’m seeing! |
CHANGES: Thu Aug 24 17:17:42 CEST 2023 + merlin binary - Constrain socket path buffer size to avoid build warnings (ocaml/merlin#1631) - Handle concurrent server start (ocaml/merlin#1622) - Omit module prefixes for constructors and record fields in the `construct` command (ocaml/merlin#1618). Prefixes are still produced when warning 42 (disambiguated name) is active. - Correctly invalidate PPX cache when pipeline ran partially (ocaml/merlin#1650, fixes ocaml/merlin#1647) - Prevent `short-path` from looping in some cases related to recursive type definitions (ocaml/merlin#1645) - Support parsing negative numbers in sexps (ocaml/merlin#1655) - Fix construct not working with inline records (ocaml/merlin#1658) - Improve behavior of `type-enclosing` on let/and operators (ocaml/merlin#1653) - Fix occurrences of extension constructors (ocaml/merlin#1662) - Improve node selection when ghosts are present (ocaml/merlin#1664, fixes ocaml/merlin#1660) + editor modes - emacs: call merlin-client-logger with "interrupted" if the merlin binary itself is interrupted, not just the parsing of the result (ocaml/merlin#1626). - emacs: merlin-construct, with a prefix argument, now includes local values in the completion options. Alternatively, this behavior can be enabled permanently by customizing `merlin-construct-with-local-values` (ocaml/merlin#1644) - emacs: add support for opam-switch-mode (ocaml/merlin#1654, fixes ocaml/merlin#1591). See <https://github.com/ProofGeneral/opam-switch-mode>
CHANGES: Thu Aug 24 17:17:42 CEST 2023 + merlin binary - Constrain socket path buffer size to avoid build warnings (ocaml/merlin#1631) - Handle concurrent server start (ocaml/merlin#1622) - Omit module prefixes for constructors and record fields in the `construct` command (ocaml/merlin#1618). Prefixes are still produced when warning 42 (disambiguated name) is active. - Correctly invalidate PPX cache when pipeline ran partially (ocaml/merlin#1650, fixes ocaml/merlin#1647) - Prevent `short-path` from looping in some cases related to recursive type definitions (ocaml/merlin#1645) - Support parsing negative numbers in sexps (ocaml/merlin#1655) - Fix construct not working with inline records (ocaml/merlin#1658) - Improve behavior of `type-enclosing` on let/and operators (ocaml/merlin#1653) - Fix occurrences of extension constructors (ocaml/merlin#1662) - Improve node selection when ghosts are present (ocaml/merlin#1664, fixes ocaml/merlin#1660) + editor modes - emacs: call merlin-client-logger with "interrupted" if the merlin binary itself is interrupted, not just the parsing of the result (ocaml/merlin#1626). - emacs: merlin-construct, with a prefix argument, now includes local values in the completion options. Alternatively, this behavior can be enabled permanently by customizing `merlin-construct-with-local-values` (ocaml/merlin#1644) - emacs: add support for opam-switch-mode (ocaml/merlin#1654, fixes ocaml/merlin#1591). See <https://github.com/ProofGeneral/opam-switch-mode>
CHANGES: Thu Aug 24 17:17:42 CEST 2023 + merlin binary - Constrain socket path buffer size to avoid build warnings (ocaml/merlin#1631) - Handle concurrent server start (ocaml/merlin#1622) - Omit module prefixes for constructors and record fields in the `construct` command (ocaml/merlin#1618). Prefixes are still produced when warning 42 (disambiguated name) is active. - Correctly invalidate PPX cache when pipeline ran partially (ocaml/merlin#1650, fixes ocaml/merlin#1647) - Prevent `short-path` from looping in some cases related to recursive type definitions (ocaml/merlin#1645) - Support parsing negative numbers in sexps (ocaml/merlin#1655) - Fix construct not working with inline records (ocaml/merlin#1658) - Improve behavior of `type-enclosing` on let/and operators (ocaml/merlin#1653) - Fix occurrences of extension constructors (ocaml/merlin#1662) - Improve node selection when ghosts are present (ocaml/merlin#1664, fixes ocaml/merlin#1660) + editor modes - emacs: call merlin-client-logger with "interrupted" if the merlin binary itself is interrupted, not just the parsing of the result (ocaml/merlin#1626). - emacs: merlin-construct, with a prefix argument, now includes local values in the completion options. Alternatively, this behavior can be enabled permanently by customizing `merlin-construct-with-local-values` (ocaml/merlin#1644) - emacs: add support for opam-switch-mode (ocaml/merlin#1654, fixes ocaml/merlin#1591). See <https://github.com/ProofGeneral/opam-switch-mode>
CHANGES: Thu Aug 24 17:17:42 CEST 2023 + merlin binary - Constrain socket path buffer size to avoid build warnings (ocaml/merlin#1631) - Handle concurrent server start (ocaml/merlin#1622) - Omit module prefixes for constructors and record fields in the `construct` command (ocaml/merlin#1618). Prefixes are still produced when warning 42 (disambiguated name) is active. - Correctly invalidate PPX cache when pipeline ran partially (ocaml/merlin#1650, fixes ocaml/merlin#1647) - Prevent `short-path` from looping in some cases related to recursive type definitions (ocaml/merlin#1645) - Support parsing negative numbers in sexps (ocaml/merlin#1655) - Fix construct not working with inline records (ocaml/merlin#1658) - Improve behavior of `type-enclosing` on let/and operators (ocaml/merlin#1653) - Fix occurrences of extension constructors (ocaml/merlin#1662) - Improve node selection when ghosts are present (ocaml/merlin#1664, fixes ocaml/merlin#1660) + editor modes - emacs: call merlin-client-logger with "interrupted" if the merlin binary itself is interrupted, not just the parsing of the result (ocaml/merlin#1626). - emacs: merlin-construct, with a prefix argument, now includes local values in the completion options. Alternatively, this behavior can be enabled permanently by customizing `merlin-construct-with-local-values` (ocaml/merlin#1644) - emacs: add support for opam-switch-mode (ocaml/merlin#1654, fixes ocaml/merlin#1591). See <https://github.com/ProofGeneral/opam-switch-mode>
CHANGES: Thu Aug 24 17:17:42 CEST 2023 + merlin binary - Constrain socket path buffer size to avoid build warnings (ocaml/merlin#1631) - Handle concurrent server start (ocaml/merlin#1622) - Omit module prefixes for constructors and record fields in the `construct` command (ocaml/merlin#1618). Prefixes are still produced when warning 42 (disambiguated name) is active. - Correctly invalidate PPX cache when pipeline ran partially (ocaml/merlin#1650, fixes ocaml/merlin#1647) - Prevent `short-path` from looping in some cases related to recursive type definitions (ocaml/merlin#1645) - Support parsing negative numbers in sexps (ocaml/merlin#1655) - Fix construct not working with inline records (ocaml/merlin#1658) - Improve behavior of `type-enclosing` on let/and operators (ocaml/merlin#1653) - Fix occurrences of extension constructors (ocaml/merlin#1662) - Improve node selection when ghosts are present (ocaml/merlin#1664, fixes ocaml/merlin#1660) + editor modes - emacs: call merlin-client-logger with "interrupted" if the merlin binary itself is interrupted, not just the parsing of the result (ocaml/merlin#1626). - emacs: merlin-construct, with a prefix argument, now includes local values in the completion options. Alternatively, this behavior can be enabled permanently by customizing `merlin-construct-with-local-values` (ocaml/merlin#1644) - emacs: add support for opam-switch-mode (ocaml/merlin#1654, fixes ocaml/merlin#1591). See <https://github.com/ProofGeneral/opam-switch-mode>
CHANGES: Thu Aug 24 17:17:42 CEST 2023 + merlin binary - Constrain socket path buffer size to avoid build warnings (ocaml/merlin#1631) - Handle concurrent server start (ocaml/merlin#1622) - Omit module prefixes for constructors and record fields in the `construct` command (ocaml/merlin#1618). Prefixes are still produced when warning 42 (disambiguated name) is active. - Correctly invalidate PPX cache when pipeline ran partially (ocaml/merlin#1650, fixes ocaml/merlin#1647) - Prevent `short-path` from looping in some cases related to recursive type definitions (ocaml/merlin#1645) - Support parsing negative numbers in sexps (ocaml/merlin#1655) - Fix construct not working with inline records (ocaml/merlin#1658) - Improve behavior of `type-enclosing` on let/and operators (ocaml/merlin#1653) - Fix occurrences of extension constructors (ocaml/merlin#1662) - Improve node selection when ghosts are present (ocaml/merlin#1664, fixes ocaml/merlin#1660) + editor modes - emacs: call merlin-client-logger with "interrupted" if the merlin binary itself is interrupted, not just the parsing of the result (ocaml/merlin#1626). - emacs: merlin-construct, with a prefix argument, now includes local values in the completion options. Alternatively, this behavior can be enabled permanently by customizing `merlin-construct-with-local-values` (ocaml/merlin#1644) - emacs: add support for opam-switch-mode (ocaml/merlin#1654, fixes ocaml/merlin#1591). See <https://github.com/ProofGeneral/opam-switch-mode>
We’ve run into the following issue with the PPX caching (cc @pitag-ha) in the merlin pipeline:
reader_parsetree
ppx_parsetree
or anything that depends on itNow the PPX stage will return its cached result, because the reader parsetree is cached (from 1.), but the cached result is out of date.
This can be observed in particular when using the ocaml LSP (cc @rgrinberg, @ddickstein), since VSCode will send a
documentFoldingRange
request which only depends on the parse tree (this then leads to stale errors reported by the LSP, via the cache corruption outlined above).I think a nice way to solve this issue (at least in the LSP, which has a notion of open documents) would be to remove the implicit global cache and instead have explicit per document caches and pipelines that we construct / update as the documents are opened / changed.
Another way to address this would be to compute a proper digest of the parse tree, rather than doing
force_invalidation = not source_is_unmodified
.The text was updated successfully, but these errors were encountered: