Skip to content

An option for clickhouse-client to show realtime table with metrics#63689

Merged
alexey-milovidov merged 39 commits intoClickHouse:masterfrom
mariaKhr:interactive-metrics-table
Oct 5, 2024
Merged

An option for clickhouse-client to show realtime table with metrics#63689
alexey-milovidov merged 39 commits intoClickHouse:masterfrom
mariaKhr:interactive-metrics-table

Conversation

@mariaKhr
Copy link
Copy Markdown
Contributor

@mariaKhr mariaKhr commented May 13, 2024

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

A new --progress-table option in clickhouse-client prints a table with metrics changing during query execution; a new --enable-progress-table-toggle is associated with the --progress-table option, and toggles the rendering of the progress table by pressing the control key (Space).

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/

Modify your CI run

NOTE: If your merge the PR with modified CI you MUST KNOW what you are doing
NOTE: Checked options will be applied if set before CI RunConfig/PrepareRunConfig step

Include tests (required builds will be added automatically):

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • All with ASAN
  • All with TSAN
  • All with Analyzer
  • All with Azure
  • Add your option here

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Performance tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All with Aarch64
  • Add your option here

Extra options:

  • do not test (only style check)
  • disable merge-commit (no merge from master before tests)
  • disable CI cache (job reuse)

Only specified batches in multi-batch jobs:

  • 1
  • 2
  • 3
  • 4
Details

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 13, 2024

CLA assistant check
All committers have signed the CLA.

@nikitamikhaylov nikitamikhaylov added the can be tested Allows running workflows for external contributors label May 13, 2024
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-feature Pull request with new product feature label May 13, 2024
@robot-ch-test-poll2
Copy link
Copy Markdown
Contributor

robot-ch-test-poll2 commented May 13, 2024

This is an automated comment for commit 5387908 with description of existing statuses. It's updated for the latest CI running

✅ Click here to open a full report in a separate page

Successful checks
Check nameDescriptionStatus
AST fuzzerRuns randomly generated queries to catch program errors. The build type is optionally given in parenthesis. If it fails, ask a maintainer for help✅ success
BuildsThere's no description for the check yet, please add it to tests/ci/ci_config.py:CHECK_DESCRIPTIONS✅ success
ClickBenchRuns [ClickBench](https://github.com/ClickHouse/ClickBench/) with instant-attach table✅ success
Compatibility checkChecks that clickhouse binary runs on distributions with old libc versions. If it fails, ask a maintainer for help✅ success
Docker keeper imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docker server imageThe check to build and optionally push the mentioned image to docker hub✅ success
Docs checkBuilds and tests the documentation✅ success
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here✅ success
Flaky testsChecks if new added or modified tests are flaky by running them repeatedly, in parallel, with more randomization. Functional tests are run 100 times with address sanitizer, and additional randomization of thread scheduling. Integration tests are run up to 10 times. If at least once a new test has failed, or was too long, this check will be red. We don't allow flaky tests, read the doc✅ success
Install packagesChecks that the built packages are installable in a clear environment✅ success
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests✅ success
Performance ComparisonMeasure changes in query performance. The performance test report is described in detail here. In square brackets are the optional part/total tests✅ success
Stateful testsRuns stateful functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc✅ success
Stress testRuns stateless functional tests concurrently from several clients to detect concurrency-related errors✅ success
Style checkRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report✅ success
Unit testsRuns the unit tests for different release types✅ success
Upgrade checkRuns stress tests on server version from last release and then tries to upgrade it to the version from the PR. It checks if the new server can successfully startup without any errors, crashes or sanitizer asserts✅ success

@mariaKhr mariaKhr force-pushed the interactive-metrics-table branch from 32047d6 to 692d4fd Compare May 13, 2024 15:14
@jkartseva jkartseva self-assigned this May 17, 2024
@jkartseva
Copy link
Copy Markdown
Member

Hi! I've built Clickhouse from this PR branch and run a table function without a limit.

A few comments before the code review.

1. A 'Progress' metric can take on negative values (see MemoryTrackerUsage)

Screenshot 2024-05-21 at 6 36 21 PM

2. tty cursor is flickering and changing position (see the video)

sample.mov

Maybe the latter depends on the tty settings on my system.

Please kindly advise if this is expected.
What are the commands you used to test this PR? It worths updating the description with them.

@jkartseva
Copy link
Copy Markdown
Member

@mariaKhr Please take a look at my comments above

@alexey-milovidov
Copy link
Copy Markdown
Member

This feature is amazing, I like it so much!

I'm thinking about how to make it more visible. Maybe we should toggle the metrics display if a user presses some button, e.g., whitespace, during the query run?

@alexey-milovidov
Copy link
Copy Markdown
Member

@jkartseva, there are two types of metrics: counters and gauges.
Counters can only increase, and we display the speed of change per second.
Gauges can change in either direction, and we display the amount of change last second.

@alexey-milovidov
Copy link
Copy Markdown
Member

But it does not work well for parallel replicas (or with distributed queries in general) - it looks like it does not aggregate across hosts.

@alexey-milovidov
Copy link
Copy Markdown
Member

Why is the cursor displayed here (in the middle of the progress bar)?
Let's make the cursor temporarily invisible during rendering.

Screenshot_20240610_062847

@alexey-milovidov
Copy link
Copy Markdown
Member

alexey-milovidov commented Jun 10, 2024

Let's display metrics documentation in a dark gray color at the rightmost column.
We can cut it so it does not overflow.

@alexey-milovidov
Copy link
Copy Markdown
Member

alexey-milovidov commented Jun 10, 2024

Also, I'd improve color coding.

For time-based metrics, less than 0.001 s/s will be dark gray, less than 0.01 gray, less than 0.1 green, less than 1 yellow, more than 1 bold (white if on dark background). The same for absolute values.

For bytes-based metrics, less than 1 MB/s dark gray, less than 100 MB/sec. gray, less than 1 GB/sec green, less than 10 GB/sec yellow, 100 GB/sec orange, 1 TB/sec bold (white if on dark background). The same for absolute values.

Metrics that were not updated in 5 seconds can be removed from the table.

@alexey-milovidov
Copy link
Copy Markdown
Member

Change GB / s to GB/s, etc. (remove the whitespace), so it will be similar to the existing progress bar.

@alexey-milovidov
Copy link
Copy Markdown
Member

Absolute values without a multiplier should be shown without trailing zeros.

Current:

SchemaInferenceCacheMisses            73.00

Should be:

SchemaInferenceCacheMisses            73

@jkartseva jkartseva marked this pull request as draft July 15, 2024 05:48
@jkartseva jkartseva force-pushed the interactive-metrics-table branch from 6cc6eac to 8b567d6 Compare July 16, 2024 01:14
@jkartseva jkartseva force-pushed the interactive-metrics-table branch from 96db0c8 to 40e5a60 Compare July 18, 2024 00:48
@jkartseva jkartseva force-pushed the interactive-metrics-table branch from 165fa40 to 1d3b7b0 Compare July 19, 2024 01:23
@clickhouse-ci clickhouse-ci bot added the manual approve Manual approve required to run CI label Sep 19, 2024
@jkartseva jkartseva force-pushed the interactive-metrics-table branch 5 times, most recently from d63b8f8 to 727f561 Compare September 20, 2024 03:25
@jkartseva jkartseva force-pushed the interactive-metrics-table branch from 727f561 to ce86bb1 Compare September 20, 2024 03:39
@jkartseva jkartseva marked this pull request as ready for review September 20, 2024 03:54
@jkartseva jkartseva force-pushed the interactive-metrics-table branch from ce86bb1 to 892f702 Compare September 20, 2024 03:57
("stage", po::value<std::string>()->default_value("complete"), "Request query processing up to specified stage: complete,fetch_columns,with_mergeable_state,with_mergeable_state_after_aggregation,with_mergeable_state_after_aggregation_and_limit")
("progress", po::value<ProgressOption>()->implicit_value(ProgressOption::TTY, "tty")->default_value(ProgressOption::DEFAULT, "default"), "Print progress of queries execution - to TTY: tty|on|1|true|yes; to STDERR non-interactive mode: err; OFF: off|0|false|no; DEFAULT - interactive to TTY, non-interactive is off")
("progress-table", po::value<ProgressOption>()->implicit_value(ProgressOption::TTY, "tty")->default_value(ProgressOption::DEFAULT, "default"), "Print a progress table with changing metrics during query execution - to TTY: tty|on|1|true|yes; to STDERR non-interactive mode: err; OFF: off|0|false|no; DEFAULT - interactive to TTY, non-interactive is off.")
("enable-progress-table-toggle", po::value<bool>()->default_value(true), "Enable toggling of the progress table by pressing the control key (Space). Only applicable in interactive mode with the progress table enabled.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I enabled toggling by default, but there is a caveat:
If a client communicates with the server interactively, e.g., using expect program, the keystroke interceptor consumes the input and makes the communication impossible. In our .expect tests I explicitly disabled the --enable-progress-table-toggle option.
Perhaps, we should set this setting to false by default to be on the safe side. It may break clients that automate client interaction through expect-like programs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm totally ok with enabling it by default.
Expect scripts are a rare scenario. The interactive mode is not an API.

@devcrafter devcrafter self-assigned this Oct 1, 2024
@alexey-milovidov alexey-milovidov added this pull request to the merge queue Oct 5, 2024
Merged via the queue into ClickHouse:master with commit 418233d Oct 5, 2024
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 5, 2024
github-merge-queue bot pushed a commit that referenced this pull request Oct 7, 2024
Follow-up on clickhouse-client realtime metrics display #63689
@azat
Copy link
Copy Markdown
Member

azat commented Oct 7, 2024

FWIW if the lines overlaps the terminal width it still flikers

@azat
Copy link
Copy Markdown
Member

azat commented Oct 7, 2024

Also it is not strictly table metrics, but query, so how about renaming all options to reflect this?

azat added a commit to azat/ClickHouse that referenced this pull request Oct 7, 2024
…eptor)

Introduced in ClickHouse#63689, improved from 0.3 to 0.1 in ClickHouse#70423 with condvar.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants