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

Support detection of bthread mutex and FastMutex deadlock caused by double lock #2765

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chenBright
Copy link
Contributor

@chenBright chenBright commented Sep 16, 2024

What problem does this PR solve?

Issue Number:

Problem Summary:

What is changed and the side effects?

Changed:

加锁成功记录下拥有锁的bthread/pthread id,如果在同一个bthread/pthread,就可以检测到在同一个bthread/pthread中重复加锁。

Side effects:

  • Performance effects(性能影响):

  • Breaking backward compatibility(向后兼容性):


Check List:

  • Please make sure your changes are compilable(请确保你的更改可以通过编译).
  • When providing us with a new feature, it is best to add related tests(如果你向我们增加一个新的功能, 请添加相关测试).
  • Please follow Contributor Covenant Code of Conduct.(请遵循贡献者准则).

@chenBright chenBright changed the title Support detection of bthread mutex and FastMutex caused by double lock Support detection of bthread mutex and FastMutex deadlock caused by double lock Sep 16, 2024
@wwbmmm
Copy link
Contributor

wwbmmm commented Sep 19, 2024

这个是否会影响性能?

@chenBright chenBright force-pushed the bthread_deadlock_detection branch 6 times, most recently from 2daa334 to da030ca Compare September 22, 2024 03:10
@chenBright
Copy link
Contributor Author

这个是否会影响性能?

之前的实现不会影响性能,但是没用原子变量没法保证正确性。现在用原子变量实现后会导致性能退化,MutexTest.performance测试发现锁的平均运行时间慢了50%左右,所以该功能只作为debug手段,默认关闭,只有编译bRPC库时定义了DEBUG_MUTEX宏才会开启该功能。

@wwbmmm
Copy link
Contributor

wwbmmm commented Sep 22, 2024

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants