Skip to content

Conversation

@sdluxeon
Copy link

Description
Added the ability to disable background stats collection

Motivation
While running the server, without making api calls, stats are collected constantly. This leads to CPU utilisation even when the server is idle.

TLDR of the changes

  • added a new config DISABLE_BACKGROUND_STATS_COLLECTION
  • added a new class called LazyObservable that stops the "interval" if there are no observers subscribed to it.
  • moved 'getCurrentValue()' from index.ts to the LazyObservable, in order to prevent creation of timers/schedulers when not need.

I tried to keep the existing behaviour and made the feature opt-int as I was not sure if the current behaviour isn't actually the intended one.

The screenshot below shows two containers running the code changes from this PR:

  • bg-collect — constant CPU utilization of ~4% with no active WebSocket subscribers.
    docker container run -it --rm -p 80:3001 -v /:/mnt/host:ro --privileged --name bg-collect dashdot-test:amd64
  • non-bg — sits at 0% utilization under the same conditions
    docker container run -it --rm -p 81:3001 -v /:/mnt/host:ro --privileged -e DASHDOT_DISABLE_BACKGROUND_STATS_COLLECTION="true" --name non-bg dashdot-test:amd64
cpu-usage

NOTE: If you try to reproduce, there is an initial CPU utilisation coming from the speed test. After the speed test is complete, CPU settles to 4%

I'm not a TS developer so any feedback is welcome. Thank you!

Related Issue(s)

Fixes: #1050

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

Successfully merging this pull request may close these issues.

1 participant