Skip to content
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

Configurable cache retention period #1698

Merged
merged 2 commits into from
Nov 8, 2023
Merged

Conversation

3Rafal
Copy link
Collaborator

@3Rafal 3Rafal commented Oct 30, 2023

Second task from #1636

PoC:
The cache retention value was added to Mconfig. Call to Mocaml.flush_caches was moved to a place where Mconfig is available. Next step will be to create a flag that allows setting the config value from client. Last step is to use this flag from emacs/vim plugins.

@voodoos
Copy link
Collaborator

voodoos commented Nov 2, 2023

Is that PR ready for review ? Looks like everything is in place :-)

Maybe we could write a test which show cache hits when the flag has a very high value and no cache hit when it is set to 0.

@3Rafal
Copy link
Collaborator Author

3Rafal commented Nov 3, 2023

@voodoos I was considering extending vim and emacs plugins, so that they can use this new flag. But this PR is actually nice and self-contained, so I'll just write tests and ask you for review when ready :)

3Rafal added a commit to 3Rafal/merlin that referenced this pull request Nov 6, 2023
@3Rafal 3Rafal requested a review from voodoos November 6, 2023 11:52
@3Rafal 3Rafal changed the title [WIP] Configurable cache freshness time Configurable cache freshness time Nov 6, 2023
@3Rafal 3Rafal marked this pull request as ready for review November 6, 2023 12:22
Copy link
Collaborator

@voodoos voodoos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. The test is very nice :-)

src/kernel/mconfig.ml Outdated Show resolved Hide resolved
3Rafal added a commit to 3Rafal/merlin that referenced this pull request Nov 8, 2023
Remove old call to `flush_caches`

Add `-cache-time` flag

Add tests for `--cache-time` flag

Add changelog entry for ocaml#1698

Change cache time measure to minutes.

Fix quoting.t

Fix cache-time.t tests

Replace awk with sed in cache-time.t

debug logs

Fix grep pattern

Investigate logs

Flush file_cache logs

Investigate logs

Move test file

Add
@3Rafal 3Rafal changed the title Configurable cache freshness time Configurable cache retention time Nov 8, 2023
@3Rafal 3Rafal changed the title Configurable cache retention time Configurable cache retention period Nov 8, 2023
@3Rafal
Copy link
Collaborator Author

3Rafal commented Nov 8, 2023

@voodoos , I've added emacs handling, because it was super simple. Here is logged result of using it (as a proof that it actually works). It's a simple query ran on merlin codebase:

command:  ocamlmerlin server type-enclosing -protocol sexp -verbosity 0 -filename /Users/rafal/Projects/Tarides/merlin/src/kernel/mconfig.ml -cache-period 45 -position 73:3 -index 0
- result: ((assoc) (class . "return") (value ((assoc) (start (assoc) (line . 72) (col . 0)) (end (assoc) (line . 98) (col . 1)) (type . "type merlin = {
  build_path : string list;
  source_path : string list;
  cmi_path : string list;
  cmt_path : string list;
  extensions : string list;
  suffixes : (string * string) list;
  stdlib : string option;
  reader : string list;
  protocol : [ `Json | `Sexp ];
  log_file : string option;
  log_sections : string list;
  config_path : string option;
  use_ppx_cache : bool;
  exclude_query_dir : bool;
  flags_to_apply : string list with_workdir list;
  flags_applied : string list with_workdir list;
  failures : string list;
  extension_to_reader : (string * string) list;
  cache_period : int;
}") (tail . "no"))) (notifications) (timing (assoc) (clock . 60) (cpu . 37) (query . 4) (pp . 0) (reader . 4) (ppx . 0) (typer . 29) (error . 0)))

@voodoos
Copy link
Collaborator

voodoos commented Nov 8, 2023

Perfect !

Thank you !

@voodoos voodoos merged commit f46ebad into ocaml:master Nov 8, 2023
11 checks passed
voodoos added a commit to voodoos/merlin that referenced this pull request Nov 8, 2023
@3Rafal 3Rafal deleted the cache-flush branch November 8, 2023 16:53
voodoos added a commit to 3Rafal/merlin that referenced this pull request Nov 15, 2023
voodoos added a commit to voodoos/opam-repository that referenced this pull request Dec 1, 2023
CHANGES:

Fri Dec  1 15:00:42 CET 2023

  + merlin binary
    - Fix a follow-up issue to the preference of non-ghost nodes introduced in ocaml/merlin#1660 (ocaml/merlin#1690, fixes ocaml/merlin#1689)
    - Add `-cache-lifespan` flag, that sets cache invalidation period. (ocaml/merlin#1698,
      ocaml/merlin#1705)
    - Fix Merlin locate not fallbacking on the correct file in case of ambiguity
      (@goldfirere, ocaml/merlin#1699)
    - Fix Merlin reporting errors provoked by the recovery itself (ocaml/merlin#1709, fixes
      ocaml/merlin#1704)
  + editor modes
    - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim)
    - emacs: highlight only first error line by default (ocaml/merlin#1693, fixes ocaml/merlin#1663)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Dec 1, 2023
CHANGES:

Fri Dec  1 15:00:42 CET 2023

  + merlin binary
    - Fix a follow-up issue to the preference of non-ghost nodes introduced in ocaml/merlin#1660 (ocaml/merlin#1690, fixes ocaml/merlin#1689)
    - Add `-cache-lifespan` flag, that sets cache invalidation period. (ocaml/merlin#1698,
      ocaml/merlin#1705)
    - Ignore the new 5.1 `cmi-file` flag instead of rejecting it (ocaml/merlin#1710, fixes
      ocaml/merlin#1703)
    - Fix Merlin locate not fallbacking on the correct file in case of ambiguity
      (@goldfirere, ocaml/merlin#1699)
    - Fix Merlin reporting errors provoked by the recovery itself (ocaml/merlin#1709, fixes
      ocaml/merlin#1704)
  + editor modes
    - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim)
    - emacs: highlight only first error line by default (ocaml/merlin#1693, fixes ocaml/merlin#1663)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Dec 1, 2023
CHANGES:

Fri Dec  1 15:00:42 CET 2023

  + merlin binary
    - Fix a follow-up issue to the preference of non-ghost nodes introduced in ocaml/merlin#1660 (ocaml/merlin#1690, fixes ocaml/merlin#1689)
    - Add `-cache-lifespan` flag, that sets cache invalidation period. (ocaml/merlin#1698,
      ocaml/merlin#1705)
    - Ignore the new 5.1 `cmi-file` flag instead of rejecting it (ocaml/merlin#1710, fixes
      ocaml/merlin#1703)
    - Fix Merlin locate not fallbacking on the correct file in case of ambiguity
      (@goldfirere, ocaml/merlin#1699)
    - Fix Merlin reporting errors provoked by the recovery itself (ocaml/merlin#1709, fixes
      ocaml/merlin#1704)
    - Add support for OCaml 5.1.1 (ocaml/merlin#1714)
  + editor modes
    - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim)
    - emacs: highlight only first error line by default (ocaml/merlin#1693, fixes ocaml/merlin#1663)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Dec 1, 2023
CHANGES:

Fri Dec  1 15:00:42 CET 2023

  + merlin binary
    - Fix a follow-up issue to the preference of non-ghost nodes introduced in ocaml/merlin#1660 (ocaml/merlin#1690, fixes ocaml/merlin#1689)
    - Add `-cache-lifespan` flag, that sets cache invalidation period. (ocaml/merlin#1698,
      ocaml/merlin#1705)
    - Ignore the new 5.1 `cmi-file` flag instead of rejecting it (ocaml/merlin#1710, fixes
      ocaml/merlin#1703)
    - Fix Merlin locate not fallbacking on the correct file in case of ambiguity
      (@goldfirere, ocaml/merlin#1699)
    - Fix Merlin reporting errors provoked by the recovery itself (ocaml/merlin#1709, fixes
      ocaml/merlin#1704)
    - Add support for OCaml 5.1.1 (ocaml/merlin#1714)
  + editor modes
    - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim)
    - emacs: highlight only first error line by default (ocaml/merlin#1693, fixes ocaml/merlin#1663)

[new release] merlin-lib and merlin (4.13-501)

CHANGES:

Fri Dec  1 15:00:42 CET 2023

  + merlin binary
    - Fix a follow-up issue to the preference of non-ghost nodes introduced in ocaml/merlin#1660 (ocaml/merlin#1690, fixes ocaml/merlin#1689)
    - Add `-cache-lifespan` flag, that sets cache invalidation period. (ocaml/merlin#1698,
      ocaml/merlin#1705)
    - Ignore the new 5.1 `cmi-file` flag instead of rejecting it (ocaml/merlin#1710, fixes
      ocaml/merlin#1703)
    - Fix Merlin locate not fallbacking on the correct file in case of ambiguity
      (@goldfirere, ocaml/merlin#1699)
    - Fix Merlin reporting errors provoked by the recovery itself (ocaml/merlin#1709, fixes
      ocaml/merlin#1704)
  + editor modes
    - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim)
    - emacs: highlight only first error line by default (ocaml/merlin#1693, fixes ocaml/merlin#1663)

[new release] merlin-lib and merlin (4.13-414)

CHANGES:

Fri Dec  1 15:00:42 CET 2023

  + merlin binary
    - Fix a follow-up issue to the preference of non-ghost nodes introduced in ocaml/merlin#1660 (ocaml/merlin#1690, fixes ocaml/merlin#1689)
    - Add `-cache-lifespan` flag, that sets cache invalidation period. (ocaml/merlin#1698,
      ocaml/merlin#1705)
    - Fix Merlin locate not fallbacking on the correct file in case of ambiguity
      (@goldfirere, ocaml/merlin#1699)
    - Fix Merlin reporting errors provoked by the recovery itself (ocaml/merlin#1709, fixes
      ocaml/merlin#1704)
  + editor modes
    - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim)
    - emacs: highlight only first error line by default (ocaml/merlin#1693, fixes ocaml/merlin#1663)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Dec 18, 2023
CHANGES:

Mon Dec 18 16:42:00 CET 2023

  + merlin binary
    - Fix a follow-up issue to the preference of non-ghost nodes introduced in ocaml/merlin#1660 (ocaml/merlin#1690, fixes ocaml/merlin#1689)
    - Add `-cache-lifespan` flag, that sets cache invalidation period. (ocaml/merlin#1698,
      ocaml/merlin#1705)
    - Fix Merlin locate not fallbacking on the correct file in case of ambiguity
      (@goldfirere, ocaml/merlin#1699)
    - Fix Merlin reporting errors provoked by the recovery itself (ocaml/merlin#1709, fixes
      ocaml/merlin#1704)
  + editor modes
    - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim)
    - emacs: highlight only first error line by default (ocaml/merlin#1693, fixes ocaml/merlin#1663)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Dec 18, 2023
CHANGES:

Mon Dec 18 16:42:00 CET 2023

  + merlin binary
    - Fix a follow-up issue to the preference of non-ghost nodes introduced in ocaml/merlin#1660 (ocaml/merlin#1690, fixes ocaml/merlin#1689)
    - Add `-cache-lifespan` flag, that sets cache invalidation period. (ocaml/merlin#1698,
      ocaml/merlin#1705)
    - Fix Merlin locate not fallbacking on the correct file in case of ambiguity
      (@goldfirere, ocaml/merlin#1699)
    - Fix Merlin reporting errors provoked by the recovery itself (ocaml/merlin#1709, fixes
      ocaml/merlin#1704)
  + editor modes
    - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim)
    - emacs: highlight only first error line by default (ocaml/merlin#1693, fixes ocaml/merlin#1663)
nberth pushed a commit to nberth/opam-repository that referenced this pull request Jun 18, 2024
CHANGES:

Fri Dec  1 15:00:42 CET 2023

  + merlin binary
    - Fix a follow-up issue to the preference of non-ghost nodes introduced in ocaml/merlin#1660 (ocaml/merlin#1690, fixes ocaml/merlin#1689)
    - Add `-cache-lifespan` flag, that sets cache invalidation period. (ocaml/merlin#1698,
      ocaml/merlin#1705)
    - Ignore the new 5.1 `cmi-file` flag instead of rejecting it (ocaml/merlin#1710, fixes
      ocaml/merlin#1703)
    - Fix Merlin locate not fallbacking on the correct file in case of ambiguity
      (@goldfirere, ocaml/merlin#1699)
    - Fix Merlin reporting errors provoked by the recovery itself (ocaml/merlin#1709, fixes
      ocaml/merlin#1704)
    - Add support for OCaml 5.1.1 (ocaml/merlin#1714)
  + editor modes
    - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim)
    - emacs: highlight only first error line by default (ocaml/merlin#1693, fixes ocaml/merlin#1663)

[new release] merlin-lib and merlin (4.13-501)

CHANGES:

Fri Dec  1 15:00:42 CET 2023

  + merlin binary
    - Fix a follow-up issue to the preference of non-ghost nodes introduced in ocaml/merlin#1660 (ocaml/merlin#1690, fixes ocaml/merlin#1689)
    - Add `-cache-lifespan` flag, that sets cache invalidation period. (ocaml/merlin#1698,
      ocaml/merlin#1705)
    - Ignore the new 5.1 `cmi-file` flag instead of rejecting it (ocaml/merlin#1710, fixes
      ocaml/merlin#1703)
    - Fix Merlin locate not fallbacking on the correct file in case of ambiguity
      (@goldfirere, ocaml/merlin#1699)
    - Fix Merlin reporting errors provoked by the recovery itself (ocaml/merlin#1709, fixes
      ocaml/merlin#1704)
  + editor modes
    - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim)
    - emacs: highlight only first error line by default (ocaml/merlin#1693, fixes ocaml/merlin#1663)

[new release] merlin-lib and merlin (4.13-414)

CHANGES:

Fri Dec  1 15:00:42 CET 2023

  + merlin binary
    - Fix a follow-up issue to the preference of non-ghost nodes introduced in ocaml/merlin#1660 (ocaml/merlin#1690, fixes ocaml/merlin#1689)
    - Add `-cache-lifespan` flag, that sets cache invalidation period. (ocaml/merlin#1698,
      ocaml/merlin#1705)
    - Fix Merlin locate not fallbacking on the correct file in case of ambiguity
      (@goldfirere, ocaml/merlin#1699)
    - Fix Merlin reporting errors provoked by the recovery itself (ocaml/merlin#1709, fixes
      ocaml/merlin#1704)
  + editor modes
    - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim)
    - emacs: highlight only first error line by default (ocaml/merlin#1693, fixes ocaml/merlin#1663)
nberth pushed a commit to nberth/opam-repository that referenced this pull request Jun 18, 2024
CHANGES:

Mon Dec 18 16:42:00 CET 2023

  + merlin binary
    - Fix a follow-up issue to the preference of non-ghost nodes introduced in ocaml/merlin#1660 (ocaml/merlin#1690, fixes ocaml/merlin#1689)
    - Add `-cache-lifespan` flag, that sets cache invalidation period. (ocaml/merlin#1698,
      ocaml/merlin#1705)
    - Fix Merlin locate not fallbacking on the correct file in case of ambiguity
      (@goldfirere, ocaml/merlin#1699)
    - Fix Merlin reporting errors provoked by the recovery itself (ocaml/merlin#1709, fixes
      ocaml/merlin#1704)
  + editor modes
    - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim)
    - emacs: highlight only first error line by default (ocaml/merlin#1693, fixes ocaml/merlin#1663)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 4.13-501
Development

Successfully merging this pull request may close these issues.

2 participants