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

[enhancement](cloud) optimize block cache lock #41818

Merged
merged 5 commits into from
Oct 30, 2024

Conversation

freemandealer
Copy link
Contributor

@freemandealer freemandealer commented Oct 14, 2024

  1. async deletion when do stale rowsets reclycle
  2. minimize lock critical size
  3. add cache lock held & wait time info for debug

1. async deletion when do stale rowsets reclycle
2. minimize lock critical size
3. add cache lock held & wait time info for debug

Signed-off-by: freemandealer <[email protected]>
@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@@ -19,6 +19,7 @@

#include <bvar/bvar.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'bvar/bvar.h' file not found [clang-diagnostic-error]

#include <bvar/bvar.h>
         ^

template <class Lock>
concept IsXLock = std::same_as<Lock, std::lock_guard<std::mutex>> ||
std::same_as<Lock, std::unique_lock<std::mutex>>;

class FSFileCacheStorage;

class LockScopedTimer {
public:
LockScopedTimer() : start_(std::chrono::high_resolution_clock::now()) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: use '= default' to define a trivial default constructor [modernize-use-equals-default]

Suggested change
LockScopedTimer() : start_(std::chrono::high_resolution_clock::now()) {}
LockScopedTimer() : start_(std::chrono::high_resolution_clock::now()) = default;

Signed-off-by: freemandealer <[email protected]>
@freemandealer
Copy link
Contributor Author

run buildall

1 similar comment
@freemandealer
Copy link
Contributor Author

run buildall

Signed-off-by: freemandealer <[email protected]>
@freemandealer
Copy link
Contributor Author

run buildall

Signed-off-by: freemandealer <[email protected]>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

template <class Lock>
concept IsXLock = std::same_as<Lock, std::lock_guard<std::mutex>> ||
std::same_as<Lock, std::unique_lock<std::mutex>>;

class FSFileCacheStorage;

class LockScopedTimer {
public:
LockScopedTimer() : start_(std::chrono::steady_clock::now()) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: use '= default' to define a trivial default constructor [modernize-use-equals-default]

Suggested change
LockScopedTimer() : start_(std::chrono::steady_clock::now()) {}
LockScopedTimer() : start_(std::chrono::steady_clock::now()) = default;

@freemandealer
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 37.45% (9709/25922)
Line Coverage: 28.73% (80607/280562)
Region Coverage: 28.19% (41725/148027)
Branch Coverage: 24.76% (21212/85660)
Coverage Report: http://coverage.selectdb-in.cc/coverage/35aac9ef8aa51fa6981f8d4d2c6c9bd1c82b396e_35aac9ef8aa51fa6981f8d4d2c6c9bd1c82b396e/report/index.html

std::chrono::duration_cast<std::chrono::milliseconds>(acq_time - start_time).count(); \
if (duration > config::cache_lock_long_tail_threshold) \
LOG(WARNING) << "Lock wait time " << std::to_string(duration) << "ms. " \
<< get_stack_trace_by_boost() << std::endl; \
Copy link
Contributor

Choose a reason for hiding this comment

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

We should limit frequency of the log.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dataroaring It is limited already: only > config::cache_lock_long_tail_threshold (default:1s) will print the log. If not enough, enlarge the threshold.

@freemandealer
Copy link
Contributor Author

run cloud_p0

@freemandealer
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 37.46% (9712/25925)
Line Coverage: 28.72% (80628/280694)
Region Coverage: 28.18% (41753/148155)
Branch Coverage: 24.74% (21211/85726)
Coverage Report: http://coverage.selectdb-in.cc/coverage/00ae5bd2f3bd4c4cfb87018fc0a23d5a733af054_00ae5bd2f3bd4c4cfb87018fc0a23d5a733af054/report/index.html

while (_recycle_keys->pop(key)) {
Status st = _storage->remove(key);
if (!st.ok()) {
LOG_WARNING("").error(st);
Copy link
Contributor

Choose a reason for hiding this comment

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

put some key word in the log e.g.
"failed to remove when recycle_stale_rowset_async_bottom_half, key = {}" ...

LOG_WARNING("Failed to push recycle key to queue, do it synchronously");
Status st = _storage->remove(key);
if (!st.ok()) {
LOG_WARNING("").error(st);
Copy link
Contributor

@gavinchou gavinchou Oct 24, 2024

Choose a reason for hiding this comment

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

put some key word in the log e.g.
"failed to remove async, key = {}" ...

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Oct 30, 2024
Copy link
Contributor

PR approved by at least one committer and no changes requested.

Copy link
Contributor

PR approved by anyone and no changes requested.

Copy link
Collaborator

@TangSiyang2001 TangSiyang2001 left a comment

Choose a reason for hiding this comment

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

LGTM

@gavinchou gavinchou merged commit cf1714c into apache:master Oct 30, 2024
29 of 36 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 30, 2024
1. async deletion when do stale rowsets reclycle
2. minimize lock critical size
3. add cache lock held & wait time info for debug
freemandealer added a commit to freemandealer/doris that referenced this pull request Nov 7, 2024
pick apache#41818 from master

1. async deletion when do stale rowsets reclycle
2. minimize lock critical size
3. add cache lock held & wait time info for debug
dataroaring pushed a commit that referenced this pull request Nov 7, 2024
pick #41818 from master

1. async deletion when do stale rowsets reclycle
2. minimize lock critical size
3. add cache lock held & wait time info for debug
eldenmoon pushed a commit to eldenmoon/incubator-doris that referenced this pull request Nov 12, 2024
…#43401)

pick apache#41818 from master

1. async deletion when do stale rowsets reclycle
2. minimize lock critical size
3. add cache lock held & wait time info for debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by one committer. dev/3.0.3-merged reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants