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

[Refactor] reduce sending audit stats in exchange #37083

Merged
merged 5 commits into from
Dec 18, 2023

Conversation

fzhedu
Copy link
Contributor

@fzhedu fzhedu commented Dec 14, 2023

Why I'm doing:

sending audit stats for each chunk request takes 27% of time in high concurrent workloads.

What I'm doing:

reduce sending audit stats every _sent_audit_stats_frequency.
_sent_audit_stats_frequency = max(64, RoundUpToPowerOfTwo(fragment_ctx->num_drivers() * 4))), it is scale up with drivers' num. It help to know large query' audit stats even missing the last chunk.

the last chunk of exchange should sent audit stats.

results:
reduce 4% cost to null

Fixes #37082

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@fzhedu fzhedu requested review from liuyehcf, murphyatwork and silverbullet233 and removed request for liuyehcf and murphyatwork December 14, 2023 13:23
This reverts commit b859217.

Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
request.params->clear_query_statistics();
_eos_query_stats[instance_id.lo]->to_pb(request.params->mutable_query_statistics());
_eos_query_stats[instance_id.lo]->clear();
if (auto final_stats = _fragment_ctx->runtime_state()->query_ctx()->intermediate_query_statistic()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what if there is a short circuit, the receiver side won't wait the last eos packet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is up to the sent stats by _sent_audit_stats_frequency

}
}
} else {
if ((_request_sent & _sent_audit_stats_frequency) == _sent_audit_stats_frequency) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if total _request_sent is less than 127 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that will be up the eos's last request.

murphyatwork
murphyatwork previously approved these changes Dec 15, 2023
@@ -192,6 +189,8 @@ class SinkBuffer {
int64_t _first_send_time = -1;
int64_t _last_receive_time = -1;
int64_t _rpc_http_min_size = 0;

int64_t _sent_audit_stats_frequency = 127;
Copy link
Contributor

Choose a reason for hiding this comment

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

better to define a static const variable for 127?

Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Copy link

[FE Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[BE Incremental Coverage Report]

fail : 0 / 11 (00.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 src/exec/pipeline/query_context.cpp 0 1 00.00% [168]
🔵 src/exec/pipeline/exchange/sink_buffer.cpp 0 10 00.00% [33, 35, 95, 96, 97, 98, 100, 101, 325, 326]

@fzhedu fzhedu merged commit cd07b2d into StarRocks:main Dec 18, 2023
44 checks passed
@fzhedu
Copy link
Contributor Author

fzhedu commented Dec 18, 2023

@mergify backport branch-2.5

Copy link
Contributor

mergify bot commented Dec 18, 2023

backport branch-2.5

✅ Backports have been created

@fzhedu
Copy link
Contributor Author

fzhedu commented Dec 18, 2023

@mergify backport branch-3.0

Copy link
Contributor

mergify bot commented Dec 18, 2023

backport branch-3.0

✅ Backports have been created

@fzhedu
Copy link
Contributor Author

fzhedu commented Dec 18, 2023

@mergify backport branch-3.1

Copy link
Contributor

mergify bot commented Dec 18, 2023

backport branch-3.1

✅ Backports have been created

@fzhedu
Copy link
Contributor Author

fzhedu commented Dec 18, 2023

@mergify backport branch-3.2

mergify bot pushed a commit that referenced this pull request Dec 18, 2023
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
(cherry picked from commit cd07b2d)

# Conflicts:
#	be/src/exec/pipeline/exchange/sink_buffer.cpp
#	be/src/runtime/runtime_state.cpp
#	be/src/runtime/runtime_state.h
mergify bot pushed a commit that referenced this pull request Dec 18, 2023
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
(cherry picked from commit cd07b2d)

# Conflicts:
#	be/src/runtime/runtime_state.cpp
#	be/src/runtime/runtime_state.h
mergify bot pushed a commit that referenced this pull request Dec 18, 2023
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
(cherry picked from commit cd07b2d)

# Conflicts:
#	be/src/runtime/runtime_state.cpp
#	be/src/runtime/runtime_state.h
Copy link
Contributor

mergify bot commented Dec 18, 2023

backport branch-3.2

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Dec 18, 2023
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
(cherry picked from commit cd07b2d)
wanpengfei-git pushed a commit that referenced this pull request Dec 18, 2023
…37236)

Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Co-authored-by: Zhuhe Fang <fzhedu@gmail.com>
wanpengfei-git pushed a commit that referenced this pull request Dec 18, 2023
…37234)

Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Co-authored-by: Zhuhe Fang <fzhedu@gmail.com>
wanpengfei-git pushed a commit that referenced this pull request Dec 18, 2023
…37235)

Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Co-authored-by: Zhuhe Fang <fzhedu@gmail.com>
wanpengfei-git pushed a commit that referenced this pull request Dec 21, 2023
Zhangg7723 pushed a commit to Zhangg7723/starrocks that referenced this pull request Dec 26, 2023
Signed-off-by: Zhuhe Fang <fzhedu@gmail.com>
Signed-off-by: 张敢 <zhanggan@deepexi.com>
ZiheLiu pushed a commit to ZiheLiu/starrocks that referenced this pull request Jan 10, 2024
ZiheLiu pushed a commit to ZiheLiu/starrocks that referenced this pull request Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

audit stats' lock takes too much time
5 participants