ClickHouse icon indicating copy to clipboard operation
ClickHouse copied to clipboard

Enhance ClickHouse Profile: generate a uniq id for steps and processors

Open qhsong opened this issue 1 year ago • 11 comments

Changelog category (leave one):

  • Improvement

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

uniform step and pipeline

Clickhouse current profiling are sometimes confuse for me:

  • For explain plan we got step name
  • For explain pipeline we got processor name
  • For system.processor_profile_log/system.opentelemetry_span_log, we got an pointer address

When we need analyze a complex query with dup name, it's hard to identify those things. I think we need generate an uniq ID for every processor and step which should meaningful and can not change for every query. I use ${NAME}_${INDEX} patten as uniq ID style. ${NAME} means step/processor name, ${INDEX} is generated by generated time.

After this PR, for a query select * from t1 as t join t1 as t2 on t.a=t2.a where t.a=1

  • explain
  ┌─explain───────────────────────────────────────────┐
1. │ Expression_20 ((Project names + (Projection + ))) │
2. │   Join_6 (JOIN FillRightFirst)                    │
3. │     Expression_21                                 │
4. │       ReadFromMergeTree_0 (default.t1)            │
5. │     Expression_22                                 │
6. │       ReadFromMergeTree_3 (default.t1)            │
   └───────────────────────────────────────────────────┘
  • explain pipeline
    ┌─explain──────────────────────────────────────────────────────────────────┐
 1. │ (Expression_20)                                                          │
 2. │ ExpressionTransform                                                      │
 3. │   (Join_6)                                                               │
 4. │   JoiningTransform 2 → 1                                                 │
 5. │     (Expression_21)                                                      │
 6. │     ExpressionTransform                                                  │
 7. │       (ReadFromMergeTree_0)                                              │
 8. │       MergeTreeSelect(pool: ReadPoolInOrder, algorithm: InOrder) 0 → 1   │
 9. │     (Expression_22)                                                      │
10. │     FillingRightJoinSide                                                 │
11. │       ExpressionTransform                                                │
12. │         (ReadFromMergeTree_3)                                            │
13. │         MergeTreeSelect(pool: ReadPoolInOrder, algorithm: InOrder) 0 → 1 │
    └──────────────────────────────────────────────────────────────────────────┘
  • select id, name,parent_ids,plan_step from system.processors_profile_log;
     ┌─id──────────────────────────┬─name────────────────────┬─parent_ids──────────────────────┬─plan_step──────────┐
  6. │ SourceFromSingleChunk_1     │ SourceFromSingleChunk   │ ['ExpressionTransform_2']       │                    │
  7. │ ExpressionTransform_2       │ ExpressionTransform     │ ['LimitsCheckingTransform_3']   │ Expression_19      │
  8. │ LimitsCheckingTransform_3   │ LimitsCheckingTransform │ ['LazyOutputFormat_4']          │                    │
  9. │ NullSource_5                │ NullSource              │ ['LazyOutputFormat_4']          │                    │
 10. │ NullSource_6                │ NullSource              │ ['LazyOutputFormat_4']          │                    │
 11. │ LazyOutputFormat_4          │ LazyOutputFormat        │ []                              │                    │
 12. │ SourceFromSingleChunk_18    │ SourceFromSingleChunk   │ ['FilterTransform_19']          │                    │
 13. │ FilterTransform_19          │ FilterTransform         │ ['ExpressionTransform_20']      │ Filter_416         │
 14. │ ExpressionTransform_20      │ ExpressionTransform     │ ['DistinctTransform_83']        │ Expression_167     │
 15. │ SourceFromSingleChunk_21    │ SourceFromSingleChunk   │ ['FilterTransform_22']          │                    │
 16. │ FilterTransform_22          │ FilterTransform         │ ['ExpressionTransform_23']      │ Filter_417         │
 17. │ ExpressionTransform_23      │ ExpressionTransform     │ ['DistinctTransform_84']        │ Expression_433     │
  • select operation_name from system.opentelemetry_span_log;
    ┌─operation_name───────────────────────────────────────────────┐
 1. │ DB::InterpreterSelectQueryAnalyzer::execute()                │
 2. │ ThreadPoolRead                                               │
 3. │ ThreadPoolRead                                               │
 4. │ MergeTreeSource::tryGenerate()                               │
 5. │ MergeTreeSelect(pool: ReadPoolInOrder, algorithm: InOrder)_0 │
 6. │ ExpressionTransform_1                                        │
 7. │ ExpressionTransform_2                                        │
 8. │ LimitsCheckingTransform_3                                    │
 9. │ LazyOutputFormat_4                                           │
10. │ MergeTreeSource::tryGenerate()                               │
11. │ MergeTreeSelect(pool: ReadPoolInOrder, algorithm: InOrder)_0 │
12. │ NullSource_5                                                 │
13. │ NullSource_6                                                 │
14. │ LazyOutputFormat_4                                           │
15. │ PipelineExecutor::execute()                                  │
16. │ QueryPullPipeEx                                              │
17. │ query                                                        │
18. │ TCPHandler                                                   │
    └──────────────────────────────────────────────────────────────┘

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

qhsong avatar May 08 '24 11:05 qhsong

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 08 '24 11:05 CLAassistant

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

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

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❌ failure
Integration testsThe integration tests report. In parenthesis the package type is given, and in square brackets are the optional part/total tests❌ failure
Stateless testsRuns stateless functional tests for ClickHouse binaries built in various configurations -- release, debug, with sanitizers, etc❌ failure
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❌ failure
Successful checks
Check nameDescriptionStatus
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
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
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
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

robot-ch-test-poll1 avatar May 08 '24 11:05 robot-ch-test-poll1

Not sure this idea is work for ClickHouse, if worked, maybe I will add more test case for this.

qhsong avatar May 08 '24 12:05 qhsong

for explain plan and pipeline I don't think there is a lot of confusion, since they already contain formatting that displays hierarchy. also we have a lot of tests that check plan or pipeline specifically. they all will break. speaking of processors_profile_log - fully agree. maybe let's implement it only for processors_profile_log and opentelemetry_span_log?

nickitat avatar May 08 '24 23:05 nickitat

for explain plan and pipeline I don't think there is a lot of confusion, since they already contain formatting that displays hierarchy. also we have a lot of tests that check plan or pipeline specifically. they all will break. speaking of processors_profile_log - fully agree. maybe let's implement it only for processors_profile_log and opentelemetry_span_log?

In fact, I believe that the explain plan plays a crucial role in this PR. When we use processor_profile_log or open telemetry_span_log to identify a specific process or step with slow execution, how can we determine the corresponding details for this steps? Therefore, I think it's essential for us.

I have observed that it break some stateless test cases. I believe it's worthwhile to modify the test case content. It's not hard to change.

qhsong avatar May 09 '24 02:05 qhsong

for explain plan and pipeline

I actually think, that it's make more sense to add them (ids) in json output for those statements, which is more suitable format for consumption by program, and introduction of new field simpler here.

UnamedRus avatar May 09 '24 18:05 UnamedRus

for explain plan and pipeline

I actually think, that it's make more sense to add them (ids) in json output for those statements, which is more suitable format for consumption by program, and introduction of new field simpler here.

I also add a field in explain json. I will fix it later.

qhsong avatar May 10 '24 03:05 qhsong

Summary this feature:

  • Add "Node Id" in explain json=1
            {
              "Node Type": "Expression",
              "Node Id": "Expression_22",
              "Plans": [
                {
                  "Node Type": "ReadFromMergeTree",
                  "Node Id": "ReadFromMergeTree_2",
                  "Description": "default.t1"
                }
              ]
            }
  • Add Step id and iprocessor id in explain pipeline graph=1 Screenshot 2024-05-15 at 21 06 21

  • Add processor_uniq_id and step_uniq_id in processors_profile_log

  • Change Processor_id in opentelemetry_span_log

qhsong avatar May 15 '24 13:05 qhsong

Dear @nickitat, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

clickhouse-gh[bot] avatar Jul 02 '24 13:07 clickhouse-gh[bot]

@qhsong, let's continue. Please take a look at failed builds.

alexey-milovidov avatar Jul 17 '24 01:07 alexey-milovidov

@qhsong, let's continue. Please take a look at failed builds.

Sorry for my delayed, I will change it ASAP.

qhsong avatar Jul 17 '24 03:07 qhsong

hi @nickitat , could help me review this PR?

qhsong avatar Aug 11 '24 14:08 qhsong

hi @nickitat, do we have any update here? I have new PR rely on this.

qhsong avatar Sep 29 '24 01:09 qhsong

hi @nickitat, do we have any update here? I have new PR rely on this.

i want to take a closer look at the implementation. just need to find time for that. pls don't take it as a lack of interest in this pr - we 100% need it

nickitat avatar Sep 30 '24 09:09 nickitat

hi @nickitat, do we have any update here? I have new PR rely on this.

i want to take a closer look at the implementation. just need to find time for that. pls don't take it as a lack of interest in this pr - we 100% need it

Hope get more reply on this.

qhsong avatar Oct 04 '24 13:10 qhsong