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

Remove lock in FunctionManager #2273

Merged
merged 3 commits into from
Aug 6, 2020

Conversation

xuguruogu
Copy link
Collaborator

atomic operation acts like dead lock, and can not go out of the while loop if multi-thread access it frequently.

image

@xuguruogu xuguruogu force-pushed the remove-function-mgr-lock branch from 694097f to 4d87ba4 Compare August 5, 2020 08:20
@dutor dutor self-requested a review August 5, 2020 08:22
Copy link
Contributor

@dutor dutor left a comment

Choose a reason for hiding this comment

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

Indeed, the lock is not necessary for normal built functions.

@dutor
Copy link
Contributor

dutor commented Aug 5, 2020

But given your post of perf top, I am curious about why FunctionManager::instance is so hot. Except for the first several invokes, it does not involve any atomic or memory barrier thing.

@xuguruogu
Copy link
Collaborator Author

But given your post of perf top, I am curious about why FunctionManager::instance is so hot. Except for the first several invokes, it does not involve any atomic or memory barrier thing.

call function as filter with a little part of data returned.

@@ -60,7 +60,6 @@ class FunctionManager final {
Function body_;
};

mutable folly::RWSpinLock lock_;
std::unordered_map<std::string, FunctionAttributes> functions_;
Copy link
Contributor

@Shylock-Hg Shylock-Hg Aug 5, 2020

Choose a reason for hiding this comment

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

I think you'd better mark it const.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This may not help due to ref counter use atomic operation.

Copy link
Contributor

@dangleptr dangleptr left a comment

Choose a reason for hiding this comment

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

well done.

@dutor dutor added the ready-for-testing PR: ready for the CI test label Aug 5, 2020
@dutor dutor changed the title Remove function mgr lock Remove lock in FunctionManager Aug 6, 2020
@dutor dutor merged commit 2249c03 into vesoft-inc:master Aug 6, 2020
tong-hao pushed a commit to tong-hao/nebula that referenced this pull request Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants