Skip to content

Conversation

@dqhl76
Copy link
Collaborator

@dqhl76 dqhl76 commented Dec 8, 2025

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

Summary

format! in Runtime::try_spawn is expensive, which could be pre-assemble to avoid the string assemble overhead.

format!("Running query {} spawn task", query_id)

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-chore this PR only has small changes that no need to record, like coding styles. label Dec 8, 2025
@dqhl76 dqhl76 changed the title chore: reduce overhead when log level is not DEBUG chore: reduce extra overhead in heavy IO loop when log level is not DEBUG Dec 8, 2025
@dqhl76 dqhl76 added ci-cloud Build docker image for cloud test and removed ci-cloud Build docker image for cloud test labels Dec 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

Docker Image for PR

  • tag: pr-19077-96c8539-1765189943

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

@dqhl76 dqhl76 closed this Dec 9, 2025
@dqhl76 dqhl76 reopened this Dec 11, 2025
@dqhl76 dqhl76 added the ci-cloud Build docker image for cloud test label Dec 11, 2025
@github-actions
Copy link
Contributor

Docker Image for PR

  • tag: pr-19077-7cd9480-1765447147

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

@dqhl76 dqhl76 added ci-cloud Build docker image for cloud test and removed ci-cloud Build docker image for cloud test labels Dec 12, 2025
@github-actions
Copy link
Contributor

Docker Image for PR

  • tag: pr-19077-eb8fa8f-1765523646

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

@dqhl76 dqhl76 changed the title chore: reduce extra overhead in heavy IO loop when log level is not DEBUG chore: remove format! in heavy IO loop Dec 12, 2025
@dqhl76
Copy link
Collaborator Author

dqhl76 commented Dec 12, 2025

after:
image

The real overhead is format! in try_spawn:

impl TrySpawn for Runtime {
#[track_caller]
fn try_spawn<T>(&self, task: T, name: Option<String>) -> Result<JoinHandle<T::Output>>
where
T: Future + Send + 'static,
T::Output: Send + 'static,
{
let task = ThreadTracker::tracking_future(task);
let location_name = {
if let Some(name) = name {
name
} else {
match ThreadTracker::query_id() {
None => String::from(GLOBAL_TASK_DESC),
Some(query_id) => {
format!("Running query {} spawn task", query_id)
}
}
}
};
let task = async_backtrace::location!(location_name).frame(task);
#[expect(clippy::disallowed_methods)]
Ok(JoinHandle::create(self.handle.spawn(task)))
}

@dqhl76 dqhl76 requested a review from zhang2014 December 12, 2025 07:42
@dqhl76 dqhl76 marked this pull request as ready for review December 12, 2025 07:45
@zhang2014 zhang2014 merged commit 5594436 into databendlabs:main Dec 12, 2025
105 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-cloud Build docker image for cloud test pr-chore this PR only has small changes that no need to record, like coding styles.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants