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

CpuRecorder may leak memory for destroyed threads #15304

Closed
Tracked by #16375
overvenus opened this issue Aug 9, 2023 · 0 comments · Fixed by #15373
Closed
Tracked by #16375

CpuRecorder may leak memory for destroyed threads #15304

overvenus opened this issue Aug 9, 2023 · 0 comments · Fixed by #15373

Comments

@overvenus
Copy link
Member

Bug Report

CpuRecorder.thread_stats never get cleanup. It should remove threads that is not in _thread_stores.
Through it may not be a real problem as TiKV does not create and destroy threads frequently.

fn cleanup(
&mut self,
_records: &mut RawRecords,
_thread_stores: &mut HashMap<Pid, LocalStorage>,
) {
const THREAD_STAT_LEN_THRESHOLD: usize = 500;
if self.thread_stats.capacity() > THREAD_STAT_LEN_THRESHOLD
&& self.thread_stats.len() < THREAD_STAT_LEN_THRESHOLD / 2
{
self.thread_stats.shrink_to(THREAD_STAT_LEN_THRESHOLD);
}
}

What version of TiKV are you using?

v7.3.0

ti-chi-bot bot added a commit that referenced this issue Aug 21, 2023
close #15304

resource_metering: free leaked thread CPU stats

Signed-off-by: Neil Shen <overvenus@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
ti-chi-bot pushed a commit to ti-chi-bot/tikv that referenced this issue Aug 21, 2023
close tikv#15304

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant