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

Expose runtime metrics via EKG #2267

Merged
merged 15 commits into from
May 6, 2022
Merged

Expose runtime metrics via EKG #2267

merged 15 commits into from
May 6, 2022

Conversation

pepeiborra
Copy link
Collaborator

@pepeiborra pepeiborra commented Oct 9, 2021

Install a metrics server at port 8000 via EKG with the following metrics:

  • ghcide.values_count- count of build results in the store
  • ghcide.database_count - count of build keys in the store (these two would be the same in the absence of GC)
  • ghcide.build_count - build count. A key is GC'ed if it is dirty and older than 100 builds
  • ghcide.dirty_keys_count - non transitive count of dirty build keys
  • ghcide.indexing_pending_count - count of items in the indexing queue
  • ghcide.exports_map_count - count of identifiers in the exports map.

Unfortunately the EKG packages need allow-newer entries for GHC 9. This is also the case for the snap-server packages and dependencies. Since it doesn't look like these are getting resolved in Hackage any time soon, let's hold back on merging this PR for now

Upstream issues:

@mpickering
Copy link
Contributor

I am also picking this commit locally to test it, there are some conflicts with master that I needed to fix.

@mpickering
Copy link
Contributor

  1. It would be good to also expose the GC metrics by using registerGcMetrics.
  2. In order to get the WebUI to work, I had to set ekg_wait_datadir to point into the dist-newstyle.
ekg_wai_datadir=/home/matt/haskell-language-server/dist-newstyle/src/ekg-wai-7357402d5176ab83

2021-10-28-114029_1063x749

@pepeiborra
Copy link
Collaborator Author

pepeiborra commented Oct 28, 2021

I'll send a rebase with some new features tonight.

EDIT: I have pushed a rebase including the GC metrics, but I didn't have time to look at the WebUI comment

Left e -> do
logInfo logger $ T.pack $
"Unable to bind monitoring server on port "
<> show p <> ":" <> show e
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to happen quite often for me as I usually have multiple instances of HLS running at once. Perhaps we should try a range of ports rather than just fail?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good, do push a commit if you want this.

@pepeiborra pepeiborra force-pushed the ekg branch 3 times, most recently from ddb673c to 5faf842 Compare April 30, 2022 20:42
@pepeiborra pepeiborra marked this pull request as ready for review April 30, 2022 23:50
@pepeiborra
Copy link
Collaborator Author

I have reworked this to abstract monitoring and put it behind a Cabal flag, to avoid acquiring a hard dependency on the ekg ecosystem

.github/workflows/flags.yml Outdated Show resolved Hide resolved
cabal.project Show resolved Hide resolved
ghcide/exe/Arguments.hs Outdated Show resolved Hide resolved
@@ -30,6 +30,11 @@ flag ghc-patched-unboxed-bytecode
default: False
manual: True

flag ekg
description: Enable EKG monitoring of the build graph and other metrics on port 8999
Copy link
Collaborator

Choose a reason for hiding this comment

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

The port is configurable, right? Just seems like an odd detail to have here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Putting it here makes it easy to find :)

ghcide/exe/Main.hs Outdated Show resolved Hide resolved
ghcide/src/Development/IDE/Types/Monitoring.hs Outdated Show resolved Hide resolved
ghcide/src/Development/IDE/Monitoring/EKG.hs Outdated Show resolved Hide resolved
docs/contributing/contributing.md Outdated Show resolved Hide resolved
@pepeiborra pepeiborra force-pushed the ekg branch 3 times, most recently from 311f543 to 6a04ca5 Compare May 2, 2022 10:06
@pepeiborra pepeiborra force-pushed the ekg branch 4 times, most recently from 226a14c to f5ce823 Compare May 5, 2022 21:57
@pepeiborra
Copy link
Collaborator Author

@michaelpj thanks for the review, I think I've addressed all your feedback now and this is ready to go

Copy link
Collaborator

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

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

Nice!

@michaelpj michaelpj added the merge me Label to trigger pull request merge label May 6, 2022
@mergify mergify bot merged commit 6524122 into master May 6, 2022
sloorush pushed a commit to sloorush/haskell-language-server that referenced this pull request May 21, 2022
* Collect metrics and expose an EKG server

* register gc metrics locally

* getDatabaseKeys

* fixups

* Abstract monitoring and put EKG behind a Cabal flag

* Add CI for the new flag

* fix double ifdef

* link to GHC docs for eventlogs

* log when stopping the EKG server

* Allow CPP in modules

* Add doc comments

* Apply suggestions from code review

Co-authored-by: Michael Peyton Jones <[email protected]>

* Compat. with ghc 9.2

* use an ekg-json snapshot that preserves compat. with ghc 8.x

* confine CPP to the EKG module

Co-authored-by: Michael Peyton Jones <[email protected]>
hololeap pushed a commit to hololeap/haskell-language-server that referenced this pull request Aug 26, 2022
* Collect metrics and expose an EKG server

* register gc metrics locally

* getDatabaseKeys

* fixups

* Abstract monitoring and put EKG behind a Cabal flag

* Add CI for the new flag

* fix double ifdef

* link to GHC docs for eventlogs

* log when stopping the EKG server

* Allow CPP in modules

* Add doc comments

* Apply suggestions from code review

Co-authored-by: Michael Peyton Jones <[email protected]>

* Compat. with ghc 9.2

* use an ekg-json snapshot that preserves compat. with ghc 8.x

* confine CPP to the EKG module

Co-authored-by: Michael Peyton Jones <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants