Skip to content

feat: add time series statistics profile #17809

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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

dqhl76
Copy link
Collaborator

@dqhl76 dqhl76 commented Apr 18, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

close: #17779

Add time series statistics profile. Iniaitily, we support output_rows and output_bytes. This allows us to visualize and compare the data processing speed of different plan nodes.

{"query_id":"ed83c41f-1307-4b13-bd77-710e5e3128c6","plan_id":2,"stats_name":"output_rows","stats":[[1744971865000,69992448],[1744971866000,77529088],[1744971867000,86245376],[1744971868000,87425024],[1744971869000,97648640],[1744971870000,95813632],[1744971871000,105775104],[1744971872000,110493696],[1744971873000,113377280]]}

{"query_id":"ed83c41f-1307-4b13-bd77-710e5e3128c6","plan_id":2,"stats_name":"output_bytes","stats":[[1744971865000,559939584],[1744971866000,620232704],[1744971867000,689963008],[1744971868000,699400192],[1744971869000,781189120],[1744971870000,766509056],[1744971871000,846200832],[1744971872000,883949568],[1744971873000,907018240]]}

{"query_id":"ed83c41f-1307-4b13-bd77-710e5e3128c6","plan_id":2,"stats_name":"output_bytes","stats":[[1744971874000,953155584]]}

{"query_id":"ed83c41f-1307-4b13-bd77-710e5e3128c6","plan_id":2,"stats_name":"output_rows","stats":[[1744971874000,119144448]]}

image

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Apr 18, 2025
@dqhl76 dqhl76 force-pushed the time-series-profile branch 2 times, most recently from 971528e to dfdef76 Compare April 18, 2025 13:17
@dqhl76 dqhl76 added ci-benchmark Benchmark: run all test and removed ci-benchmark Benchmark: run all test labels Apr 21, 2025
Copy link
Contributor

Docker Image for PR

  • tag: pr-17809-bf4ac89-1745211953

note: this image tag is only available for internal use.

@dqhl76
Copy link
Collaborator Author

dqhl76 commented Apr 21, 2025

Disabled in log by default. Enable by adding databend::log::time_series=INFO

[log.file]
level = "INFO,databend::log::time_series=INFO"

@dqhl76 dqhl76 force-pushed the time-series-profile branch from 3cf1865 to a0ecd35 Compare April 21, 2025 06:38
@dqhl76 dqhl76 marked this pull request as ready for review April 21, 2025 07:36
@dqhl76 dqhl76 requested a review from zhang2014 April 21, 2025 07:36
@dqhl76 dqhl76 added the ci-benchmark Benchmark: run all test label Apr 22, 2025
Copy link
Contributor

Docker Image for PR

  • tag: pr-17809-07566f6-1745306957

note: this image tag is only available for internal use.

This reverts commit dc7fb59.
@dqhl76 dqhl76 removed the ci-benchmark Benchmark: run all test label Apr 22, 2025
@dqhl76
Copy link
Collaborator Author

dqhl76 commented Apr 22, 2025

@zhang2014 Benchmark looks good. Please take a look again

profile.statistics[name as usize].fetch_add(value, Ordering::SeqCst);
let previous_value =
profile.statistics[name.clone() as usize].fetch_add(value, Ordering::SeqCst);
if let Some(time_series_profile) = &profile.time_series {
Copy link
Member

Choose a reason for hiding this comment

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

add record_timeseries_profile function is better?

}

pub fn finish(&self) {
for item in self.items.iter() {
Copy link
Member

@zhang2014 zhang2014 Apr 24, 2025

Choose a reason for hiding this comment

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

Maybe need record last point?

let mut items = Vec::with_capacity(len);
for i in 0..len {
items.push(TimeSeriesProfileItem {
queue: ConcurrentQueue::unbounded(),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
queue: ConcurrentQueue::unbounded(),
queue: ConcurrentQueue::bounded(DEFAULT_BATCH_SIZE),

Ordering::SeqCst,
) {
Ok(_) => {
item.queue
Copy link
Member

Choose a reason for hiding this comment

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

flush if queue is full

let previous_value =
profile.statistics[name.clone() as usize].fetch_add(value, Ordering::SeqCst);
if let Some(time_series_profile) = &profile.time_series {
time_series_profile.record_point(name, previous_value + value);
Copy link
Member

Choose a reason for hiding this comment

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

losting data.

@zhang2014 zhang2014 marked this pull request as draft April 24, 2025 02:52
pub stats_name: String,
pub stats: Vec<(usize, usize)>,
}
info!(
Copy link
Member

Choose a reason for hiding this comment

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

too many logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: support time-series plan profile
3 participants