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

Enrich Merlin telemetry with info about cache hits and misses #1707

Closed
2 tasks
pitag-ha opened this issue Nov 17, 2023 · 1 comment
Closed
2 tasks

Enrich Merlin telemetry with info about cache hits and misses #1707

pitag-ha opened this issue Nov 17, 2023 · 1 comment

Comments

@pitag-ha
Copy link
Member

For a better overview of Merlin's performance, let's enhance the Merlin telemetry with information about the various cache hits and misses: file caches (cmi/cmt/(cms) cache), buffer cache, and PPX cache.

Current telemetry

The ocamlmerlin frontend already contains information about the time spent during the different Merlin phases:

$ ocamlmerlin single locate -position 16:5 < src/frontend/ocamlmerlin/new/new_merlin.ml | jq
{
  "class": "return",
  "value": {
    "file": "/home/sonja/.opam/4.14.0/lib/ocaml/stdlib.mli",
    "pos": {
      "line": 866,
      "col": 0
    }
  },
  "notifications": [],
  "timing": {
    "clock": 14,
    "cpu": 14,
    "query": 1,
    "pp": 0,
    "reader": 2,
    "ppx": 0,
    "typer": 10,
    "error": 0
  }
}

Current way of getting info about cache hits and misses

Currently, Merlin dumps information about cache hits and misses into an opt-in log-file: After running

ocamlmerlin server locate -position 16:5 -log-file logs.txt < src/frontend/ocamlmerlin/new/new_merlin.ml > /dev/null

your logs.txt will contain info such as

# 0.05 File_cache(Exists_in_directory) - read
reusing "/home/sonja/.opam/4.14.0/lib/ocaml"

Proposed addition

This issue is about adding the information about cache hits and misses to the Merlin telemetry, similarly to how the timing information is captured and exposed.

Tasks

For that, the following things need to be implemented:

  • Expose the information about cache hits and misses in Merlin_lib in a way that it can easily be picked up by the different Merlin frontends, i.e. by ocamlmerlin and by ocaml-lsp-server.
  • Add the cache info to the ocamlmerlin telemetry. There are similar CLI design choices to make as in Enrich Merlin telemetry with GC info #1680, such as: Now that the telemetry is getting richer, how do we want to structure it in the Merlin response? And do we want to make some of it opt-in via an ocamlmerlin flag? To avoid clashes with the work on Enrich Merlin telemetry with GC info #1680, let's think about this later, once the first task is implemented.

In the future, when we have telemetry for ocaml-lsp-server, we'll also add the cache info to the ocaml-lsp-server telemetry.

Motivation for the issue

We want the information about cache hits and misses to be picked up by Merlin telemetry pipelines that

@pitag-ha
Copy link
Member Author

Implemented in #1711

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant