-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](cloud) fix file cache potential leakage #46561
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
[fix](cloud) fix file cache potential leakage #46561
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
13739c8 to
272ecea
Compare
|
run buildall |
TPC-H: Total hot run time: 32805 ms |
TPC-DS: Total hot run time: 195212 ms |
ClickBench: Total hot run time: 31.72 s |
|
run p0 |
1 similar comment
|
run p0 |
1a55a0a to
c70b01d
Compare
|
run buildall |
TPC-H: Total hot run time: 32575 ms |
TPC-DS: Total hot run time: 196353 ms |
ClickBench: Total hot run time: 31.05 s |
|
run beut |
|
run buildall |
2ead512 to
f0ce039
Compare
|
run buildall |
1 similar comment
|
run buildall |
TPC-H: Total hot run time: 32961 ms |
TPC-DS: Total hot run time: 195635 ms |
ClickBench: Total hot run time: 31.63 s |
df8f75e to
d734743
Compare
|
run buildall |
TPC-H: Total hot run time: 32917 ms |
TPC-DS: Total hot run time: 195071 ms |
ClickBench: Total hot run time: 31.43 s |
TPC-H: Total hot run time: 32500 ms |
|
TeamCity be ut coverage result: |
TPC-DS: Total hot run time: 194278 ms |
ClickBench: Total hot run time: 30.66 s |
|
run buildall |
|
TeamCity be ut coverage result: |
|
run external |
|
run performance |
TPC-H: Total hot run time: 32215 ms |
TPC-DS: Total hot run time: 193427 ms |
ClickBench: Total hot run time: 30.03 s |
|
PR approved by at least one committer and no changes requested. |
| int64_t duration_ns = 0; | ||
| SCOPED_RAW_TIMER(&duration_ns); | ||
| Status st = _storage->remove(key); | ||
| *_storage_async_remove_latency << duration_ns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
microseconds is enough, and easy to keep consistent with existing latency unit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
microseconds is enough, and easy to keep consistent with existing latency unit
OK, another monitor PR is on the way. Do it later.
dataroaring
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| void BlockFileCache::run_background_gc() { | ||
| FileCacheKey key; | ||
| static const size_t interval_ms = 100; | ||
| const size_t batch_limit = config::file_cache_remove_block_qps_limit * interval_ms / 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- should move into while loop to be dynamically configurable
- interval_ms set to interval_us = 1000us
const size_t batch_limit = std::max(config::file_cache_remove_block_qps_limit * (interval_us / 1000000.0), 1); - single thread IO bottleneck
- corner cases: upper bound and lower bound
将原来的 同步/异步删除 cache meta + 同步/异步删除 cache data file 多维度的删除策略降维简化: 所有 cache meta 都是同步删除(除正在使用,此case处理方式见下文),data file在 critical 场景同步删除、gc 场景下异步删除 异步清理调度的优化: - 之前的调度逻辑会提前中断,导致清理效率低下 - 甚至调度会有概率进入某些状态导致清理无法继续进行 - 优化 CPU 使用,避免额外无效队列遍历 - 增加窗口算法对异步删除 data file 进行 qps 限制 优化标记删除: - 之前的标记删除机制对 TTL data file 有两个方面的空间泄漏问题 - 扩展应用场景:从原来只能用于 clear_cache、reset_capacity缩容,扩展任意异步删除的场景 - 将新的标记删除机制 除应用在 正在引用的数据之外,还解决了 DOWNLOADING 状态数据的删除泄漏问题 fix 删除正在引用的数据过程的多处泄漏: - 之前没有机制对于正在引用的数据进行标记删除,只能放任赦免 - 现在配合优化后的标记删除机制,使用析构函数在释放引用后自动删除 发现并修复队列操作中存在的内存写飞隐患 - reset_capacity 在迭代内部 erase容器条目,可能会导致指针悬空 其它小优化: - 使用 concurrentqueue 代替之前的静态无锁队列:保持性能的同时减少队列满、进入同步删文件带来的 IO burst 及伴随的 cache lock 开销 - 清理弃用的 file_cache_ttl_valid_check_interval_second 配置:现在 ttl 支持 LRU 了,不用额外定时清理 - 多线程拆分:避免 metrics、resource limit、data file 清理、ttl 超时清理 相互影响 Signed-off-by: zhengyu <zhangzhengyu@selectdb.com>
将原来的 同步/异步删除 cache meta + 同步/异步删除 cache data file 多维度的删除策略降维简化: 所有 cache meta 都是同步删除(除正在使用,此case处理方式见下文),data file在 critical 场景同步删除、gc 场景下异步删除 异步清理调度的优化: - 之前的调度逻辑会提前中断,导致清理效率低下 - 甚至调度会有概率进入某些状态导致清理无法继续进行 - 优化 CPU 使用,避免额外无效队列遍历 - 增加窗口算法对异步删除 data file 进行 qps 限制 优化标记删除: - 之前的标记删除机制对 TTL data file 有两个方面的空间泄漏问题 - 扩展应用场景:从原来只能用于 clear_cache、reset_capacity缩容,扩展任意异步删除的场景 - 将新的标记删除机制 除应用在 正在引用的数据之外,还解决了 DOWNLOADING 状态数据的删除泄漏问题 fix 删除正在引用的数据过程的多处泄漏: - 之前没有机制对于正在引用的数据进行标记删除,只能放任赦免 - 现在配合优化后的标记删除机制,使用析构函数在释放引用后自动删除 发现并修复队列操作中存在的内存写飞隐患 - reset_capacity 在迭代内部 erase容器条目,可能会导致指针悬空 其它小优化: - 使用 concurrentqueue 代替之前的静态无锁队列:保持性能的同时减少队列满、进入同步删文件带来的 IO burst 及伴随的 cache lock 开销 - 清理弃用的 file_cache_ttl_valid_check_interval_second 配置:现在 ttl 支持 LRU 了,不用额外定时清理 - 多线程拆分:避免 metrics、resource limit、data file 清理、ttl 超时清理 相互影响 Signed-off-by: zhengyu <zhangzhengyu@selectdb.com>
将原来的 同步/异步删除 cache meta + 同步/异步删除 cache data file 多维度的删除策略降维简化: 所有 cache meta 都是同步删除(除正在使用,此case处理方式见下文),data file在 critical 场景同步删除、gc 场景下异步删除 异步清理调度的优化: - 之前的调度逻辑会提前中断,导致清理效率低下 - 甚至调度会有概率进入某些状态导致清理无法继续进行 - 优化 CPU 使用,避免额外无效队列遍历 - 增加窗口算法对异步删除 data file 进行 qps 限制 优化标记删除: - 之前的标记删除机制对 TTL data file 有两个方面的空间泄漏问题 - 扩展应用场景:从原来只能用于 clear_cache、reset_capacity缩容,扩展任意异步删除的场景 - 将新的标记删除机制 除应用在 正在引用的数据之外,还解决了 DOWNLOADING 状态数据的删除泄漏问题 fix 删除正在引用的数据过程的多处泄漏: - 之前没有机制对于正在引用的数据进行标记删除,只能放任赦免 - 现在配合优化后的标记删除机制,使用析构函数在释放引用后自动删除 发现并修复队列操作中存在的内存写飞隐患 - reset_capacity 在迭代内部 erase容器条目,可能会导致指针悬空 其它小优化: - 使用 concurrentqueue 代替之前的静态无锁队列:保持性能的同时减少队列满、进入同步删文件带来的 IO burst 及伴随的 cache lock 开销 - 清理弃用的 file_cache_ttl_valid_check_interval_second 配置:现在 ttl 支持 LRU 了,不用额外定时清理 - 多线程拆分:避免 metrics、resource limit、data file 清理、ttl 超时清理 相互影响 Signed-off-by: zhengyu <zhangzhengyu@selectdb.com>
将原来的 同步/异步删除 cache meta + 同步/异步删除 cache data file 多维度的删除策略降维简化: 所有 cache meta 都是同步删除(除正在使用,此case处理方式见下文),data file在 critical 场景同步删除、gc 场景下异步删除
异步清理调度的优化:
优化标记删除:
fix 删除正在引用的数据过程的多处泄漏:
发现并修复队列操作中存在的内存写飞隐患
其它小优化:
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)