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

Replace std::sync::<Lock> with parking_lot lib #44

Open
rogercloud opened this issue Aug 17, 2022 · 3 comments
Open

Replace std::sync::<Lock> with parking_lot lib #44

rogercloud opened this issue Aug 17, 2022 · 3 comments

Comments

@rogercloud
Copy link

The main API difference between the two libs is poison detection. Poison detection is useful when panic happens in some thread while others are still runing, but it's not the case in this lib. In a rpc lib, we usually panic when the whole system breaks and can't be recovered, otherwise we should not panic. In another word there's no need to detection mutex poison in madsim.

Apart from poison detection parking_lot locks have better performance in most cases. So switch to parking_lot sync lock is the obvious choice from my view.

@wangrunji0408
Copy link
Member

I have done this in #41 (replacing std lock with spin).
In fact, since everything is running on a single thread, we know that there won't be any contention but it's possible to be deadlock. So what we really want is something like RefCell but also Sync. It should panic once try_lock failed.

@rogercloud
Copy link
Author

I have done this in #41 (replacing std lock with spin). In fact, since everything is running on a single thread, we know that there won't be any contention but it's possible to be deadlock. So what we really want is something like RefCell but also Sync. It should panic once try_lock failed.

We can't guarantee the single thread scenario as a multi-thread runtime, such as tokio, may be adopted. I guess you mean single thread in sim scenario.

@wangrunji0408
Copy link
Member

Oh yes. I'll do it for std part soon.

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

No branches or pull requests

2 participants